Skip to content

Commit

Permalink
Corrected tests removed ChatGPT from setup, using LLM instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maralai committed Aug 8, 2024
1 parent c35c2d6 commit 97b884b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
name='SummarizeGPT',
version='1.2',
packages=find_packages(),
description='Tool to summarize directories of code for prompting with ChatGPT',
description='Tool to summarize directories of code for prompting with LLMs',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Matt Harrison',
Expand Down
30 changes: 17 additions & 13 deletions tests/test_summarize_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ def setUp(self):
self.test_file = os.path.join(self.directory, 'testfile.txt')
# Create a test file with known content
with open(self.test_file, 'w') as f:
f.write("line1\\nline2\\nline3\\nline4\\nline5\\n")

for i in range(5):
f.write(f'line{i+1}\n')

# Create a prompt file with the summary
summary = summarize_directory(self.directory, gitignore_file=self.gitignore_file)
prompt_file = os.path.join(self.directory, 'Context_for_ChatGPT.md')
with open(prompt_file, "w", encoding="utf-8") as f:
f.write(summary)

def tearDown(self):
# Remove the test file after tests
if os.path.isfile(self.test_file):
Expand All @@ -19,28 +26,25 @@ def tearDown(self):
def test_gitignore(self):
# Test that .gitignore is working by checking that LICENSE is not in the summary
summary = summarize_directory(self.directory, gitignore_file=self.gitignore_file)
self.assertNotIn('build.README.md', summary)
self.assertNotIn('## ./Context_for_ChatGPT.md', summary)

def test_include(self):
# Test include and exclude arguments
summary = summarize_directory(self.directory, gitignore_file=self.gitignore_file, include_exts=['.md'])
self.assertIn('python summarize_directory.py', summary)
self.assertIn('python summarize_directory.py', summary) # line from readme should be included

def test_exclude(self):
# Test exclude argument
summary = summarize_directory(self.directory, gitignore_file=self.gitignore_file, exclude_exts=['.md'])
self.assertNotIn('python summarize_directory.py', summary) # README.md should be excluded

def test_max_lines(self):
# Test max_lines argument
# Test the max_lines argument
max_lines = 3
summary = summarize_directory(self.directory, max_lines=max_lines)
file_summary_start = "## {}/testfile.txt\\n".format(self.directory.replace("\\\\", "/"))
file_summary = "line1\\nline2\\nline3"
# Check that the file summary in summary includes only max_lines lines
self.assertIn(file_summary_start, summary)
self.assertIn(file_summary, summary)
self.assertNotIn("line4\\nline5", summary)
summary = summarize_directory(self.directory, gitignore_file=self.gitignore_file, max_lines=max_lines)
# Check if the 'testfile.txt' content is truncated to 'max_lines' lines
self.assertNotIn('line4', summary)
self.assertNotIn('line5', summary)

if __name__ == '__main__':
unittest.main()

0 comments on commit 97b884b

Please sign in to comment.