Beispiel #1
0
 def setUp(self):
     # creates user object in db
     self.user_password = PASSWORD
     self.user = create_superadminuser()
     self.client = Client()
     self.client.login(username=self.user.username, password=self.user_password)
     create_wms_service(group=self.user.groups.first(), how_much_services=10)
     self.service_md = Metadata.objects.filter(
         metadata_type=MetadataEnum.SERVICE.value
     ).first()
Beispiel #2
0
    def setUp(self):
        # requires services
        self.user = create_superadminuser()
        self.client = Client()
        self.client.login(username=self.user.username, password=PASSWORD)
        create_wms_service(group=self.user.groups.first(),
                           how_much_services=10)
        self.api_catalogue_uri = reverse("api:catalogue-list")

        # Get some fragment from a metadata title as value for parameter q
        self.q_param = Metadata.objects.all().first().title
        self.q_param = self.q_param[int(len(self.q_param) / 2):-1]
Beispiel #3
0
    def setUp(self):
        self.user = create_superadminuser()
        self.client = Client()
        self.client.login(username=self.user.username, password=PASSWORD)
        create_wms_service(group=self.user.groups.first(),
                           how_much_services=10)

        # Make sure services are activated
        services = Service.objects.all()
        for service in services:
            activate_service(service, True)

        self.test_id = services.first().metadata.identifier
Beispiel #4
0
    def test_removing_of_updatecandidates(self):
        older_than = 10

        user = create_superadminuser()
        organizations = create_non_autogenerated_orgas(user=user)

        wms_metadatas = create_wms_service(group=user.groups.first(),
                                           contact=organizations[0],
                                           how_much_services=10)
        wfs_metadatas = create_wfs_service(group=user.groups.first(),
                                           contact=organizations[0],
                                           how_much_services=10)

        for wms_metadata in wms_metadatas:
            update_candidate_metadata = create_wms_service(
                group=user.groups.first(),
                contact=organizations[0],
                how_much_services=1,
                is_update_candidate_for=wms_metadata.service,
                user=user)

            update_candidate_metadata[
                0].service.last_modified = timezone.localtime(
                ) - timezone.timedelta(days=older_than, )
            update_candidate_metadata[0].service.save(
                update_last_modified=False)

        for wfs_metadata in wfs_metadatas:
            update_candidate_metadata = create_wfs_service(
                group=user.groups.first(),
                contact=organizations[0],
                how_much_services=1,
                is_update_candidate_for=wfs_metadata.service,
                user=user)
            update_candidate_metadata[
                0].service.last_modified = timezone.localtime(
                ) - timezone.timedelta(days=older_than)
            update_candidate_metadata[0].service.save(
                update_last_modified=False)

        out = StringIO()
        call_command('rm_updatecandidates', stdout=out, ot=older_than)
        self.assertIn(
            'Deleted 20 objects older than {} days'.format(older_than),
            out.getvalue())

        services_count = Service.objects.filter(is_root=True).count()
        self.assertEqual(services_count, 20)
Beispiel #5
0
 def setUp(self):
     self.user = create_superadminuser()
     self.wms_metadata = create_wms_service(group=self.user.groups.first(),
                                            how_much_sublayers=10,
                                            how_much_services=2)
     self.wfs_metadata = create_wfs_service(group=self.user.groups.first(),
                                            how_much_featuretypes=10,
                                            how_much_services=2)
Beispiel #6
0
    def setUp(self):
        return
        self.user = create_superadminuser()
        self.client = Client()
        self.client.login(username=self.user.username, password=PASSWORD)

        self.wms_metadatas = create_wms_service(group=self.user.groups.first(),
                                                how_much_services=1)
Beispiel #7
0
    def test_post_invalid_update_candidate_exists_update_service_page1(self):
        return
        params = {
            'page': '1',
            'get_capabilities_uri': get_capabilitites_url().get('valid'),
        }
        create_wms_service(
            is_update_candidate_for=self.wms_metadatas[0].service,
            group=self.user.groups.all()[0],
            user=self.user)

        response = self.client.post(
            reverse('resource:new-pending-update',
                    args=(self.wms_metadatas[0].id, )) + "?current-view=home",
            data=params)
        self.assertEqual(
            response.status_code, 422
        )  # "There are still pending update requests from user '{}' for this service.".format(self.user)
Beispiel #8
0
    def setUp(self):
        # requires services
        self.user = create_superadminuser()
        self.client = Client()
        self.client.login(username=self.user.username, password=PASSWORD)
        create_wms_service(group=self.user.groups.first(),
                           how_much_services=10)

        # Default elements of json response
        self.default_response_elements = [
            "count",
            "next",
            "previous",
            "results",
        ]

        # 'name-list' | 'name-detail' is the naming convention of DRF
        # The values declare what we expect from a simple request for this API without further parameters
        self.available_apis = {
            "catalogue-list":
            Metadata.objects.filter(is_active=True),
            "metadata-list":
            Metadata.objects.filter(is_active=True),
            "suggestion-list":
            Keyword.objects.all()[:SUGGESTIONS_MAX_RESULTS],
            "category-list":
            Category.objects.all(),
            "organization-list":
            Organization.objects.filter(),
            "service-list":
            Service.objects.filter(parent_service=None,
                                   metadata__is_active=True),
            "layer-list":
            Layer.objects.filter(metadata__is_active=True),
            "group-list":
            MrMapGroup.objects.filter(),
        }
Beispiel #9
0
    def setUp(self):
        self.user = create_superadminuser()
        self.group = self.user.groups.first()
        self.metadata = create_wms_service(self.group, how_much_services=10)[0]

        # Declare timeout span
        self.timeout_delta = timezone.timedelta(seconds=10)

        # For new service testing
        create_non_autogenerated_orgas(self.user, 3)
        self.org = Organization.objects.all().first()

        # For securing service
        create_operation(OGCOperationEnum.GET_MAP.value)
        self.operation = RequestOperation.objects.all().first()
Beispiel #10
0
    def setUp(self):
        self.default_user = create_testuser()
        self.user = create_superadminuser()
        self.user.organization = create_non_autogenerated_orgas(user=self.user, how_much_orgas=1)[0]
        self.user.save()

        self.client = Client()
        self.client.login(username=self.user.username, password=PASSWORD)
        self.request_factory = RequestFactory()

        self.wms_services = create_wms_service(
            group=self.user.groups.first(),
            how_much_services=1
        )

        # Setup for log proxy test
        self.metadata = Metadata.objects.all().first()
        self.metadata.use_proxy_uri = True
        self.metadata.log_proxy_access = True
        self.metadata.save()
        self.metadata.refresh_from_db()
Beispiel #11
0
 def setUp(self):
     self.user = create_superadminuser()
     self.root_metadata = create_wms_service(group=self.user.groups.first(),
                                             how_much_sublayers=100,
                                             how_much_services=1)[0]
Beispiel #12
0
 def setUp(self):
     self.user_password = PASSWORD
     self.user = create_superadminuser()
     self.wms_services = create_wms_service(group=self.user.groups.first(),
                                            how_much_services=1)
     self.monitoring_run = create_monitoring_run()[0]