-
Notifications
You must be signed in to change notification settings - Fork 1
Implement CORE Async - Phase 1 #129
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
Draft
btoron
wants to merge
9
commits into
master
Choose a base branch
from
core-async-phase-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implemented 12 async GET methods for Activities in Core API module with comprehensive test coverage and Pydantic model validation. Changes: - Added 12 new Pydantic models for activities endpoints in ofsc/models.py (ActivityListResponse, SubmittedForm, ResourcePreference, Inventory, etc.) - Implemented 12 async GET methods in ofsc/async_client/core.py: * get_activities - List with pagination * get_activity - Single activity by ID * get_capacity_categories - Capacity categories * get_customer_inventories - Customer inventories * get_deinstalled_inventories - Deinstalled inventories * get_file_property - File property content * get_installed_inventories - Installed inventories * get_linked_activities - Linked activities * get_activity_link - Specific link details * get_required_inventories - Required inventories * get_resource_preferences - Resource preferences * get_submitted_forms - Submitted forms - Added error handling helpers (_parse_error_response, _handle_http_error) - Created comprehensive test suite with 21 passing tests: * 11 live API tests validating against actual OFSC API * 10 saved response validation tests for Pydantic models * Error handling test for 404 responses - Updated scripts/capture_api_responses.py with activities endpoints - Captured 12 API responses to tests/saved_responses/activities/ - Updated docs/ENDPOINTS.md with new async implementations All endpoints follow existing async patterns with PEP 287 docstrings, type hints, and comprehensive exception handling. Test Results: 21 passed, 2 skipped in 4.73s 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implemented a Pydantic model for get_activities query parameters based on Swagger specification with proper validation and type safety. Changes: - Renamed GetActivityRequest → GetActivitiesParams in ofsc/models.py - Added missing svcWorkOrderId parameter - Made resources optional (was incorrectly required) - Used Literal["none", "immediate", "all"] for includeChildren enum - Fixed validator bug (unreachable code after return) - Changed extra="allow" to extra="forbid" for stricter validation - Added to_api_params() method for API parameter conversion Integration: - Updated get_activities() in ofsc/async_client/core.py to accept GetActivitiesParams | dict for backward compatibility - Added validation logic to convert dict to model internally Testing: - Created tests/test_get_activities_params.py with 13 comprehensive tests: * Valid params with various combinations * Invalid params (missing dateTo, dateFrom > dateTo, etc.) * API parameter conversion validation * Enum validation * Extra fields forbidden - Updated existing live API test to use date objects and list for resources - All 13 tests passing + live API test passing Validation Rules: - dateFrom and dateTo must both be specified or both omitted - dateFrom must be <= dateTo - Must have one of: dateFrom/dateTo, svcWorkOrderId, or includeNonScheduled=True 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…e results Updated the live API test to: - Use includeChildren="all" parameter to include child resources - Increase limit from 5 to 100 activities - Assert that more than 5 activities are returned - Ensure results don't exceed limit This provides better test coverage for the GetActivitiesParams model and validates pagination with includeChildren parameter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updated test_get_activities to calculate date range dynamically: - dateFrom: First day of current month (day 1) - dateTo: Last day of current month (day 28/29/30/31 depending on month) Uses calendar.monthrange() to determine the correct last day for any month. This ensures the test always queries relevant current data from the API. Example: For December 2025, queries 2025-12-01 to 2025-12-31 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implemented 18 async GET methods for the Resources API in AsyncOFSCore, with comprehensive Pydantic models and test coverage. **Methods Implemented:** 1. get_assigned_locations() - Get assigned locations for a resource 2. get_calendars() - Get all calendars 3. get_position_history() - Get position history for a resource 4. get_resource() - Get a single resource by ID (with expand support) 5. get_resource_assistants() - Get assistant resources 6. get_resource_calendar() - Get calendar view for a resource 7. get_resource_children() - Get child resources 8. get_resource_descendants() - Get descendant resources (with expand support) 9. get_resource_inventories() - Get inventories assigned to a resource 10. get_resource_location() - Get a single location for a resource 11. get_resource_locations() - Get all locations for a resource 12. get_resource_plans() - Get routing plans for a resource 13. get_resource_route() - Get route for a resource on a specific date 14. get_resource_users() - Get users assigned to a resource 15. get_resource_workschedules() - Get workschedules for a resource 16. get_resource_workskills() - Get workskills assigned to a resource 17. get_resource_workzones() - Get workzones assigned to a resource 18. get_resources() - Get all resources with pagination (with expand support) **Models Added** (ofsc/models.py): - ResourceListResponse - Paginated resource list - ResourceAssistant, ResourceAssistantsResponse - ResourceWorkskillAssignment, ResourceWorkskillListResponse - ResourceWorkzoneAssignment, ResourceWorkzoneListResponse - PositionHistoryItem, PositionHistoryResponse - ResourceRouteActivity, ResourceRouteResponse - ResourcePlan, ResourcePlansResponse - Calendar, CalendarsListResponse **Key Features:** - Python date objects for all date parameters (converted to ISO internally) - Expand parameter support (inventories, workSkills, workZones, workSchedules) - Proper error handling (404, validation, network errors) - Comprehensive exception hierarchy usage - Helper method _build_expand_param() for clean parameter construction **Testing:** - Created tests/async/test_async_resources_get.py with 23 tests - Live API tests for all 18 methods - Saved response validation tests - Error handling tests (404 not found) - All tests passing ✅ **API Responses Captured:** - Added 21 resource endpoints to scripts/capture_api_responses.py - Captured responses for: individual, bucket, group resources - Captured responses for all sub-entities (users, inventories, etc.) - Captured routes, calendars, locations, workskills, workzones **Test Resources Used:** - Individual: 33001 - Bucket: FLUSA - Group: ACMECONTRACTOR - Parent (for hierarchy): SUNRISE 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Reorganize models.py into clearly defined sections: - Core / Activities: Activity models and related responses - Core / Resources: Resource instance models and related responses - Metadata / Resource Types: ResourceType metadata definitions This improves code organization and makes it easier to find and maintain related models. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This was
linked to
issues
Dec 31, 2025
Add pytest-xdist for parallel test execution to reduce test time by 50%+. Changes: - Add pytest-xdist dependency to pyproject.toml - Configure pytest with `-n auto --dist worksteal` for parallel execution - Add `@pytest.mark.serial` marker for tests that modify shared API state - Mark 13 state-modifying tests (subscriptions, workzones, properties) - Create CI workflow (.github/workflows/test.yml) for automated testing - Update README.md with comprehensive testing documentation Test Results: - 541 total tests - 13 marked as serial (run sequentially) - 528 can run in parallel - Mocked tests run in ~17s (vs ~2min sequential) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove stub tests for get_activities and get_resource from test_async_ofsc.py since these methods are now fully implemented (in #117 and #121) and tested in their respective test files. The stub tests were checking for NotImplementedError but the methods now make actual API calls, causing network errors in tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…n permissions Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I