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

refactor: updating region_request.py and tests for the class #109

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

drduhe
Copy link
Collaborator

@drduhe drduhe commented Oct 25, 2024

Issue #, if available: n/a

Notes

This PR introduces improvements to the RegionRequest class, focusing on cleaner initialization, enhanced validation, and updated unit tests to ensure robust functionality and maintainability. The PR also deletes the test_api.py file as all the tests that were there have been migrated to the associated ImageRequest and RegionRequest class tests.

Key Changes:

  1. Improved Initialization:

    • Refactored the class to use helper methods for setting default values and attributes from input data, ensuring consistent behavior and cleaner code.
    • Simplified the constructor by delegating attribute-setting logic to private methods, making the class easier to extend and maintain.
  2. Enhanced Validation Logic:

    • Added checks in the is_valid() method to ensure region_bounds is properly set and not left as the default, improving robustness.
    • Retained validation for shared properties, ensuring consistent checks across different request types.
  3. Comprehensive Attribute Documentation:

    • Added reStructuredText-style doc comments for all attributes, providing clear descriptions of each field’s purpose and use. This improves code readability and supports better autogenerated documentation.
  4. Updated and Expanded Unit Tests:

    • Created new unit tests to cover additional scenarios, including missing or invalid image_id and region_bounds.
    • Ensured that tests align with the improved unittest structure, making it easier to run, debug, and maintain.
    • Added setup and teardown methods to streamline testing and ensure consistent test environments.

Checklist

Before you submit a pull request, please make sure you have the following:

  • Code changes are compact and well-structured to facilitate easy review
  • Changes are documented in the README.md and other relevant documentation pages
  • PR title and description accurately reflect the changes and are detailed enough for historical tracking
  • PR contains tests that cover all new code and the code has been manual tested
  • All new dependencies are declared (if any), and no unnecessary libraries are added
  • Performance impacts (if any) of the changes are evaluated and documented
  • Security implications of the changes (if any) are reviewed and addressed
  • I have read the Contributing Guidelines and agree to follow the Code of Conduct

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@drduhe drduhe force-pushed the refactor/update-region-request branch from 00b7468 to 957c947 Compare October 25, 2024 18:19
@drduhe drduhe force-pushed the refactor/update-region-request branch 2 times, most recently from 673d160 to f5c1f77 Compare October 29, 2024 19:12
@drduhe drduhe force-pushed the refactor/update-region-request branch from f5c1f77 to dfd251b Compare October 30, 2024 16:20
@drduhe drduhe merged commit 2b2e2b2 into main Oct 31, 2024
2 checks passed
@drduhe drduhe deleted the refactor/update-region-request branch October 31, 2024 18:50
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