Skip to content

Add comprehensive test suite for utility modules and core models#297

Open
amussara wants to merge 1 commit intoridgesai:mainfrom
amussara:add-comprehensive-test-suite-and-error-handling
Open

Add comprehensive test suite for utility modules and core models#297
amussara wants to merge 1 commit intoridgesai:mainfrom
amussara:add-comprehensive-test-suite-and-error-handling

Conversation

@amussara
Copy link
Copy Markdown

  • tests/test_diff.py: Tests for file diff computation, validation, and application
  • tests/test_git_utils.py: Tests for git clone, commit verification, init, and reset
  • tests/test_cost_hash_map.py: Tests for in-memory cost tracking with cleanup
  • tests/test_inference_models.py: Tests for model cost calculation, tool conversion, request/response validation
  • tests/test_ttl_cache.py: Tests for TTL cache key generation, entry lifecycle, and decorator behavior
  • tests/test_temp_utils.py: Tests for temporary directory creation and cleanup
  • tests/test_logger.py: Tests for log levels, formatting, and debug toggle
  • tests/test_evaluation_models.py: Tests for evaluation run status, error codes, and model validation

Covers edge cases including error code categorization, cache eviction, diff header formatting, and subprocess failure handling.

- tests/test_diff.py: Tests for file diff computation, validation, and application
- tests/test_git_utils.py: Tests for git clone, commit verification, init, and reset
- tests/test_cost_hash_map.py: Tests for in-memory cost tracking with cleanup
- tests/test_inference_models.py: Tests for model cost calculation, tool conversion, request/response validation
- tests/test_ttl_cache.py: Tests for TTL cache key generation, entry lifecycle, and decorator behavior
- tests/test_temp_utils.py: Tests for temporary directory creation and cleanup
- tests/test_logger.py: Tests for log levels, formatting, and debug toggle
- tests/test_evaluation_models.py: Tests for evaluation run status, error codes, and model validation

Covers edge cases including error code categorization, cache eviction,
diff header formatting, and subprocess failure handling.
Copy link
Copy Markdown

@CryptoAardvark CryptoAardvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for putting this together, the naming conventions and class structure are really clear, and the error code range invariants (1xxx/2xxx/3xxx) in test_evaluation_models.py are a particularly nice touch. All of the observations above are minor and non-blocking from my perspective as an external reviewer. Feel free to take or leave any of them, and apologies if any of this overlaps with conventions I'm not aware of. 🙏

"""Tests for the validate_diff_for_local_repo function."""

def _create_git_repo(self, files: dict) -> str:
repo_dir = tempfile.mkdtemp()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: I noticed the directory created here doesn't appear to be cleaned up after the test finishes, so repeated test runs may leave behind temp directories. If it would be helpful, I think pytest's built-in tmp_path fixture handles cleanup automatically and could also eliminate the need for the try/finally blocks in _write_temp.

Comment on lines +57 to +58
with pytest.raises(Exception):
get_file_diff(existing, "/nonexistent/file.txt")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion(non-blocking): Since Exception is the root of most exception hierarchies, these assertions would also pass if the source code raised something unexpected like AttributeError from a typo. If the function raises a more specific type (e.g. FileNotFoundError or a custom exception), catching that explicitly would make the tests a bit stricter:

with pytest.raises(FileNotFoundError):
    get_file_diff(existing, "/nonexistent/file.txt")

That said, I don't know the project's conventions here if broad catching is the preferred style, please disregard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants