Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
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
Exemple #4
0
 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)
Exemple #5
0
 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)