Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests for ClonedRepo class #2378

Merged
merged 4 commits into from
Oct 21, 2023
Merged

Conversation

sweep-nightly[bot]
Copy link
Contributor

@sweep-nightly sweep-nightly bot commented Oct 21, 2023

Description

This PR adds unit tests for the ClonedRepo class in the sweepai/utils/github_utils.py file. The ClonedRepo class is responsible for various operations related to cloning a GitHub repository, listing its directory tree, getting file contents, and more. The added unit tests ensure that these functionalities are working as expected.

The tests have been added in a new file sweepai/utils/github_utils_test.py. Each method in the ClonedRepo class has a corresponding test case. Mocking is used to isolate the ClonedRepo class and its methods for testing.

Summary of Changes

  • Created a new file sweepai/utils/github_utils_test.py for the unit tests.
  • Added a TestClonedRepo class that contains all the unit tests for the ClonedRepo class.
  • For each method in the ClonedRepo class, a corresponding test method has been added in the TestClonedRepo class.
  • Used unittest.mock to create mock objects and patch external resources as needed.

Fixes #2377.


🎉 Latest improvements to Sweep:

  • Sweep can now passively improve your repository! Check out Rules to learn more.

💡 To get Sweep to edit this pull request, you can:

  • Comment below, and Sweep can edit the entire PR
  • Comment on a file, Sweep will only modify the commented file
  • Edit the original issue to get Sweep to recreate the PR from scratch

@sweep-nightly
Copy link
Contributor Author

sweep-nightly bot commented Oct 21, 2023

Rollback Files For Sweep

  • Rollback changes to sweepai/utils/github_utils_test.py
  • Rollback changes to sweepai/utils/github_utils_test.py

@sweep-nightly
Copy link
Contributor Author

sweep-nightly bot commented Oct 21, 2023

Apply Sweep Rules to your PR?

  • Apply: There should not be large chunks of code that are just commented out. Docstrings and explanations in code are acceptable.
  • Apply: We should use loguru for error logging. If the log is inside an exception, use loguru.exception to add tracebacks. Use f-strings for string formatting in logger calls.
  • Apply: There should be no instances of import pdb; pdb.set_trace() in production code.
  • Apply: There should be no debug log or print statements in production code.
  • Apply: All functions should have parameters and output annotated with type hints. Use list, tuple and dict instead of typing.List, typing.Tuple and typing.dict.
  • Apply: Leftover TODOs in the code should be handled.
  • Apply: All new business logic should have corresponding unit tests in the same directory. For example, sweepai/api_test.py tests sweepai/api.py. Use unittest and unittest.mock as required.
  • Apply: Any clearly inefficient or repeated code should be optimized or refactored.
  • Apply: Remove any comments before code that are obvious. For example # this prints hello world; print('hello world').

@sweep-nightly sweep-nightly bot added the sweep Assigns Sweep to an issue or pull request. label Oct 21, 2023
@vercel
Copy link

vercel bot commented Oct 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sweep-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 21, 2023 8:37pm

@wwzeng1 wwzeng1 merged commit 90ea2c4 into main Oct 21, 2023
5 checks passed
@wwzeng1 wwzeng1 deleted the sweep/add-cloned-repo-tests_2 branch October 21, 2023 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sweep Assigns Sweep to an issue or pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sweep: Write unit tests for ClonedRepo
1 participant