Closed opsdep closed 4 years ago
[x] rename nansat_ingestor/management/commands/ingest_thredds_crawl.crawl to crawl_and_ingest
[x] Split nansat_ingestor/tests/tests.TestDatasetManager.test_getorcreate_localfile(self, mock_isfile) into three tests:
[x] Add tests to nansat_ingestor/tests/tests. TestIngestThreddsCrawlcrawlfunction which check that NansatDataset.objects.get_or_create() was called ONCE with correct values for url, uri_service_name and uri_service_type; AND checks that DatasetURI.objects.get_or_create was called (several times) with correct values of name, service, uri.
See Mock docs here: https://docs.python.org/3/library/unittest.mock.html
There is a many to many relationship between dataset table and the parameter table. Some tests should be written in order to test the filtering ability of datasets based on specifying the parameters of them. This is working in the Django shell and the tests should assert that this filtering is ok. Thus, tests should consider below notes:
ingest
oringest_thredds_crawl
command should be used to ingesting a new dataset with nansatcrawl
function for this purpose ifingest_thredds_crawl
command is usedNansat
objectFor this purpose, below python code ( as snippet, not the exact code ) can be used in a separate file:
import django os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.project.settings") django.setup()
import geospaas.nansat_ingestor.management.commands.ingest as ingest command = ingest.Command() command.handle(files=["/data/MER_FRS_1PNPDK20120303_093810_000000333112_00180_52349_3561.N1"], nansat_option=[])
import geospaas.nansat_ingestor.management.commands.ingest_thredds_crawl as ingest_thredds_crawl command = ingest_thredds_crawl.Command() command.handle(url=["http://nbstds.met.no/thredds/catalog/NBS/S2A/2017/01/catalog.html"],date = '2017/01/10')