-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Tier 1: Critical (Catch Configuration & Initialization Errors)
These tests would have caught every error you've encountered so far. They focus on object creation and ensuring all required configuration is present.
simulation/scenario_loader.py
Why: This is your #1 priority. The ScenarioLoader is the first class to deeply interact with the config object to create agents and components.
What to test:
Write a test that creates an EmergenceScenarioLoader instance.
In that test, call the .load() method using a mock simulation_state.
This will immediately throw errors if the loader tries to access parts of the config schema that don't exist (like agent.foundational or scenario_path).
config/schemas.py
Why: To ensure your emergence_config.yml can be successfully loaded and validated by your Pydantic models.
What to test:
Write a test that loads your actual emergence_config.yml file into a dictionary.
Attempt to create an EmergenceSimAppConfig instance from that dictionary.
This test will fail instantly if there are any mismatches between the YAML structure and your Pydantic models.
run.py (specifically the setup_and_run function)
Why: To test the dependency injection and initialization of the entire simulation stack.
What to test:
Write a test that calls setup_and_run but uses mocker (from pytest-mock) to "patch" the final manager.run() call so the simulation loop doesn't actually start.
This tests that the SimulationManager can be created successfully and that all providers and systems can be instantiated with their dependencies without AttributeError or TypeError.
Tier 2: High Priority (Verify Core Logic)
These tests check that your simulation's unique systems behave as expected.
providers/simulation_providers.py
Why: Your EmergenceStateEncoder is critical for the Q-learning system. An incorrect feature vector shape will crash the simulation during training.
What to test:
Test the encode_state and encode_internal_state methods.
Create mock components, pass them to the encoder, and assert that the output numpy array has the exact shape defined in your config (state_feature_dim, internal_state_dim).
providers/action_providers.py
Why: To prevent mismatches between the inputs expected by your Q-network and the feature vectors produced by your actions.
What to test:
For each action, test its get_feature_vector method and assert the output shape matches action_feature_dim.
Tier 3: Good to Have (System Integrity)
systems/*.py (e.g., social_credit_system.py)
Why: To test the logic of individual systems.
What to test:
For the SocialCreditSystem, create an agent with a SocialCreditComponent, manually call the system's process method, and assert that the agent's credit score changes as expected.
By implementing tests for just Tier 1, you will build a robust defense against the entire class of errors you've been fighting.