def test_loading_config_with_valid_measure_year(self): """Test that configuration correctly initialises when a valid measure year is set.""" base_params = TestConfig.get_config_params_with_necessary_attributes_for_reloading( ) test_params = { 'calculation': { 'measures_year': '1234' }, 'assets': { 'qpp_single_source_json': { '1234': 'test' } } } params = dict_utils.nested_update(base_params, test_params) with mock.patch('builtins.open', mock.mock_open(read_data=json.dumps(params))): config.reload_config('test_path')
def test_loading_config_with_invalid_measure_year(self): """ Test that configuration throws an exception when the measure year is invalid due to a path to the measure definitions for that year not being defined. """ base_params = TestConfig.get_config_params_with_necessary_attributes_for_reloading( ) test_params = { 'calculation': { 'measures_year': '1234' }, 'assets': { 'qpp_single_source_json': { 'abcd': 'test' } } } params = dict_utils.nested_update(base_params, test_params) with pytest.raises(InvalidConfigurationException): with mock.patch('builtins.open', mock.mock_open(read_data=json.dumps(params))): config.reload_config('test_path')
def teardown_class(cls): # Reload default config for the other tests. config.reload_config()