def test_check_energy_system_can_fulfill_max_demand_sufficient_non_dispatchable_production( caplog, ): dict_values_v7 = deepcopy(dict_values_fulfill_demand) dict_values_v7[ENERGY_PRODUCTION][production].update( {MAXIMUM_CAP: { VALUE: 200 }}) dict_values_v7[ENERGY_PRODUCTION][production].update( {OPTIMIZE_CAP: { VALUE: True }}) dict_values_v7[ENERGY_PRODUCTION][production].update( {TIMESERIES_PEAK: { VALUE: 0.5 }}) with caplog.at_level(logging.DEBUG): peak_generation, peak_demand = C1.check_energy_system_can_fulfill_max_demand( dict_values_v7) assert ( peak_generation == 100 ), f"The peak generation should have been 100 but is {peak_generation}" assert (peak_demand == 100 ), f"The peak demand should have been 100 but is {peak_demand}" assert ( "The check for assets having sufficient capacities to fulfill the maximum demand has successfully passed" in caplog.text ), f"As the maximum/installed capacities of the assets in an energy system are sufficient, a successful debug message should have be logged. This did not happen, with peak generation of {peak_generation} and peak demand of {peak_demand}."
def test_check_energy_system_can_fulfill_max_demand_with_storage(caplog): dict_values_v4 = deepcopy(dict_values_fulfill_demand) dict_values_v4[ENERGY_CONVERSION][generator].update( {INSTALLED_CAP: { VALUE: 80 }}) dict_values_v4[ENERGY_STORAGE][storage].update( {OPTIMIZE_CAP: { VALUE: True }}) with caplog.at_level(logging.DEBUG): C1.check_energy_system_can_fulfill_max_demand(dict_values_v4) assert ( "this check does not determine if the storage can be sufficiently" in caplog.text ), f"If a storage asset is included in the energy system, a successful debug message should have been logged."
def test_check_energy_system_can_fulfill_max_demand_no_maximum_capacity( caplog): dict_values_v2 = deepcopy(dict_values_fulfill_demand) dict_values_v2[ENERGY_CONVERSION][generator].update( {MAXIMUM_CAP: { VALUE: None }}) dict_values_v2[ENERGY_CONVERSION][generator].update( {OPTIMIZE_CAP: { VALUE: True }}) with caplog.at_level(logging.DEBUG): C1.check_energy_system_can_fulfill_max_demand(dict_values_v2) assert ( "The check for assets having sufficient capacities to fulfill the maximum demand has successfully passed" in caplog.text ), f"If the maximum capacity of an optimizable asset is set to None, a successful debug message should have been logged."
def test_check_energy_system_can_fulfill_max_demand_insufficient_capacities( caplog): dict_values_v3 = deepcopy(dict_values_fulfill_demand) dict_values_v3[ENERGY_CONVERSION][generator].update( {MAXIMUM_CAP: { VALUE: 90 }}) dict_values_v3[ENERGY_CONVERSION][generator].update( {OPTIMIZE_CAP: { VALUE: True }}) with caplog.at_level(logging.WARNING): peak_generation, peak_demand = C1.check_energy_system_can_fulfill_max_demand( dict_values_v3) assert ( "might have insufficient capacities" in caplog.text ), f"If the maximum/installed capacities of the assets in an energy system are insufficient, a warning message should have been logged. This did not happen, with peak generation of {peak_generation} and peak demand of {peak_demand}."
def test_check_energy_system_can_fulfill_max_demand_insufficient_non_dispatchable_production( caplog, ): dict_values_v8 = deepcopy(dict_values_fulfill_demand) dict_values_v8[ENERGY_PRODUCTION][production].update( {MAXIMUM_CAP: { VALUE: 100 }}) dict_values_v8[ENERGY_PRODUCTION][production].update( {OPTIMIZE_CAP: { VALUE: True }}) dict_values_v8[ENERGY_PRODUCTION][production].update( {TIMESERIES_PEAK: { VALUE: 0.5 }}) with caplog.at_level(logging.WARNING): peak_generation, peak_demand = C1.check_energy_system_can_fulfill_max_demand( dict_values_v8) assert ( "might have insufficient capacities" in caplog.text ), f"If the maximum/installed capacities of the assets in an energy system are insufficient, a warning message should have been logged. This did not happen, with peak generation of {peak_generation} and peak demand of {peak_demand}."