Skip to content

Jules - Factory Boy#10

Draft
s2t2 wants to merge 1 commit intocopybara_pushfrom
feat/add-factory-boy
Draft

Jules - Factory Boy#10
s2t2 wants to merge 1 commit intocopybara_pushfrom
feat/add-factory-boy

Conversation

@s2t2
Copy link
Owner

@s2t2 s2t2 commented May 26, 2025

feat: Introduce factory_boy for test fixtures

Installs factory_boy and sets up initial factories for common data structures.

Key changes:

  • Added factory_boy to dev dependencies.
  • Created smart_control/utils/factory_utils.py containing factories for:
    • Protobuf messages: ActionRequest, SingleActionRequest, ObservationResponse, SingleObservationResponse, ObservationRequest, SingleObservationRequest.
    • Custom classes: SimpleBuilding (from environment_test_utils), MaterialProperties, Building (deprecated simulator building), and FloorPlanBasedBuilding.
  • Refactored tests in smart_control/environment/environment_test.py to use ActionRequestFactory and SimpleBuildingFactory.
  • Refactored tests in smart_control/simulator/building_test.py (test_init_direct_attributes and test_init_direct_attributes_post_refactor) to use DeprecatedBuildingFactory and FloorPlanBasedBuildingFactory.
  • Added smart_control/utils/factory_utils_test.py with examples demonstrating how to create object variations using the new factories.
  • Updated smart_control/utils/BUILD to include targets for the new factory utilities and tests.
  • Added documentation to README.md on how to use and create factories with factory_boy in this project.

These changes make it easier to create and manage test data, improving the clarity and maintainability of tests.

Fixes #<issue_number_goes_here>

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

Installs factory_boy and sets up initial factories for common data structures.

Key changes:
- Added `factory_boy` to dev dependencies.
- Created `smart_control/utils/factory_utils.py` containing factories for:
    - Protobuf messages: `ActionRequest`, `SingleActionRequest`, `ObservationResponse`, `SingleObservationResponse`, `ObservationRequest`, `SingleObservationRequest`.
    - Custom classes: `SimpleBuilding` (from environment_test_utils), `MaterialProperties`, `Building` (deprecated simulator building), and `FloorPlanBasedBuilding`.
- Refactored tests in `smart_control/environment/environment_test.py` to use `ActionRequestFactory` and `SimpleBuildingFactory`.
- Refactored tests in `smart_control/simulator/building_test.py` (`test_init_direct_attributes` and `test_init_direct_attributes_post_refactor`) to use `DeprecatedBuildingFactory` and `FloorPlanBasedBuildingFactory`.
- Added `smart_control/utils/factory_utils_test.py` with examples demonstrating how to create object variations using the new factories.
- Updated `smart_control/utils/BUILD` to include targets for the new factory utilities and tests.
- Added documentation to `README.md` on how to use and create factories with `factory_boy` in this project.

These changes make it easier to create and manage test data, improving the clarity and maintainability of tests.
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.

1 participant