Exemplo n.º 1
0
 def test_with_nonsite_transactions(self):
     result = parse('XXXXXX\n' + self.location1 + '\n' + self.non_location +
                    '\n' + self.location2)
     self.assertEqual(len(result), 2)
     sites_in_result = [
         this_result.get('siteNumber') for this_result in result
     ]
     self.assertNotIn('680042108433301', sites_in_result)
Exemplo n.º 2
0
 def test_with_two_locations(self):
     result = parse('XXXXXXX\n' + self.location1 + '\r\n' + self.location2)
     self.assertEqual(len(result), 2)
     self.assertEqual(
         result[0], {
             'agencyCode': 'USGS ',
             'siteNumber': '480042108433301',
             'databaseTableIdentifier': '0',
             'transactionType': 'A',
             'stationName': 'YELLVILLE WATERWORKS',
             'coordinateAccuracyCode': 'S',
             'coordinateMethodCode': 'M',
             'coordinateDatumCode': 'NAD27',
             'districtCode': '05',
             'stateFipsCode': '05',
             'countyCode': '089',
             'hydrologicUnitCode': '11010003',
             'siteTypeCode': 'NNNNNNNNNNNNYNNNNNNN',
             'nationalWaterUseCode': 'WS',
             'timeZoneCode': 'CST',
             'daylightSavingsTimeFlag': 'Y',
             'dataReliabilityCode': 'C',
             'countryCode': 'US'
         })
     self.assertEqual(
         result[1], {
             'agencyCode': 'USEPA',
             'siteNumber': '123456789012345',
             'databaseTableIdentifier': '0',
             'transactionType': 'A',
             'stationName': 'INTAKE ON LAKE WOBEGON',
             'siteTypeCode': 'FA-DV Long Line',
             'coordinateMethodCode': '',
             'coordinateDatumCode': 'NAD27',
             'districtCode': '05',
             'stateFipsCode': '05',
             'countyCode': '023',
             'hydrologicUnitCode': '11010014'
         })
Exemplo n.º 3
0
 def test_with_single_location(self):
     result = parse('XXXXXXX\n' +self.location1)
     self.assertEqual(len(result), 1)
     self.assertEqual(result[0], {
         'agencyCode': 'USGS ',
         'siteNumber': '480042108433301',
         'databaseTableIdentifier': '0',
         'transactionType': 'A',
         'stationName': 'YELLVILLE WATERWORKS',
         'coordinateAccuracyCode': 'S',
         'coordinateMethodCode': 'M',
         'coordinateDatumCode': 'NAD27',
         'districtCode': '05',
         'stateFipsCode': '05',
         'countyCode': '089',
         'hydrologicUnitCode': '11010003',
         'siteTypeCode': 'NNNNNNNNNNNNYNNNNNNN',
         'nationalWaterUseCode': 'WS',
         'timeZoneCode': 'CST',
         'daylightSavingsTimeFlag': 'Y',
         'dataReliabilityCode': 'C',
         'countryCode': 'US'
     })
Exemplo n.º 4
0
 def test_invalid_transaction_type(self):
     with self.assertRaises(ParseError) as err:
         result = parse('XXXXX\n' + 'USGS 480042108433301 R=0* T=B*')
     self.assertIn('Invalid transaction', err.exception.message)
     self.assertIn('lines [2]', err.exception.message)
Exemplo n.º 5
0
 def test_with_bad_component_values(self):
     with self.assertRaises(ParseError) as err:
         result = parse('XXXXX\n' + self.invalid_component_codes)
     self.assertIn('999, 998', err.exception.message)
     self.assertIn('lines [2, 3]', err.exception.message)
Exemplo n.º 6
0
 def test_with_missing_transaction_type(self):
     with self.assertRaises(ParseError) as err:
         result = parse('XXXXX\n' + self.location1 + '\n' + self.missing_transaction_type)
     self.assertIn('Missing "T"', err.exception.message)
     self.assertIn('lines [5]', err.exception.message)
Exemplo n.º 7
0
 def test_with_duplicate_non_adjacent_transactions(self):
     with self.assertRaises(ParseError) as err:
         result = parse('XXXXXX\n' + self.location1 + '\n' + self.location2 + '\n' + self.location1)
     self.assertIn('Duplicate transaction', err.exception.message)
Exemplo n.º 8
0
 def test_with_site_web_ready_code_of_not_c(self):
     result = parse('XXXXXX\n' +
                    self.location1_transaction_start +
                    ' 32=P*'
     )
     self.assertEqual(result[0].get('siteWebReadyCode'), 'P')
Exemplo n.º 9
0
 def test_with_longitude_with_dash(self):
     result = parse('XXXXXX\n' + self.location1_transaction_start + ' 10=-1000000*')
     self.assertEqual(result[0]['longitude'], '-1000000')
Exemplo n.º 10
0
 def test_with_no_value_ending_token(self):
     with self.assertRaises(ParseError) as err:
         result = parse('XXXXXX\n' + self.location1 + '\n' + self.location3 + '=13')
     self.assertIn('[5, 6]', err.exception.message)
     self.assertIn('12=13', err.exception.message)
Exemplo n.º 11
0
 def test_with_no_code_separator(self):
     with self.assertRaises(ParseError) as err:
         result = parse('XXXXXX\n' + self.location1 + '\n' + self.location3)
     self.assertIn('[5, 6]', err.exception.message)
     self.assertIn('12', err.exception.message)
Exemplo n.º 12
0
 def test_with_invalid_site_number_very_short(self):
     with self.assertRaises(ParseError) as e:
         parse('XXXXXXX\n' + self.invalid_site_number_very_short)
     self.assertIn('lines 2, 3, 4', e.exception.message)
Exemplo n.º 13
0
 def test_with_line_too_long(self):
     with self.assertRaises(ParseError) as e:
         parse('XXXXXXX\n' + self.long_line)
     self.assertIn('lines 2', e.exception.message)
Exemplo n.º 14
0
 def test_with_no_transactions(self):
     with self.assertRaises(ParseError):
         parse('XXXXXXXX')
Exemplo n.º 15
0
 def test_no_contents(self):
     with self.assertRaises(ParseError):
         parse('')
Exemplo n.º 16
0
 def test_with_latitude_with_space(self):
     result = parse('XXXXXX\n' + self.location1_transaction_start + ' 9= 400000*')
     self.assertEqual(result[0]['latitude'], ' 400000')
Exemplo n.º 17
0
 def test_with_neg_90_longitude_with_zero(self):
     result = parse('XXXXXX\n' + self.location1_transaction_start + ' 10=-0900000*')
     self.assertEqual(result[0]['longitude'], '-0900000')
Exemplo n.º 18
0
 def test_with_duplicate_station_name(self):
     with self.assertRaises(ParseError) as err:
         result = parse('XXXXXX\n' + self.location1 + '\n' + 'USGS 480042108433301 900=Another name*')
     self.assertIn('2, 3, 4, 5', err.exception.message)
     self.assertIn('Duplicate station name', err.exception.message)
Exemplo n.º 19
0
 def test_empty_longitude(self):
     result = parse('XXXXXX\n' + self.location1_transaction_start + ' 10=*')
     self.assertEqual(result[0]['longitude'], '')
Exemplo n.º 20
0
 def test_with_starting_quote_and_no_ending_quote_on_station_name(self):
     result = parse('XXXXXX\n' +
                    self.location1_transaction_start +
                    ' 12=YELLVILLE WATERWORKS\'*'
     )
     self.assertEqual(result[0].get('stationName'), 'YELLVILLE WATERWORKS\'')