コード例 #1
0
 def test_good_data(self):
     with mock.patch('floodviz.reference_parser.open', mock.mock_open(read_data=self.mock_reference)):
         parsed_data = reference_parser.parse_reference_data(self.mock_path)
         self.assertEqual(parsed_data['epsg'], self.mock_response['epsg'])
         self.assertEqual(parsed_data['display_sites'], self.mock_response['display_sites'])
         self.assertEqual(parsed_data['bbox'], self.mock_response['bbox'])
         self.assertEqual(parsed_data['epsg'], self.mock_response['epsg'])
         self.assertEqual(parsed_data['peak_dv_date'], self.mock_response['peak_dv_date'])
コード例 #2
0
 def test_feature_parsing(self):
     with mock.patch('floodviz.reference_parser.open', mock.mock_open(read_data=self.mock_reference)):
         parsed_data = reference_parser.parse_reference_data(self.mock_path)
         self.assertEqual(parsed_data['city_geojson_data']['features'],
                          self.mock_response['city_geojson_data']['features'])
         self.assertEqual(json.loads(parsed_data['river_geojson_data'])['features'],
                          json.loads(self.mock_response['river_geojson_data'])['features'])
         self.assertEqual(json.loads(parsed_data['background_geojson_data'])['features'],
                          json.loads(self.mock_response['background_geojson_data'])['features'])
コード例 #3
0
 def test_bad_json(self):
     with mock.patch('floodviz.reference_parser.open',
                     mock.mock_open(read_data=self.bad_json)):
         parsed_data = reference_parser.parse_reference_data(self.mock_path)
         self.assertEqual(parsed_data, None)
コード例 #4
0
 def test_missing_field(self):
     with mock.patch('floodviz.reference_parser.open',
                     mock.mock_open(read_data=self.reference_missing_data)):
         parsed_data = reference_parser.parse_reference_data(self.mock_path)
         self.assertEqual(parsed_data, None)
コード例 #5
0
 def test_bad_path(self):
     parsed_data = reference_parser.parse_reference_data(self.mock_path)
     self.assertEqual(parsed_data, None)