예제 #1
0
 def test_validlocations(self, project_config_yaml):
     Country.countriesdata(use_live=False)
     validlocations = [{'name': 'shn', 'title': 'St. Helena'}]
     assert Locations.get_HDX_code_from_location('sh', locations=validlocations) is None
     assert Locations.get_HDX_code_from_location_partial('sh', locations=validlocations) == (None, False)
     assert Locations.get_location_from_HDX_code('shn', locations=validlocations) == 'St. Helena'
     validlocations = [{'name': 'zmb', 'title': 'Zambia'}, {'name': 'pry', 'title': 'Paraguay'}]
     Locations.set_validlocations(validlocations)
     assert Locations.validlocations() == validlocations
     assert Locations.get_HDX_code_from_location_partial('NOT') == (None, False)
     assert Locations.get_location_from_HDX_code('pr') is None
     assert Locations.get_HDX_code_from_location('zmb') == 'ZMB'
     assert Locations.get_HDX_code_from_location_partial('zmb') == ('ZMB', True)
     assert Locations.get_HDX_code_from_location('Z') is None
     assert Locations.get_HDX_code_from_location_partial('Z') == ('ZMB', False)
     assert Locations.get_HDX_code_from_location_partial('Zambia') == ('ZMB', True)
     assert Locations.get_HDX_code_from_location_partial('ZAM') == ('ZMB', False)
     assert Locations.get_location_from_HDX_code('zmb', locations=validlocations) == 'Zambia'
     validlocations = [{'name': 'shn', 'title': 'St. Helena'}]
     assert Locations.get_HDX_code_from_location('sh', locations=validlocations) is None
     assert Locations.get_HDX_code_from_location_partial('sh', locations=validlocations) == (None, False)
     assert Locations.get_location_from_HDX_code('shn', locations=validlocations) == 'St. Helena'
     Configuration.setup(MyConfiguration())
     Locations.set_validlocations(None)
     assert Locations.get_HDX_code_from_location('zaf') == 'ZAF'
     assert Locations.get_HDX_code_from_location_partial('zaf') == ('ZAF', True)
     assert Locations.get_location_from_HDX_code('zaf') == 'South Africa'
 def test_validlocations(self, project_config_yaml):
     Country.countriesdata(use_live=False)
     validlocations = [{'name': 'shn', 'title': 'St. Helena'}]
     assert Locations.get_HDX_code_from_location(
         'sh', locations=validlocations) is None
     assert Locations.get_HDX_code_from_location_partial(
         'sh', locations=validlocations) == (None, False)
     assert Locations.get_location_from_HDX_code(
         'shn', locations=validlocations) == 'St. Helena'
     validlocations = [{
         'name': 'zmb',
         'title': 'Zambia'
     }, {
         'name': 'pry',
         'title': 'Paraguay'
     }]
     Locations.set_validlocations(validlocations)
     assert Locations.validlocations() == validlocations
     assert Locations.get_HDX_code_from_location_partial('NOT') == (None,
                                                                    False)
     assert Locations.get_location_from_HDX_code('pr') is None
     assert Locations.get_HDX_code_from_location('zmb') == 'ZMB'
     assert Locations.get_HDX_code_from_location_partial('zmb') == ('ZMB',
                                                                    True)
     assert Locations.get_HDX_code_from_location('Z') is None
     assert Locations.get_HDX_code_from_location_partial('Z') == ('ZMB',
                                                                  False)
     assert Locations.get_HDX_code_from_location_partial('Zambia') == (
         'ZMB', True)
     assert Locations.get_HDX_code_from_location_partial('ZAM') == ('ZMB',
                                                                    False)
     assert Locations.get_location_from_HDX_code(
         'zmb', locations=validlocations) == 'Zambia'
     validlocations = [{'name': 'shn', 'title': 'St. Helena'}]
     assert Locations.get_HDX_code_from_location(
         'sh', locations=validlocations) is None
     assert Locations.get_HDX_code_from_location_partial(
         'sh', locations=validlocations) == (None, False)
     assert Locations.get_location_from_HDX_code(
         'shn', locations=validlocations) == 'St. Helena'
     Configuration.setup(MyConfiguration())
     Locations.set_validlocations(None)
     assert Locations.get_HDX_code_from_location('zaf') == 'ZAF'
     assert Locations.get_HDX_code_from_location_partial('zaf') == ('ZAF',
                                                                    True)
     assert Locations.get_location_from_HDX_code('zaf') == 'South Africa'
예제 #3
0
 def test_validlocations(self, project_config_yaml):
     validlocations = [{'name': 'shn', 'title': 'St. Helena'}]
     assert Locations.get_HDX_code_from_location(
         'sh', exact=False, locations=validlocations) == (None, False)
     assert Locations.get_location_from_HDX_code(
         'shn', locations=validlocations) == 'St. Helena'
     validlocations = [{
         'name': 'zmb',
         'title': 'Zambia'
     }, {
         'name': 'pry',
         'title': 'Paraguay'
     }]
     Locations.set_validlocations(validlocations)
     assert Locations.validlocations() == validlocations
     assert Locations.get_HDX_code_from_location('NOT') == (None, False)
     assert Locations.get_location_from_HDX_code('pr') is None
     assert Locations.get_HDX_code_from_location('zmb') == ('zmb', True)
     assert Locations.get_HDX_code_from_location('Z') == (None, False)
     assert Locations.get_HDX_code_from_location('Z',
                                                 exact=False) == ('zmb',
                                                                  False)
     assert Locations.get_HDX_code_from_location('Zambia') == ('zmb', True)
     assert Locations.get_HDX_code_from_location('ZAM',
                                                 exact=False) == ('zmb',
                                                                  False)
     assert Locations.get_location_from_HDX_code(
         'zmb', locations=validlocations) == 'Zambia'
     validlocations = [{'name': 'shn', 'title': 'St. Helena'}]
     assert Locations.get_HDX_code_from_location(
         'sh', exact=False, locations=validlocations) == (None, False)
     assert Locations.get_location_from_HDX_code(
         'shn', locations=validlocations) == 'St. Helena'
     Configuration.setup(MyConfiguration())
     Locations.set_validlocations(None)
     assert Locations.get_HDX_code_from_location('zaf') == ('zaf', True)
     assert Locations.get_location_from_HDX_code('zaf') == 'South Africa'