Commit f51fa7dd authored by Cecilia Nievas's avatar Cecilia Nievas
Browse files

Added tests for new parameters of Configuration

parent b419ecd1
Pipeline #28960 passed with stage
in 2 minutes and 23 seconds
model_name: esrm20
exposure_format: esrm20
data_pathname: /some/path/to/directory
boundaries_pathname: /some/path/to/directory
occupancies_to_run: residential, commercial, industrial
exposure_entities_to_run: all
exposure_entities_code:
Name 1: NM1
Name 2: XXX
number_cores: 4
database_built_up:
host: host.somewhere.xx
dbname: some_database_name
username: some_username
password: some_password
database_gde_tiles:
host: host.somewhere.xx
dbname: some_database_name
username: some_username
password: some_password
model_name: esrm20
exposure_format: esrm20
data_pathname: /some/path/to/directory
boundaries_pathname: /some/path/to/directory
occupancies_to_run: residential, commercial, industrial
exposure_entities_to_run: all
exposure_entities_code:
Name 1:
Something 1: XXX
Something 2: XXX
Name 2: XXX
number_cores: 4
database_built_up:
host: host.somewhere.xx
dbname: some_database_name
username: some_username
password: some_password
database_gde_tiles:
host: host.somewhere.xx
dbname: some_database_name
username: some_username
password: some_password
model_name: esrm20
exposure_format: esrm20
data_pathname: /some/path/to/directory
boundaries_pathname: /some/path/to/directory
occupancies_to_run: residential, commercial, industrial
exposure_entities_to_run: all
exposure_entities_code:
Name 1: LONGERSTRING
Name 2: XXX
number_cores: 4
database_built_up:
host: host.somewhere.xx
dbname: some_database_name
username: some_username
password: some_password
database_gde_tiles:
host: host.somewhere.xx
dbname: some_database_name
username: some_username
password: some_password
model_name: esrm20
exposure_format: esrm20
data_pathname: /some/path/to/directory
boundaries_pathname: /some/path/to/directory
occupancies_to_run: residential, commercial, industrial
exposure_entities_to_run: all
exposure_entities_code: WRONG
number_cores: 4
database_built_up:
host: host.somewhere.xx
dbname: some_database_name
username: some_username
password: some_password
database_gde_tiles:
host: host.somewhere.xx
dbname: some_database_name
username: some_username
password: some_password
......@@ -183,3 +183,56 @@ def test_Configuration():
)
assert returned_database_built_up is None
# Test case in which exposure_entities_code is a dictionary
returned_config = Configuration(
os.path.join(
os.path.dirname(__file__),
"data",
"config_for_testing_exposure_entities_code_dict.yml",
),
force_config_over_hierarchies=True,
)
expected_exposure_entities_code = {
"Name 1": "NM1",
"Name 2": "XXX",
}
assert returned_config.exposure_entities_code == expected_exposure_entities_code
# Test case in which exposure_entities_code is a string different from ISO3
with pytest.raises(OSError) as excinfo:
returned_config = Configuration(
os.path.join(
os.path.dirname(__file__),
"data",
"config_for_testing_exposure_entities_code_wrong_string.yml",
),
force_config_over_hierarchies=True,
)
assert "OSError" in str(excinfo.type)
# Test case in which exposure_entities_code is a dictionary with wrong length strings
with pytest.raises(OSError) as excinfo:
returned_config = Configuration(
os.path.join(
os.path.dirname(__file__),
"data",
"config_for_testing_exposure_entities_code_wrong_dict.yml",
),
force_config_over_hierarchies=True,
)
assert "OSError" in str(excinfo.type)
# Test case in which exposure_entities_code is a dictionary with dictionaries
with pytest.raises(OSError) as excinfo:
returned_config = Configuration(
os.path.join(
os.path.dirname(__file__),
"data",
"config_for_testing_exposure_entities_code_dict_dict.yml",
),
force_config_over_hierarchies=True,
)
assert "OSError" in str(excinfo.type)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment