-
Notifications
You must be signed in to change notification settings - Fork 18.5k
feat: add comprehensive unit tests for dataset service retrieval/list… #28539
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
base: main
Are you sure you want to change the base?
feat: add comprehensive unit tests for dataset service retrieval/list… #28539
Conversation
… methods Add comprehensive test coverage for dataset service retrieval/list methods: - get_datasets: pagination, search, filtering, permissions * Basic pagination * Search functionality * Tag filtering * Permission-based filtering (ONLY_ME, ALL_TEAM, PARTIAL_TEAM) * Role-based filtering (OWNER, DATASET_OPERATOR, NORMAL) * include_all flag - get_dataset: single dataset retrieval * Successful retrieval * Not found cases - get_datasets_by_ids: bulk retrieval * Successful bulk retrieval * Empty/None list handling - get_process_rules: dataset processing rules * With existing rule * Without existing rule (defaults) - get_dataset_queries: dataset query history * Successful retrieval with pagination * Empty results - get_related_apps: apps using the dataset * Successful retrieval * Empty results Follows TDD principles with Arrange-Act-Assert structure and comprehensive coverage of all scenarios including edge cases.
Summary of ChangesHello @SmartDever02, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the unit test coverage for the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a comprehensive suite of unit tests for the DatasetService retrieval methods, significantly improving test coverage. The tests are well-structured, follow the Arrange-Act-Assert pattern, and cover a wide range of scenarios including pagination, filtering, and permissions.
My review focuses on improving test robustness and correctness. I've suggested using create_autospec consistently for mock creation to make tests more resilient to changes in the underlying models. I also identified and proposed a fix for a test case that had incorrect logic for filtering by tags.
Overall, this is a high-quality contribution that strengthens the reliability of the dataset service.
api/tests/unit_tests/services/test_dataset_service_retrieval.py
Outdated
Show resolved
Hide resolved
|
@crazywoola Please review my pr. |
When tag_ids is an empty list, the implementation skips tag filtering entirely (to avoid WHERE false condition) and continues with the normal query. The test was incorrectly expecting empty results. Updated the test to: - Expect normal query results when tag_ids is empty - Verify that TagService.get_target_ids_by_tag_ids is not called - Verify that pagination is called normally This matches the actual behavior where empty tag_ids means 'no tag filter' rather than 'return empty results'.
Description
This PR adds comprehensive unit test coverage for DatasetService retrieval and list methods, significantly improving test coverage for dataset querying and filtering functionality.
Test Coverage Added
get_datasetsMethod Tests (10 test cases)Basic Functionality:
Permission-Based Filtering:
get_datasetMethod Tests (2 test cases)get_datasets_by_idsMethod Tests (3 test cases)get_process_rulesMethod Tests (2 test cases)get_dataset_queriesMethod Tests (2 test cases)get_related_appsMethod Tests (2 test cases)Testing Approach
test_dataset_service_update_dataset.pytest_dataset_service_delete_dataset.pytest_dataset_permission.pyTest Statistics
test_dataset_service_retrieval.pyRelated Work
This complements the existing test coverage:
test_dataset_models.py- Dataset model tests (PR feat: complete test script for dataset models #28512)test_dataset_service_update_dataset.py- Update operationstest_dataset_service_delete_dataset.py- Delete operationstest_dataset_permission.py- Permission checksChecklist
Contribution by Gittensor, learn more at https://gittensor.io/