def setUpTestData(cls): cls.node = Node(catalog_id=cls.catalog_id, catalog_url=os.path.join(dir_path, 'full_data.json'), catalog_format='json', indexable=True) cls.node.catalog = json.dumps(DataJson(cls.node.catalog_url)) cls.node.save() cls.task = IndicatorsGenerationTask.objects.create() cls.catalogs = load_catalogs(cls.task, Node.objects.all())
def setUpTestData(cls): HarvestingNode.objects.create( name='aName', url='harvest_url', apikey='apikey', enabled=True) Node.objects.create(catalog_id='id1', catalog_url=cls.get_sample('full_data.json'), indexable=True) Node.objects.create(catalog_id='id2', catalog_url=cls.get_sample('minimum_data.json'), indexable=True) HarvestingNode.objects.create( catalog_id='idx1', name='indexador1', url=cls.get_sample('catalogo_justicia.json'), apikey='apikey', enabled=True) HarvestingNode.objects.create( catalog_id='idx2', name='indexador2', url=cls.get_sample('full_data.json'), apikey='apikey', enabled=True) task = IndicatorsGenerationTask.objects.create() cls.catalogs = load_catalogs(task, Node.objects.all()) # Quiero que los cargue por el path, no como url. Uso harvesting=False cls.indexing_catalogs = load_catalogs(task, HarvestingNode.objects.all()) central = DataJson(cls.get_sample('full_data.json')) cls.indicators, cls.network_indicators = \ DataJson().generate_catalogs_indicators(cls.catalogs, central_catalog=central, identifier_search=True, broken_links=True) cls.indexing_indicators, _ = \ DataJson().generate_catalogs_indicators(cls.indexing_catalogs, identifier_search=True, broken_links=True) config = TasksConfig.get_solo() config.indicators_url_check = True config.save() cls.dj = DataJson() with patch('monitoreo.apps.dashboard.indicators_tasks.CENTRAL', cls.get_sample('full_data.json')): call_command('indicadores')
def test_load_catalog_json_node_format(self): def mock_side_effect(catalog, catalog_format=None, verify_ssl=False): return {'format': catalog_format} with patch('monitoreo.apps.dashboard.helpers.DataJson', side_effect=mock_side_effect): result = load_catalogs(self.task, Node.objects.all()) self.assertEqual([{ 'identifier': 'test_catalog', 'format': 'json' }], result)
def test_load_catalog_xlsx_node_format(self): def mock_side_effect(catalog, catalog_format=None): return {'format': catalog_format} self.node.catalog_format = 'xlsx' self.node.save() with patch('monitoreo.apps.dashboard.helpers.DataJson', side_effect=mock_side_effect): result = load_catalogs(self.task, Node.objects.all()) self.assertEqual([{ 'identifier': 'test_catalog', 'format': 'xlsx' }], result)