Vivarium Testing Utilities

Utility functions and classes to make testing vivarium components easier.

class vivarium.testing_utilities.NonCRNTestPopulation[source]
CONFIGURATION_DEFAULTS: Dict[str, Any] = {'population': {'initialization_age_max': 100, 'initialization_age_min': 0, 'untracking_age': None}}

A dictionary containing the defaults for any configurations managed by this component. An empty dictionary indicates no managed configurations.

property columns_created: List[str]

Provides names of columns created by the component.

Returns:

Names of the columns created by this component, or an empty list if none.

Return type:

List[str]

setup(builder)[source]

Defines custom actions this component needs to run during the setup lifecycle phase.

This method is intended to be overridden by subclasses to perform any necessary setup operations specific to the component. By default, it does nothing.

Parameters:

builder (Builder) – The builder object used to set up the component.

Return type:

None

on_initialize_simulants(pop_data)[source]

Method that vivarium will run during simulant initialization.

This method is intended to be overridden by subclasses if there are operations they need to perform specifically during the simulant initialization phase.

Parameters:

pop_data (SimulantData) – The data associated with the simulants being initialized.

Return type:

None

on_time_step(event)[source]

Method that vivarium will run during the time_step event.

This method is intended to be overridden by subclasses if there are operations they need to perform specifically during the time_step event.

Parameters:

event (Event) – The event object associated with the time_step event.

Return type:

None

class vivarium.testing_utilities.TestPopulation[source]
setup(builder)[source]

Defines custom actions this component needs to run during the setup lifecycle phase.

This method is intended to be overridden by subclasses to perform any necessary setup operations specific to the component. By default, it does nothing.

Parameters:

builder (Builder) – The builder object used to set up the component.

Return type:

None

on_initialize_simulants(pop_data)[source]

Method that vivarium will run during simulant initialization.

This method is intended to be overridden by subclasses if there are operations they need to perform specifically during the simulant initialization phase.

Parameters:

pop_data (SimulantData) – The data associated with the simulants being initialized.

Return type:

None

vivarium.testing_utilities.build_table(value, year_start, year_end, columns=('age', 'year', 'sex', 'value'))[source]
vivarium.testing_utilities.make_dummy_column(name, initial_value)[source]
vivarium.testing_utilities.get_randomness(key='test', clock=<function <lambda>>, seed=12345, initializes_crn_attributes=False)[source]
vivarium.testing_utilities.reset_mocks(mocks)[source]
vivarium.testing_utilities.metadata(file_path, layer='override')[source]