Ejemplo n.º 1
0
 def test_country_name_to_id_en(self):
     data = [
         ("Mongolia", "MN"),
         ("Marocco", "MA"),
         ("Georgia", "GE"),
         ("kosovo", "KO"),
         ("Namibia", "NA"),
         ("Venezuela", "VE"),
         ("Armenia", "AM"),
         ("sweden", "SE"),
         (u"Knotts Island, NC 27950\n\n27950-0039\nUnited States", "US"),
         ("721 APS BLDG 3334\nUNIT 3295 \nRamstein Air Base, Non-U.S. 66877 \nGermany ", "DE"),
         ("Saudi Arabia", "SA"),
         ("Country execution:nigeria.", "NG"),
         ("RUSSIA", "RU"),
         ("PAPUA NEW GUINEA", "PG"),
         ("guinea-bissau", "GW"),
         ("netherlands antilles", "AN"),
         ("netherlands or something", "NL"),
         (u"curaçao", "CW"),
         (u"saint barthélemy", "BL"),
         ("Sudan", "SD"),
         ("South Sudan", "SS"),
         ("tanzania", "TZ"),
         ("united states minor outlying islands", "UM"),
         ("Lorem ipsum Libya - LIBYA", "LY"),
         (" Democratic Republic of the Congo", "CD"),
         ("CONGO, DEM. REPUBLIC", "CD"),
         ("TIMOR LESTE", "TL"),
         ("state of palestine", "PS"),
         ("palestine, state of", "PS"),
     ]
     for test in data:
         self.assertEqual(country_name_to_id(test[0], lang="EN"), test[1])
Ejemplo n.º 2
0
 def test_country_name_to_id_en(self):
     data = [
         ('Mongolia', 'MN'),
         ('Marocco', 'MA'),
         ('Georgia', 'GE'),
         ('kosovo', 'KO'),
         ('Namibia', 'NA'),
         ('Venezuela', 'VE'),
         ('Armenia', 'AM'),
         ('sweden', 'SE'),
         (u"Knotts Island, NC 27950\n\n27950-0039\nUnited States", 'US'),
         ("721 APS BLDG 3334\nUNIT 3295 \nRamstein Air Base, Non-U.S. 66877 \nGermany ", 'DE'),
         ("Saudi Arabia", 'SA'),
         ("Country execution:nigeria.", 'NG'),
         ("RUSSIA", 'RU'),
         ("PAPUA NEW GUINEA", 'PG'),
         ("guinea-bissau", 'GW'),
         ("netherlands antilles", 'AN'),
         ("netherlands or something", 'NL'),
         (u'curaçao', 'CW'),
         (u'saint barthélemy', 'BL'),
         ('Sudan', 'SD'),
         ('South Sudan', 'SS'),
         ('tanzania', 'TZ'),
         ("united states minor outlying islands", 'UM'),
         ("Lorem ipsum Libya - LIBYA", 'LY'),
         (' Democratic Republic of the Congo', 'CD'),
         ('CONGO, DEM. REPUBLIC', 'CD'),
         ('TIMOR LESTE', 'TL'),
         ('state of palestine', 'PS'),
         ('palestine, state of', 'PS')
     ]
     for test in data:
         self.assertEqual(country_name_to_id(test[0], lang='EN'), test[1])
Ejemplo n.º 3
0
 def test_country_name_to_id_fr(self):
     data = [
         ("france", "FR"),
         ("Comores", "KM"),
         ("Madagascar", "MG"),
         (u"S\xe9n\xe9gal", "SN"),
         ("République démocratique du Congo", "CD"),
         ("Mali", "ML"),
         ("Sri Lanka ", "LK"),
         (u"\xa0V\xe9n\xe9zuela\xa0", "VE"),
         (u"Vi\xeatnam", "VN"),
         ("Nigeria", "NG"),
         (u"Niger", "NE"),
         (u"aaa ( bbb", None),
         (u" Le  nigéria c'est trop   sympa", "NG"),
         (u"Pays d'exécution : Niger", "NE"),
         ("  Côte d'Ivoire ", "CI"),
         ("  Côte d’Ivoire ", "CI"),  # with accent for apostrophe
         ("U.S. Mission Iraq\n\nIraq", "IQ"),
         ("Pays:France ?".encode("ascii", "ignore"), "FR"),
         (",royaume-uni,", "GB"),
         (u"trinité-et-Tobago", "TT"),
         ("surinam", "SR"),
         (u"saint-barthélemy", "BL"),
         (u"saint-barthélemy", "BL"),
         ("sint maarten", "SX"),
         (u"curaçao", "CW"),
         ("andorre", "AD"),
         ("bonaire, saint-eustache et saba", "BQ"),
         ("soudan", "SD"),
         ("soudan du sud", "SS"),
         ("PAYS-BRÉSIL", "BR"),
         (u"Lorem ipsum Libye - LIBYE", "LY"),
         ("palestine", "PS"),
     ]
     for test in data:
         self.assertEqual(country_name_to_id(test[0]), test[1])
Ejemplo n.º 4
0
 def test_country_name_to_id_fr(self):
     data = [
         ('france', 'FR'),
         ('Comores', 'KM'),
         ('Madagascar', 'MG'),
         (u'S\xe9n\xe9gal', 'SN'),
         ('République démocratique du Congo', 'CD'),
         ('Mali', 'ML'),
         ('Sri Lanka ', 'LK'),
         (u'\xa0V\xe9n\xe9zuela\xa0', 'VE'),
         (u'Vi\xeatnam', 'VN'),
         ('Nigeria', 'NG'),
         (u'Niger', 'NE'),
         (u'aaa ( bbb', None),
         (u" Le  nigéria c'est trop   sympa", 'NG'),
         (u"Pays d'exécution : Niger", 'NE'),
         ("  Côte d'Ivoire ", 'CI'),
         ("  Côte d’Ivoire ", 'CI'),  # with accent for apostrophe
         ("U.S. Mission Iraq\n\nIraq", 'IQ'),
         ("Pays:France ?".encode('ascii', 'ignore'), 'FR'),
         (",royaume-uni,", 'GB'),
         (u"trinité-et-Tobago", 'TT'),
         ("surinam", 'SR'),
         (u"saint-barthélemy", 'BL'),
         (u"saint-barthélemy", 'BL'),
         ('sint maarten', 'SX'),
         (u'curaçao', 'CW'),
         ("andorre", 'AD'),
         ('bonaire, saint-eustache et saba', 'BQ'),
         ('soudan', 'SD'),
         ('soudan du sud', 'SS'),
         ("PAYS-BRÉSIL", 'BR'),
         (u"Lorem ipsum Libye - LIBYE", 'LY'),
         ("palestine", 'PS')
     ]
     for test in data:
         self.assertEqual(country_name_to_id(test[0]), test[1])
Ejemplo n.º 5
0
 def test_country_name_to_country_code_es(self, input_data, expected):
     assert country_name_to_country_code(input_data, lang="ES") == expected
     assert country_name_to_id(input_data, lang="ES") == expected