Exemple #1
0
 def setUpClass(cls):
     super(CSVTest, cls).setUpClass()
     cls.catalog_id = 'csv_dump_test_catalog'
     path = os.path.join(samples_dir, 'distribution_daily_periodicity.json')
     index_catalog(cls.catalog_id, path, cls.index)
     cls.task = GenerateDumpTask()
     cls.task.save()
     gen = DumpGenerator(cls.task)
     gen.generate()
    def test_invalid_catalog(self):
        task = GenerateDumpTask()
        task.save()

        gen = DumpGenerator(task, "no_catalog")
        gen.generate()
        task.refresh_from_db()

        self.assertFalse(DumpFile.objects.filter(file_type=DumpFile.TYPE_CSV, task=task))
    def test_dump_distribution_no_periodicity(self):
        task = GenerateDumpTask()
        task.save()
        Distribution.objects.first().enhanced_meta.get(key=meta_keys.PERIODICITY).delete()
        gen = DumpGenerator(task)
        gen.generate()
        task.refresh_from_db()

        self.assertTrue(DumpFile.objects.filter(file_type=DumpFile.TYPE_CSV, task=task))
    def test_leading_nulls_distribution(self):
        path = os.path.join(samples_dir, 'leading_nulls_distribution.json')
        index_catalog('leading_null', path, self.index)
        self.task = GenerateDumpTask()
        self.task.save()
        gen = DumpGenerator(self.task, 'leading_null')
        gen.generate()

        file = self.task.dumpfile_set.get(file_name=DumpFile.FILENAME_FULL,
                                          file_type=DumpFile.TYPE_CSV,
                                          node__catalog_id='leading_null').file
        reader = read_file_as_csv(file)

        next(reader)  # Header!!!!
        self.assertEqual(len(list(reader)), 2)
Exemple #5
0
    def setUpClass(cls):
        super(ViewTests, cls).setUpClass()
        es_client = ElasticInstance.get()
        if es_client.indices.exists(cls.index):
            es_client.indices.delete(cls.index)
        es_client.indices.create(cls.index, body=INDEX_CREATION_BODY)

        cls.catalog_id = 'csv_dump_test_catalog'
        path = os.path.join(samples_dir, 'distribution_daily_periodicity.json')
        index_catalog(cls.catalog_id, path, cls.index)
        cls.task = GenerateDumpTask()
        cls.task.save()
        gen = DumpGenerator(cls.task)
        gen.generate()

        DumpGenerator(cls.task, cls.catalog_id).generate()
 def test_run_catalog_unavailable_fields(self):
     field = Field.objects.last()
     field.enhanced_meta.get(key=meta_keys.AVAILABLE).delete()
     task = GenerateDumpTask.objects.create()
     DumpGenerator(task, self.catalog_id).generate()
     file = task.dumpfile_set.get(file_name=DumpFile.FILENAME_METADATA,
                                  file_type=DumpFile.TYPE_CSV).file
     reader = read_file_as_csv(file)
     for row in reader:
         self.assertNotEqual(row[5], field.title)