Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_bad_meter_input(monkeypatch_temperature_data):
meter = EnergyEfficiencyMeter()
results = meter.evaluate({})
assert results['status'] == 'FAILURE'
assert results['failure_message'].startswith("Meter input")
def test_ignore_extra_args_daily(
meter_input_daily_elec,
monkeypatch_temperature_data):
meter = EnergyEfficiencyMeter()
results = meter.evaluate(meter_input_daily_elec,
model=(None, {'fit_cdd': True, 'grid_search': True, 'extra_arg': 'value'}),
formatter=None)
assert results['meter_kwargs'] == {}
assert results['model_class'] == 'CaltrackDailyModel'
assert results['model_kwargs'] == {'fit_cdd': True, 'grid_search': True, 'extra_arg': 'value'}
def test_basic_usage_daily_supplied_weather_source(
meter_input_daily, monkeypatch_temperature_data,
mock_isd_weather_source):
meter = EnergyEfficiencyMeter()
results = meter.evaluate(meter_input_daily,
weather_source=mock_isd_weather_source)
assert results['status'] == 'SUCCESS'
assert results['failure_message'] is None
assert len(results['logs']) == 2
assert results['eemeter_version'] is not None
assert results['project_id'] == 'PROJECT_1'
assert results['trace_id'] == 'TRACE_1'
assert results['interval'] == 'daily'
assert results['meter_kwargs'] == {}
assert results['model_class'] == 'CaltrackDailyModel'
def test_custom_evaluate_args_monthly(
meter_input_monthly,
monkeypatch_temperature_data):
meter = EnergyEfficiencyMeter()
results = meter.evaluate(meter_input_monthly,
model=None,
formatter=None)
assert results['meter_kwargs'] == {}
assert results['model_class'] == 'CaltrackMonthlyModel'
assert results['model_kwargs'] == {'fit_cdd': True, 'grid_search': True}
assert results['formatter_class'] == 'ModelDataBillingFormatter'
assert results['formatter_kwargs'] == {}
results = meter.evaluate(meter_input_monthly,
model=(None, None),
formatter=(None, None))
assert results['meter_kwargs'] == {}
def test_basic_usage_baseline_only(
meter_input_daily_baseline_only,
monkeypatch_temperature_data):
meter = EnergyEfficiencyMeter()
results = meter.evaluate(meter_input_daily_baseline_only)
assert results['status'] == 'SUCCESS'
assert results['failure_message'] is None
assert len(results['logs']) == 2
assert results['eemeter_version'] is not None
assert results['meter_kwargs'] == {}
assert results['model_class'] == 'CaltrackDailyModel'
assert results['model_kwargs'] is not None
assert results['formatter_class'] == 'ModelDataFormatter'
assert results['formatter_kwargs'] is not None
assert results['modeled_energy_trace'] is not None
def test_basic_usage_hourly(
meter_input_hourly, monkeypatch_temperature_data):
meter = EnergyEfficiencyMeter()
results = meter.evaluate(meter_input_hourly)
assert results['status'] == 'SUCCESS'
assert results['failure_message'] is None
assert len(results['logs']) == 2
assert results['eemeter_version'] is not None
assert results['project_id'] == 'PROJECT_1'
assert results['trace_id'] == 'TRACE_1'
assert results['interval'] == 'hourly'
assert results['meter_kwargs'] == {}
assert results['model_class'] == 'CaltrackDailyModel'
assert results['model_kwargs'] is not None
def test_ignore_extra_args_monthly(
meter_input_monthly,
monkeypatch_temperature_data):
meter = EnergyEfficiencyMeter()
results = meter.evaluate(meter_input_monthly,
model=(None, {'grid_search': True, 'extra_arg': 'value'}),
formatter=None)
assert results['meter_kwargs'] == {}
assert results['model_class'] == 'CaltrackMonthlyModel'
assert results['model_kwargs'] == {'fit_cdd': True, 'grid_search': True, 'extra_arg': 'value'}
def test_basic_usage_daily_period_start_end(
meter_input_daily_with_period_start_end,
monkeypatch_temperature_data):
meter = EnergyEfficiencyMeter()
results = meter.evaluate(meter_input_daily_with_period_start_end)
assert results['status'] == 'SUCCESS'
assert results['failure_message'] is None
assert len(results['logs']) == 2
assert results['eemeter_version'] is not None
assert results['project_id'] == 'PROJECT_1'
assert results['trace_id'] == 'TRACE_1'
assert results['interval'] == 'daily'
assert results['meter_kwargs'] == {}
assert results['model_class'] == 'CaltrackDailyModel'
assert results['model_kwargs'] is not None
def test_basic_usage_daily(
meter_input_daily, monkeypatch_temperature_data):
meter = EnergyEfficiencyMeter()
results = meter.evaluate(meter_input_daily)
assert results['status'] == 'SUCCESS'
assert results['failure_message'] is None
assert len(results['logs']) == 2
assert results['eemeter_version'] is not None
assert results['project_id'] == 'PROJECT_1'
assert results['trace_id'] == 'TRACE_1'
assert results['interval'] == 'daily'
assert results['meter_kwargs'] == {}
assert results['model_class'] == 'CaltrackDailyModel'
assert results['model_kwargs'] is not None
def test_meter_settings_cz2010(meter_input_daily):
meter = EnergyEfficiencyMeter(
weather_station_mapping='CZ2010',
weather_normal_station_mapping='CZ2010'
)
assert meter.weather_station_mapping == 'CZ2010'
assert meter.weather_normal_station_mapping == 'CZ2010'
results = meter.evaluate(meter_input_daily)
assert results['logs'][0] == 'Using weather_source ISDWeatherSource("722880")'
assert results['logs'][1] == 'Using weather_normal_source CZ2010WeatherSource("722880")'
assert results['status'] == 'SUCCESS'
assert results['meter_kwargs'] == {
'weather_station_mapping': 'CZ2010',
'weather_normal_station_mapping': 'CZ2010'
}