コード例 #1
0
 def test_no_country_in_lookup(self):
     test_location = {
         'site_no': '12345678',
         'country_cd': 'MX',
         'state_cd': '10',
         'county_cd': '004'
     }
     expected_location = {
         'site_no': {
             'name': '12345678',
             'code': '12345678'
         },
         'country_cd': {
             'name': 'MX',
             'code': 'MX'
         },
         'state_cd': {
             'name': '10',
             'abbreviation': None,
             'code': '10'
         },
         'county_cd': {
             'name': '004',
             'code': '004'
         }
     }
     self.assertEqual(
         get_disambiguated_values(test_location, self.test_code_lookups,
                                  self.test_country_state_county_lookup,
                                  {}), expected_location)
コード例 #2
0
 def test_missing_county(self):
     test_location = {
         'site_no': '12345678',
         'country_cd': 'US',
         'state_cd': '01',
     }
     expected_location = {
         'site_no': {
             'name': '12345678',
             'code': '12345678'
         },
         'country_cd': {
             'name': 'US',
             'code': 'US'
         },
         'state_cd': {
             'name': 'Alabama',
             'abbreviation': 'AL',
             'code': '01'
         },
     }
     self.assertEqual(
         get_disambiguated_values(test_location, self.test_code_lookups,
                                  self.test_country_state_county_lookup,
                                  {}), expected_location)
コード例 #3
0
 def test_huc8_missing(self):
     with app.test_request_context():
         test_location = {'huc_cd': '01010002'}
         expected_location = {
             'huc_cd': {
                 'name': None,
                 'code': '01010002',
                 'url': '/hydrological-unit/01010002/'
             }
         }
         self.assertEqual(
             get_disambiguated_values(test_location, {}, {},
                                      self.test_huc_lookup),
             expected_location)
コード例 #4
0
 def test_huc2(self):
     with app.test_request_context():
         test_location = {'huc_cd': '01'}
         expected_location = {
             'huc_cd': {
                 'name': 'New England Region',
                 'code': '01',
                 'url': '/hydrological-unit/01/'
             }
         }
         self.assertEqual(
             get_disambiguated_values(test_location, {}, {},
                                      self.test_huc_lookup),
             expected_location)
コード例 #5
0
 def test_location_with_no_keys_in_lookups(self):
     test_location = {
         'station_name': 'This is a name',
         'site_no': '12345678'
     }
     expected_location = {
         'station_name': {
             'name': 'This is a name',
             'code': 'This is a name'
         },
         'site_no': {
             'name': '12345678',
             'code': '12345678'
         }
     }
     self.assertEqual(
         get_disambiguated_values(test_location, self.test_code_lookups,
                                  self.test_country_state_county_lookup,
                                  {}), expected_location)
コード例 #6
0
 def test_missing_country(self):
     test_location = {
         'site_no': '12345678',
         'state_cd': '10',
         'county_cd': '004'
     }
     expected_location = {
         'site_no': {
             'name': '12345678',
             'code': '12345678'
         },
         'state_cd': {
             'name': '10',
             'code': '10'
         },
         'county_cd': {
             'name': '004',
             'code': '004'
         }
     }
     self.assertEqual(
         get_disambiguated_values(test_location, self.test_code_lookups,
                                  self.test_country_state_county_lookup,
                                  {}), expected_location)
コード例 #7
0
 def test_state_county_in_state_county_lookup(self):
     test_location = {
         'site_no': '12345678',
         'country_cd': 'US',
         'state_cd': '01',
         'district_cd': '02',
         'county_cd': '002'
     }
     expected_location = {
         'site_no': {
             'name': '12345678',
             'code': '12345678'
         },
         'country_cd': {
             'name': 'US',
             'code': 'US'
         },
         'state_cd': {
             'name': 'Alabama',
             'abbreviation': 'AL',
             'code': '01'
         },
         'district_cd': {
             'name': 'Alaska',
             'abbreviation': 'AK',
             'code': '02'
         },
         'county_cd': {
             'name': 'Baldwin County',
             'code': '002'
         }
     }
     self.assertEqual(
         get_disambiguated_values(test_location, self.test_code_lookups,
                                  self.test_country_state_county_lookup,
                                  {}), expected_location)
コード例 #8
0
 def test_location_with_key_values_not_in_code_lookups(self):
     test_location = {
         'site_no': '12345678',
         'agency_cd': 'USDA',
         'nat_aqfr_cd': 'N100BSNRGB'
     }
     expected_location = {
         'site_no': {
             'code': '12345678',
             'name': '12345678'
         },
         'agency_cd': {
             'code': 'USDA',
             'name': 'USDA'
         },
         'nat_aqfr_cd': {
             'code': 'N100BSNRGB',
             'name': 'Basin and Range basin-fill aquifers'
         }
     }
     self.assertEqual(
         get_disambiguated_values(test_location, self.test_code_lookups,
                                  self.test_country_state_county_lookup,
                                  {}), expected_location)
コード例 #9
0
 def test_empty_location(self):
     self.assertEqual(
         get_disambiguated_values({}, self.test_code_lookups,
                                  self.test_country_state_county_lookup,
                                  {}), {})