def guess_code(props): code = None if props.get("adm0_a3_is") == "SJM": return "XR" for name in PROPERTIES: if props.get(name) in REGION_CODE_MAP: code = REGION_CODE_MAP.get(props[name]) break elif props.get(name) in REGION_CODES: code = genc.region_by_alpha3(props[name]).alpha2 break return code
def guess_code(props): code = None if props.get('adm0_a3_is') == 'SJM': return 'XR' for name in PROPERTIES: if props.get(name) in REGION_CODE_MAP: code = REGION_CODE_MAP.get(props[name]) break elif props.get(name) in REGION_CODES: code = genc.region_by_alpha3(props[name]).alpha2 break return code
def test_api_alpha3(): assert genc.region_by_alpha3('DEU').name == 'Germany' assert genc.region_by_alpha3('dEu').name == 'Germany' assert genc.region_by_alpha3('None') is None assert genc.region_by_alpha3('None', 1) == 1
def test_alpha3(self): self.assertEqual(genc.region_by_alpha3('DEU').name, 'Germany') self.assertEqual(genc.region_by_alpha3('dEu').name, 'Germany') self.assertEqual(genc.region_by_alpha3('None'), None) self.assertEqual(genc.region_by_alpha3('None', 1), 1)