def setUp(self): super().setUp() update_frequency = base.UpdateFrequencyFactory() area = base.AreaFactory() timeliness = base.TimelinessFactory() data_policy = base.DataPolicyFactory() data_type = base.DataTypeFactory() data_format = base.DataFormatFactory() quality_control_procedure = base.QualityControlProcedureFactory() inspire_themes = [ base.InspireThemeFactory(), base.InspireThemeFactory() ] essential_variables = [ base.EssentialVariableFactory(), base.EssentialVariableFactory(), base.EssentialVariableFactory() ] dissemination = base.DisseminationFactory() self._DATA = { 'name': 'TEST data', 'note': 'TEST note', 'update_frequency': update_frequency.pk, 'area': area.pk, 'timeliness': timeliness.pk, 'data_policy': data_policy.pk, 'data_type': data_type.pk, 'data_format': data_format.pk, 'quality_control_procedure': quality_control_procedure.pk, 'inspire_themes': [inspire_theme.pk for inspire_theme in inspire_themes], 'start_time_coverage': datetime.date(day=1, month=1, year=2000), 'end_time_coverage': datetime.date(day=1, month=1, year=2000), 'essential_variables': [ essential_variable.pk for essential_variable in essential_variables ], 'dissemination': dissemination.pk } self.creator = base.UserFactory(username='******') base.TeamFactory(user=self.creator) self.client.force_login(self.creator)
def setUp(self): super().setUp() group = base.ProductGroupFactory() component = base.ComponentFactory() status = base.ProductStatusFactory() area = base.AreaFactory() self.user = provider_user = base.UserFactory(is_superuser=True, username='******') self.client.force_login(provider_user) self._DATA = { 'acronym': 'TST', 'name': 'TEST product', 'note': 'TEST note', 'description': 'TEST description', 'group': group.pk, 'component': component.pk, 'status': status.pk, 'area': area.pk } with open(os.devnull, 'w') as f: call_command('search_index', '--rebuild', '-f', stdout=f)
def setUp(self): super().setUp() group = base.ProductGroupFactory() component = base.ComponentFactory() status = base.StatusFactory() area = base.AreaFactory() self.user = provider_user = base.UserFactory( is_superuser=True, username="******" ) self.client.force_login(provider_user) self._DATA = { "acronym": "TST", "name": "TEST product", "note": "TEST note", "description": "TEST description", "group": group.pk, "component": component.pk, "status": status.pk, "area": area.pk, } with open(os.devnull, "w") as f: call_command("search_index", "--rebuild", "-f", stdout=f)
def test_entity_and_group_sync_other_filters(self): """ Whenever any of the filters is selected, this should trigger a synchronization of all other filters. Because of combinatorial explosion it is impractical to test all possible combinations, so this only tests one specific case that was selected at random, namely `entity`, and `group` triggering the synchronization of `service`, `component`, `status` and `area`. """ service_1 = base.CopernicusServiceFactory(name="Service 1") service_2 = base.CopernicusServiceFactory(name="Service 2") entity_1 = base.EntrustedEntityFactory(acronym="Entity 1") entity_2 = base.EntrustedEntityFactory(acronym="Entity 2") component_1 = base.ComponentFactory(name='Component 1', service=service_1, entrusted_entity=entity_1) component_2 = base.ComponentFactory(name='Component 2', service=service_1, entrusted_entity=entity_2) component_3 = base.ComponentFactory(name='Component 3', service=service_2, entrusted_entity=entity_1) group_1 = base.ProductGroupFactory(name='Group 1') group_2 = base.ProductGroupFactory(name='Group 2') status_1 = base.ProductStatusFactory(name='Status 1') status_2 = base.ProductStatusFactory(name='Status 2') area_1 = base.AreaFactory(name='Area 1') area_2 = base.AreaFactory(name='Area 2') base.ProductFactory(component=component_1, group=group_1, status=status_1, area=area_1) base.ProductFactory(component=component_2, group=group_1, status=status_1, area=area_1) base.ProductFactory(component=component_1, group=group_2, status=status_2, area=area_1) base.ProductFactory(component=component_3, group=group_1, status=status_1, area=area_2) resp = self.client.get(reverse('product:json'), { 'entity': entity_1.acronym, 'group': group_1.name }) self.assertEqual(resp.status_code, 200) data = resp.json() filters = { 'component': { 'options': ['Component 1', 'Component 3'], 'selected': None }, 'area': { 'options': ['Area 1', 'Area 2'], 'selected': None }, 'entity': { 'options': ['Entity 1'], 'selected': 'Entity 1' }, 'group': { 'options': ['Group 1'], 'selected': 'Group 1' }, 'service': { 'options': ['Service 1', 'Service 2'], 'selected': None }, 'status': { 'options': ['Status 1'], 'selected': None } } self.assertEqual(data['filters'], filters)
def test_entity_and_group_sync_other_filters(self): """ Whenever any of the filters is selected, this should trigger a synchronization of all other filters. Because of combinatorial explosion it is impractical to test all possible combinations, so this only tests one specific case that was selected at random, namely `entity`, and `group` triggering the synchronization of `service`, `component`, `status` and `area`. """ service_1 = base.CopernicusServiceFactory(name="Service 1") service_2 = base.CopernicusServiceFactory(name="Service 2") entity_1 = base.EntrustedEntityFactory(acronym="Entity 1") entity_2 = base.EntrustedEntityFactory(acronym="Entity 2") component_1 = base.ComponentFactory( name="Component 1", service=service_1, entrusted_entity=entity_1 ) component_2 = base.ComponentFactory( name="Component 2", service=service_1, entrusted_entity=entity_2 ) component_3 = base.ComponentFactory( name="Component 3", service=service_2, entrusted_entity=entity_1 ) group_1 = base.ProductGroupFactory(name="Group 1") group_2 = base.ProductGroupFactory(name="Group 2") status_1 = base.StatusFactory(name="Status 1") status_2 = base.StatusFactory(name="Status 2") area_1 = base.AreaFactory(name="Area 1") area_2 = base.AreaFactory(name="Area 2") base.ProductFactory( component=component_1, group=group_1, status=status_1, area=area_1 ) base.ProductFactory( component=component_2, group=group_1, status=status_1, area=area_1 ) base.ProductFactory( component=component_1, group=group_2, status=status_2, area=area_1 ) base.ProductFactory( component=component_3, group=group_1, status=status_1, area=area_2 ) resp = self.client.get( reverse("product:json"), {"entity": entity_1.acronym, "group": group_1.name} ) self.assertEqual(resp.status_code, 200) data = resp.json() filters = { "component": {"options": ["Component 1", "Component 3"], "selected": None}, "area": {"options": ["Area 1", "Area 2"], "selected": None}, "entity": {"options": ["Entity 1"], "selected": "Entity 1"}, "group": {"options": ["Group 1"], "selected": "Group 1"}, "service": {"options": ["Service 1", "Service 2"], "selected": None}, "status": {"options": ["Status 1"], "selected": None}, } self.assertEqual(data["filters"], filters)
def setUp(self): super().setUp() update_frequency = base.UpdateFrequencyFactory() area = base.AreaFactory() status = base.StatusFactory() timeliness = base.TimelinessFactory() data_policy = base.DataPolicyFactory() data_type = base.DataTypeFactory() data_format = base.DataFormatFactory() quality_control_procedure = base.QualityControlProcedureFactory() inspire_themes = [ base.InspireThemeFactory(), base.InspireThemeFactory() ] essential_variables = [ base.EssentialVariableFactory(), base.EssentialVariableFactory(), base.EssentialVariableFactory(), ] geographical_coverages = [base.CountryFactory(code="T3")] dissemination = base.DisseminationFactory() self._DATA = { "name": "TEST data", "note": "TEST note", "update_frequency": update_frequency.pk, "area": area.pk, "status": status.pk, "timeliness": timeliness.pk, "data_policy": data_policy.pk, "data_type": data_type.pk, "data_format": data_format.pk, "quality_control_procedure": quality_control_procedure.pk, "inspire_themes": [inspire_theme.pk for inspire_theme in inspire_themes], "start_time_coverage": datetime.date(day=1, month=1, year=2000), "end_time_coverage": datetime.date(day=1, month=1, year=2000), "essential_variables": [ essential_variable.pk for essential_variable in essential_variables ], "geographical_coverage": [ geographical_coverage.code for geographical_coverage in geographical_coverages ], "dissemination": dissemination.pk, } self.creator = base.UserFactory(username="******") self.client.force_login(self.creator) with open(os.devnull, "w") as f: call_command("search_index", "--rebuild", "-f", stdout=f)