This PR introduces a series of enhancements and new unit tests for various classes interacting with AWS DynamoDB tables. The goal is to increase code coverage, improve robustness, and ensure consistent error handling across all components. Below is a detailed breakdown of the changes and additions:
Changes by Class
1. DDBHelper Class
Expanded Test Coverage:
Added tests to cover methods for put_ddb_item, get_ddb_item, delete_ddb_item, update_ddb_item, and batch_write_items.
Introduced exception tests to validate error handling and resilience under failure scenarios.
Added checks to verify correct behavior when using conditional expressions and update parameters.
Enhanced Assertions:
Ensured that test cases validate HTTP response status codes and DynamoDB item attributes accurately.
2. EndpointStatisticsTable Class
New Tests Added:
Implemented tests for upsert_endpoint, increment_region_count, decrement_region_count, and current_in_progress_regions.
Verified handling of concurrent updates to region counts and proper upserting logic for new and existing endpoints.
Exception Handling:
Tested exception scenarios where DynamoDB operations fail, ensuring appropriate errors are raised and logged.
3. FeatureTable Class
Increased Test Coverage:
Added tests for methods like add_features, get_features, and group_features_by_key.
Verified behavior for aggregating features, handling large payloads, and parallel processing.
Tested various edge cases to ensure robustness, including handling large and complex feature sets.
New Tests for Error Conditions:
Introduced tests to simulate failure conditions, such as batch write failures, to ensure proper exception handling.
Validated behavior when adding malformed or oversized features.
4. JobTable Class
Comprehensive Unit Testing:
Added unit tests for start_image_request, complete_region_request, is_image_request_complete, end_image_request, and get_image_request.
Ensured behavior aligns with expected outcomes, including start and end times, processing durations, and region counts.
Verified that image requests are correctly identified as complete based on region counts.
Resilience Tests:
Simulated conditions where DynamoDB operations might fail to validate exception handling logic.
Tested scenarios with missing or partial data to ensure system integrity.
5. RegionRequestTable Class
New Unit Tests:
Implemented tests to cover all major functionalities, including start_region_request, complete_region_request, update_region_request, and add_tile.
Tested successful and failed scenarios, such as region completions and tile additions.
Verified that the class handles retry and expiration logic correctly when starting new region requests.
Edge Case Handling:
Added tests for edge cases, including adding invalid tile formats and handling unexpected data structures.
Enhanced the add_tile method tests to ensure tiles are correctly categorized as succeeded or failed.
Introduced tests for partial data processing to ensure flexibility and resilience in handling incomplete inputs.
General Enhancements Across All Classes
Consistent Error Handling:
Standardized exception handling to ensure robust responses to failures.
Ensured that appropriate exceptions are raised and logged for visibility.
Documentation & Readability:
Improved docstrings for clarity and purpose across all tests.
Refined test structure for better readability and maintenance.
Added descriptive comments to each test case to clearly outline expected behavior and what is being validated.
Better Assertion Coverage:
Enhanced assertions to verify deeper aspects of functionality, including attribute values, response status, and processing logic.
Increased coverage to include boundary conditions, negative testing, and concurrency checks where applicable.
Checklist
Before you submit a pull request, please make sure you have the following:
[x] Code changes are compact and well-structured to facilitate easy review
[x] Changes are documented in the README.md and other relevant documentation pages
[x] PR title and description accurately reflect the changes and are detailed enough for historical tracking
[x] PR contains tests that cover all new code and the code has been manual tested
[x] All new dependencies are declared (if any), and no unnecessary libraries are added
[x] Performance impacts (if any) of the changes are evaluated and documented
[x] Security implications of the changes (if any) are reviewed and addressed
Issue #, if available: n/a
Notes
This PR introduces a series of enhancements and new unit tests for various classes interacting with AWS DynamoDB tables. The goal is to increase code coverage, improve robustness, and ensure consistent error handling across all components. Below is a detailed breakdown of the changes and additions:
Changes by Class
1.
DDBHelper
Classput_ddb_item
,get_ddb_item
,delete_ddb_item
,update_ddb_item
, andbatch_write_items
.2.
EndpointStatisticsTable
Classupsert_endpoint
,increment_region_count
,decrement_region_count
, andcurrent_in_progress_regions
.3.
FeatureTable
Classadd_features
,get_features
, andgroup_features_by_key
.4.
JobTable
Classstart_image_request
,complete_region_request
,is_image_request_complete
,end_image_request
, andget_image_request
.5.
RegionRequestTable
Classstart_region_request
,complete_region_request
,update_region_request
, andadd_tile
.add_tile
method tests to ensure tiles are correctly categorized as succeeded or failed.General Enhancements Across All Classes
Checklist
Before you submit a pull request, please make sure you have the following:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.