Draft
Conversation
I introduced factory_boy and refactored several of your test files to use factories, simplifying test data setup and improving maintainability.
Here are the key changes:
- Added `factory_boy` to your project dependencies.
- Created `smart_control/utils/factory_utils.py` with factories for:
- Protobufs: `ActionRequest`, `ObservationRequest`, `ObservationResponse`, `RewardInfo` and their sub-components.
- Custom classes: `SimpleBuilding`, `MaterialProperties`, `Building` (deprecated), `FloorPlanBasedBuilding`.
- Refactored tests in:
- `smart_control/environment/environment_test.py`
- `smart_control/simulator/building_test.py`
- `smart_control/simulator/simulator_building_test_lib.py`
- `smart_control/simulator/tf_simulator_test.py`
- `smart_control/reward/base_setpoint_energy_carbon_reward_test.py`
- `smart_control/reward/setpoint_energy_carbon_regret_test.py`
- Added `smart_control/utils/factory_utils_test.py` with usage examples.
- Updated `smart_control/utils/BUILD` for new files and dependencies.
- Documented factory usage in `README.md`.
This work is part of an ongoing effort to improve test clarity and reduce boilerplate by leveraging factories for test object creation.
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
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 refactored your tests to use factory_boy for test data generation.
I introduced factory_boy and refactored several of your test files to use factories, simplifying test data setup and improving maintainability.
Here are the key changes:
factory_boyto your project dependencies.smart_control/utils/factory_utils.pywith factories for:ActionRequest,ObservationRequest,ObservationResponse,RewardInfoand their sub-components.SimpleBuilding,MaterialProperties,Building(deprecated),FloorPlanBasedBuilding.smart_control/environment/environment_test.pysmart_control/simulator/building_test.pysmart_control/simulator/simulator_building_test_lib.pysmart_control/simulator/tf_simulator_test.pysmart_control/reward/base_setpoint_energy_carbon_reward_test.pysmart_control/reward/setpoint_energy_carbon_regret_test.pysmart_control/utils/factory_utils_test.pywith usage examples.smart_control/utils/BUILDfor new files and dependencies.README.md.This work is part of an ongoing effort to improve test clarity and reduce boilerplate by leveraging factories for test object creation.
Fixes #<issue_number_goes_here>