Commit 6837868b authored by Cecilia Nievas's avatar Cecilia Nievas
Browse files

Added tests for ExposureEntity

parent f51fa7dd
Pipeline #28964 passed with stage
in 1 minute and 56 seconds
......@@ -241,7 +241,7 @@ class ExposureEntity:
entity is a country, or a code that the user defines in the configuration file.
"""
if config_code.upper() == "ISO3":
if isinstance(config_code, str) and config_code.upper() == "ISO3":
exposure_entity_code = self.retrieve_country_ISO3(self.name)
else:
exposure_entity_code = config_code[self.name]
......
#!/usr/bin/env python3
# Copyright (C) 2021:
# Helmholtz-Zentrum Potsdam Deutsches GeoForschungsZentrum GFZ
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
import logging
from gdeimporter.exposureentity import ExposureEntity
logger = logging.getLogger()
def test_ExposureEntity_retrieve_country_ISO3():
assert ExposureEntity.retrieve_country_ISO3("Greece") == "GRC"
assert ExposureEntity.retrieve_country_ISO3("United_Kingdom") == "GBR"
assert ExposureEntity.retrieve_country_ISO3("Moldova") == "MDA"
assert ExposureEntity.retrieve_country_ISO3("Not_a_Country") is None
returned_exposureentity = ExposureEntity("Greece", "ISO3")
assert returned_exposureentity.name == "Greece"
assert returned_exposureentity.code == "GRC"
returned_exposureentity = ExposureEntity(
"South_America", {"South_America": "SRR", "Africa": "FFF"}
)
assert returned_exposureentity.name == "South_America"
assert returned_exposureentity.code == "SRR"
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