Esempio n. 1
0
 def test_ds_created(self):
     self.mock_ds.objects.get_or_create.return_value = (Dataset(), True)
     self.mock_dsuri.objects.get_or_create.return_value = (DatasetURI(), True)
     from geospaas.nansat_ingestor.management.commands.ingest_thredds_crawl import crawl
     added = crawl(self.uri)
     self.mock_validate_uri.assert_called_once_with(self.uri)
     self.mock_Crawl.assert_called_once_with(self.uri, debug=True, select=None, skip=['.*ncml'])
     self.assertEqual(added, 1)
Esempio n. 2
0
 def test_ds_created_with_filename_arg(self):
     self.mock_ds.objects.get_or_create.return_value = (Dataset(), True)
     self.mock_dsuri.objects.get_or_create.return_value = (DatasetURI(), True)
     from geospaas.nansat_ingestor.management.commands.ingest_thredds_crawl import crawl
     fn = 'S2A_MSIL1C_20190124T115401_N0207_R023_T30VWP_20190124T120414.nc'
     added = crawl(self.uri, filename=fn)
     self.mock_validate_uri.assert_called_once_with(self.uri)
     self.mock_Crawl.assert_called_once_with(self.uri, debug=True,
             select=['(.*S2A_MSIL1C_20190124T115401_N0207_R023_T30VWP_20190124T120414.nc)'],
             skip=['.*ncml'])
     self.assertEqual(added, 1)
Esempio n. 3
0
    def test_ds_created_with_date_arg(self):
        self.mock_ds.objects.get_or_create.return_value = (Dataset(), True)
        self.mock_dsuri.objects.get_or_create.return_value = (DatasetURI(),
                                                              True)

        added = crawl_and_ingest(self.uri, date='2019/01/01')
        self.mock_validate_uri.assert_called_once_with(self.uri)
        self.mock_Crawl.assert_called_once_with(
            self.uri,
            debug=True,
            select=['(.*2019/01/01.*\\.nc)'],
            skip=['.*ncml'])
        self.assertEqual(added, 1)
Esempio n. 4
0
 def test_ds_created(self):
     '''shall assert that NansatDataset.objects.get_or_create
     is called for only once with correct input calls (called with opendap)'''
     self.mock_ds.objects.get_or_create.return_value = (Dataset(), True)
     self.mock_dsuri.objects.get_or_create.return_value = (DatasetURI(),
                                                           True)
     added = crawl_and_ingest(self.uri)
     self.mock_validate_uri.assert_called_once_with(self.uri)
     self.mock_Crawl.assert_called_once_with(self.uri,
                                             debug=True,
                                             select=None,
                                             skip=['.*ncml'])
     self.mock_ds.objects.get_or_create.assert_called_once_with(
         'http://nbstds.met.no/TEST/thredds/dodsC/NBS/S2A/2019/01/24/'
         'S2A_MSIL1C_20190124T115401_N0207_R023_T30VWP_20190124T120414.nc',
         uri_service_name='odap',
         uri_service_type='OPENDAP')
     self.assertEqual(added, 1)
Esempio n. 5
0
 def test_dsuri_ds_created(self):
     '''shall assert that DatasetURI.objects.get_or_create
     is called several times with correct input calls'''
     self.mock_ds.objects.get_or_create.return_value = (Dataset(), True)
     self.mock_dsuri.objects.get_or_create.return_value = (DatasetURI(),
                                                           True)
     crawl_and_ingest(self.uri)
     self.mock_validate_uri.assert_called_once_with(self.uri)
     self.mock_Crawl.assert_called_once_with(self.uri,
                                             debug=True,
                                             select=None,
                                             skip=['.*ncml'])
     self.assertEqual(
         self.mock_dsuri.objects.get_or_create.call_args_list[0].
         kwargs['name'], 'odap')
     self.assertEqual(
         self.mock_dsuri.objects.get_or_create.call_args_list[1].
         kwargs['service'], 'HTTPServer')
     self.assertEqual(
         self.mock_dsuri.objects.get_or_create.call_args_list[2].
         kwargs['name'], 'wms')
     self.assertEqual(
         self.mock_dsuri.objects.get_or_create.call_args_list[3].
         kwargs['service'], 'WCS')