simplify and test #185
GitHub Actions / Test Results
failed
Jun 27, 2024 in 0s
3 fail, 26 pass in 7m 37s
Annotations
Check warning on line 0 in tests.hdx.location.test_adminlevel.TestAdminLevel
github-actions / Test Results
test_adminlevel (tests.hdx.location.test_adminlevel.TestAdminLevel) failed
test-results.xml [took 0s]
Raw output
AssertionError: assert ('YE24', False) == ('YE30', False)
At index 0 diff: #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mYE24#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m != #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mYE30#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
Full diff:
#x1B[0m#x1B[90m #x1B[39;49;00m (#x1B[90m#x1B[39;49;00m
#x1B[91m- 'YE30',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
? ^^#x1B[90m#x1B[39;49;00m
#x1B[92m+ 'YE24',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
? ^^#x1B[90m#x1B[39;49;00m
#x1B[90m #x1B[39;49;00m False,#x1B[90m#x1B[39;49;00m
#x1B[90m #x1B[39;49;00m )#x1B[90m#x1B[39;49;00m
self = <location.test_adminlevel.TestAdminLevel object at 0x7fcebd5c7bf0>
config = {'admin_info': [{'pcode': 'AF01', 'name': 'Kabul', 'iso3': 'AFG'}, {'pcode': 'AF02', 'name': 'Kapisa', 'iso3': 'AFG'},...': 'Paghman', 'iso3': 'AFG', 'parent': 'AF01'}, {'pcode': 'AF0201', 'name': 'Kabul', 'iso3': 'AFG', 'parent': 'AF02'}]}
def test_adminlevel(self, config):
adminone = AdminLevel(config)
adminone.setup_from_admin_info(
config["admin_info"], countryiso3s=("yem",)
)
assert len(adminone.get_pcode_list()) == 22
adminone = AdminLevel(config)
adminone.setup_from_admin_info(config["admin_info"])
assert adminone.get_admin_level("YEM") == 1
assert len(adminone.get_pcode_list()) == 433
assert adminone.get_pcode_length("YEM") == 4
assert adminone.use_parent is False
assert adminone.pcode_to_iso3["YE30"] == "YEM"
assert adminone.get_pcode("YEM", "YE30", logname="test") == (
"YE30",
True,
)
assert adminone.get_pcode("YEM", "YEM30", logname="test") == (
"YE30",
True,
)
assert adminone.get_pcode("YEM", "YEM030", logname="test") == (
"YE30",
True,
)
assert adminone.get_pcode("NGA", "NG015", logname="test") == (
"NG015",
True,
)
assert adminone.get_pcode("NGA", "NG15", logname="test") == (
"NG015",
True,
)
assert adminone.get_pcode("NGA", "NGA015", logname="test") == (
"NG015",
True,
)
assert adminone.get_pcode("NER", "NER004", logname="test") == (
"NER004",
True,
)
assert adminone.get_pcode("NER", "NE04", logname="test") == (
"NER004",
True,
)
assert adminone.get_pcode("NER", "NE004", logname="test") == (
"NER004",
True,
)
assert adminone.get_pcode("ABC", "NE004", logname="test") == (
None,
True,
)
assert adminone.get_pcode("ABC", "BLAH", logname="test") == (
None,
False,
)
config["countries_fuzzy_try"].append("ABC")
assert adminone.get_pcode("ABC", "NE004", logname="test") == (
None,
True,
)
assert adminone.get_pcode("ABC", "BLAH", logname="test") == (
None,
False,
)
assert adminone.get_pcode("XYZ", "XYZ123", logname="test") == (
None,
True,
)
assert adminone.get_pcode("XYZ", "BLAH", logname="test") == (
None,
False,
)
assert adminone.get_pcode("NER", "ABCDEFGH", logname="test") == (
None,
False,
)
assert adminone.get_pcode("YEM", "Ad Dali", logname="test") == (
"YE30",
True,
)
> assert adminone.get_pcode("YEM", "Ad Dal", logname="test") == (
"YE30",
False,
)
E AssertionError: assert ('YE24', False) == ('YE30', False)
E
E At index 0 diff: #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mYE24#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m != #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mYE30#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
E
E Full diff:
E #x1B[0m#x1B[90m #x1B[39;49;00m (#x1B[90m#x1B[39;49;00m
E #x1B[91m- 'YE30',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
E ? ^^#x1B[90m#x1B[39;49;00m
E #x1B[92m+ 'YE24',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
E ? ^^#x1B[90m#x1B[39;49;00m
E #x1B[90m #x1B[39;49;00m False,#x1B[90m#x1B[39;49;00m
E #x1B[90m #x1B[39;49;00m )#x1B[90m#x1B[39;49;00m
tests/hdx/location/test_adminlevel.py:111: AssertionError
Check warning on line 0 in tests.hdx.location.test_adminlevel.TestAdminLevel
github-actions / Test Results
test_adminlevel_with_url (tests.hdx.location.test_adminlevel.TestAdminLevel) failed
test-results.xml [took 6m 20s]
Raw output
AssertionError: assert ('YE24', False) == ('YE30', False)
At index 0 diff: #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mYE24#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m != #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mYE30#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
Full diff:
#x1B[0m#x1B[90m #x1B[39;49;00m (#x1B[90m#x1B[39;49;00m
#x1B[91m- 'YE30',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
? ^^#x1B[90m#x1B[39;49;00m
#x1B[92m+ 'YE24',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
? ^^#x1B[90m#x1B[39;49;00m
#x1B[90m #x1B[39;49;00m False,#x1B[90m#x1B[39;49;00m
#x1B[90m #x1B[39;49;00m )#x1B[90m#x1B[39;49;00m
self = <location.test_adminlevel.TestAdminLevel object at 0x7fcebd0cf1a0>
config = {'admin_info': [{'pcode': 'AF01', 'name': 'Kabul', 'iso3': 'AFG'}, {'pcode': 'AF02', 'name': 'Kapisa', 'iso3': 'AFG'},...': 'Paghman', 'iso3': 'AFG', 'parent': 'AF01'}, {'pcode': 'AF0201', 'name': 'Kabul', 'iso3': 'AFG', 'parent': 'AF02'}]}
url = 'https://raw.githubusercontent.com/OCHA-DAP/hdx-python-country/main/tests/fixtures/global_pcodes_adm_1_2.csv'
def test_adminlevel_with_url(self, config, url):
adminone = AdminLevel(config)
with pytest.raises(HXLIOException):
adminone.setup_from_url("fake_url")
AdminLevel.set_default_admin_url()
assert AdminLevel._admin_url == AdminLevel._admin_url_default
AdminLevel.set_default_admin_url(url)
assert AdminLevel._admin_url == url
adminone.setup_from_url(countryiso3s=("YEM",))
assert len(adminone.get_pcode_list()) == 22
adminone = AdminLevel(config)
adminone.setup_from_url()
assert adminone.get_admin_level("YEM") == 1
assert len(adminone.get_pcode_list()) == 2509
assert adminone.get_pcode_length("YEM") == 4
assert adminone.get_pcode("YEM", "YE30", logname="test") == (
"YE30",
True,
)
assert adminone.get_pcode(
"YEM", "YE30", parent="YEM", logname="test"
) == (
"YE30",
True,
)
# Exact match of p-code so doesn't need parent
assert adminone.get_pcode(
"YEM", "YE30", parent="Blah1", logname="test"
) == (
"YE30",
True,
)
assert adminone.get_pcode("YEM", "YEM30", logname="test") == (
"YE30",
True,
)
assert adminone.get_pcode("YEM", "YEM030", logname="test") == (
"YE30",
True,
)
assert adminone.get_pcode("NGA", "NG015", logname="test") == (
"NG015",
True,
)
assert adminone.get_pcode("NGA", "NG15", logname="test") == (
"NG015",
True,
)
assert adminone.get_pcode("NGA", "NGA015", logname="test") == (
"NG015",
True,
)
assert adminone.get_pcode("NER", "NER004", logname="test") == (
"NE004",
True,
)
assert adminone.get_pcode("NER", "NE04", logname="test") == (
"NE004",
True,
)
assert adminone.get_pcode("NER", "NE004", logname="test") == (
"NE004",
True,
)
assert adminone.get_pcode("ABC", "NE004", logname="test") == (
"NE004",
True,
)
assert adminone.get_pcode("ABC", "NER004", logname="test") == (
None,
True,
)
assert adminone.get_pcode("ABC", "BLAH", logname="test") == (
None,
False,
)
config["countries_fuzzy_try"].append("ABC")
assert adminone.get_pcode("ABC", "NER004", logname="test") == (
None,
True,
)
assert adminone.get_pcode("ABC", "BLAH", logname="test") == (
None,
False,
)
assert adminone.get_pcode("XYZ", "XYZ123", logname="test") == (
None,
True,
)
assert adminone.get_pcode("XYZ", "BLAH", logname="test") == (
None,
False,
)
assert adminone.get_pcode("NER", "ABCDEFGH", logname="test") == (
None,
False,
)
assert adminone.get_pcode("YEM", "Ad Dali", logname="test") == (
"YE30",
False,
)
> assert adminone.get_pcode("YEM", "Ad Dal", logname="test") == (
"YE30",
False,
)
E AssertionError: assert ('YE24', False) == ('YE30', False)
E
E At index 0 diff: #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mYE24#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m != #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mYE30#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
E
E Full diff:
E #x1B[0m#x1B[90m #x1B[39;49;00m (#x1B[90m#x1B[39;49;00m
E #x1B[91m- 'YE30',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
E ? ^^#x1B[90m#x1B[39;49;00m
E #x1B[92m+ 'YE24',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
E ? ^^#x1B[90m#x1B[39;49;00m
E #x1B[90m #x1B[39;49;00m False,#x1B[90m#x1B[39;49;00m
E #x1B[90m #x1B[39;49;00m )#x1B[90m#x1B[39;49;00m
tests/hdx/location/test_adminlevel.py:462: AssertionError
Check warning on line 0 in tests.hdx.location.test_adminlevel.TestAdminLevel
github-actions / Test Results
test_adminlevel_parent (tests.hdx.location.test_adminlevel.TestAdminLevel) failed
test-results.xml [took 0s]
Raw output
AssertionError: assert (None, False) == ('CD2013', False)
At index 0 diff: #x1B[0m#x1B[94mNone#x1B[39;49;00m#x1B[90m#x1B[39;49;00m != #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mCD2013#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
Full diff:
#x1B[0m#x1B[90m #x1B[39;49;00m (#x1B[90m#x1B[39;49;00m
#x1B[91m- 'CD2013',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
#x1B[92m+ None,#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
#x1B[90m #x1B[39;49;00m False,#x1B[90m#x1B[39;49;00m
#x1B[90m #x1B[39;49;00m )#x1B[90m#x1B[39;49;00m
self = <location.test_adminlevel.TestAdminLevel object at 0x7fcebd0cd8e0>
config_parent = {'admin_info_with_parent': [{'pcode': 'AF0101', 'name': 'Kabul', 'iso3': 'AFG', 'parent': 'AF01'}, {'pcode': 'AF0102',...: {' city': ''}, 'alt1_admin_name_replacements': {'COD| city': ''}, 'alt2_admin_name_replacements': {'CD20| city': ''}}
def test_adminlevel_parent(self, config_parent):
admintwo = AdminLevel(config_parent)
admintwo.countries_fuzzy_try = None
admintwo.setup_from_admin_info(config_parent["admin_info_with_parent"])
assert admintwo.use_parent is True
assert admintwo.pcode_to_parent["AF0101"] == "AF01"
assert admintwo.get_pcode("AFG", "AF0101", logname="test") == (
"AF0101",
True,
)
assert admintwo.get_pcode(
"AFG", "AF0101", parent="blah", logname="test"
) == ("AF0101", True)
assert admintwo.get_pcode("AFG", "Kabul", logname="test") == (
"AF0201",
True,
)
assert admintwo.get_pcode(
"AFG", "Kabul", parent="AF01", logname="test"
) == ("AF0101", True)
assert admintwo.get_pcode(
"AFG", "Kabul", parent="blah", logname="test"
) == (None, False)
assert admintwo.get_pcode(
"AFG", "Kabul", parent="AF02", logname="test"
) == ("AF0201", True)
assert admintwo.get_pcode(
"AFG", "Kabull", parent="AF01", logname="test"
) == ("AF0101", False)
assert admintwo.get_pcode(
"AFG", "Kabull", parent="blah", logname="test"
) == (None, False)
assert admintwo.get_pcode(
"AFG", "Kabull", parent="AF02", logname="test"
) == ("AF0201", False)
assert admintwo.get_pcode(
"ABC", "Kabull", parent="AF02", logname="test"
) == (None, False)
output = admintwo.output_admin_name_mappings()
assert output == [
"MyMapping: Charikar (AF0301)",
"AFG|MyMapping2: Maydan Shahr (AF0401)",
"AF05|MyMapping3: Pul-e-Alam (AF0501)",
]
assert admintwo.get_pcode("AFG", "MyMapping", logname="test") == (
"AF0301",
True,
)
assert admintwo.get_pcode(
"AFG", "MyMapping", parent="AF03", logname="test"
) == ("AF0301", True)
assert admintwo.get_pcode(
"AFG", "MyMapping", parent="AF04", logname="test"
) == (None, False)
assert admintwo.get_pcode("AFG", "MyMapping2", logname="test") == (
"AF0401",
True,
)
assert admintwo.get_pcode(
"AFG", "MyMapping2", parent="AF04", logname="test"
) == ("AF0401", True)
assert admintwo.get_pcode(
"AFG", "MyMapping2", parent="AF05", logname="test"
) == (None, False)
assert admintwo.get_pcode("AFG", "MyMapping3", logname="test") == (
None,
False,
)
assert admintwo.get_pcode(
"AFG", "MyMapping3", parent="AF05", logname="test"
) == ("AF0501", True)
assert admintwo.get_pcode(
"AFG", "MyMapping3", parent="AF04", logname="test"
) == (None, False)
output = admintwo.output_admin_name_replacements()
assert output == [" city: "]
> assert admintwo.get_pcode(
"COD", "Mbanza-Ngungu city", logname="test"
) == ("CD2013", False)
E AssertionError: assert (None, False) == ('CD2013', False)
E
E At index 0 diff: #x1B[0m#x1B[94mNone#x1B[39;49;00m#x1B[90m#x1B[39;49;00m != #x1B[0m#x1B[33m'#x1B[39;49;00m#x1B[33mCD2013#x1B[39;49;00m#x1B[33m'#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
E
E Full diff:
E #x1B[0m#x1B[90m #x1B[39;49;00m (#x1B[90m#x1B[39;49;00m
E #x1B[91m- 'CD2013',#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
E #x1B[92m+ None,#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
E #x1B[90m #x1B[39;49;00m False,#x1B[90m#x1B[39;49;00m
E #x1B[90m #x1B[39;49;00m )#x1B[90m#x1B[39;49;00m
tests/hdx/location/test_adminlevel.py:285: AssertionError
Loading