示例#1
0
    def test_search_filter(self):
        file = self.get_file('/resources/tests/files/image.jpg', 'rb')
        not_found = self.storage.save('resources/bild.jpg', file.read())
        file.close()
        su = SpatialUnitFactory.create(project=self.prj)
        ResourceFactory.create_from_kwargs([{
            'content_object': su,
            'project': self.prj,
            'file': self.file_name
        }, {
            'content_object': su,
            'project': self.prj,
            'file': self.file_name
        }, {
            'content_object': su,
            'project': self.prj,
            'file': not_found
        }])

        response = self.request(user=self.user,
                                url_kwargs={
                                    'organization': self.prj.organization.slug,
                                    'project': self.prj.slug,
                                    'location': su.id
                                },
                                get_data={'search': 'image'})
        assert response.status_code == 200
        assert len(response.content['results']) == 2
    def test_ordering(self):
        tenure = TenureRelationshipFactory.create(project=self.prj)
        ResourceFactory.create_from_kwargs([
            {
                'content_object': tenure,
                'project': self.prj,
                'name': 'A'
            },
            {
                'content_object': tenure,
                'project': self.prj,
                'name': 'B'
            },
            {
                'content_object': tenure,
                'project': self.prj,
                'name': 'C'
            },
        ])

        response = self.request(user=self.user,
                                url_kwargs={'tenure_rel_id': tenure.id},
                                get_data={'ordering': 'name'})
        assert response.status_code == 200
        assert len(response.content['results']) == 3
        names = [resource['name'] for resource in response.content['results']]
        assert (names == sorted(names))
示例#3
0
    def test_reverse_ordering(self):
        su = SpatialUnitFactory.create(project=self.prj)
        ResourceFactory.create_from_kwargs([
            {
                'content_object': su,
                'project': self.prj,
                'name': 'A'
            },
            {
                'content_object': su,
                'project': self.prj,
                'name': 'B'
            },
            {
                'content_object': su,
                'project': self.prj,
                'name': 'C'
            },
        ])

        response = self.request(user=self.user,
                                url_kwargs={'location': su.id},
                                get_data={'ordering': '-name'})
        assert response.status_code == 200
        assert len(response.content['results']) == 3
        names = [resource['name'] for resource in response.content['results']]
        assert (names == sorted(names, reverse=True))
    def test_search_filter(self):
        not_found = self.storage.save('resources/bild.jpg', self.file)
        tenure = TenureRelationshipFactory.create(project=self.prj)
        ResourceFactory.create_from_kwargs([{
            'content_object': tenure,
            'project': self.prj,
            'file': self.file_name
        }, {
            'content_object': tenure,
            'project': self.prj,
            'file': self.file_name
        }, {
            'content_object': tenure,
            'project': self.prj,
            'file': not_found
        }])

        response = self.request(user=self.user,
                                url_kwargs={
                                    'organization': self.prj.organization.slug,
                                    'project': self.prj.slug,
                                    'tenure_rel_id': tenure.id
                                },
                                get_data={'search': 'image'})
        assert response.status_code == 200
        assert len(response.content) == 2
    def test_reverse_ordering(self):
        su = SpatialUnitFactory.create(project=self.prj)
        ResourceFactory.create_from_kwargs([
            {'content_object': su, 'project': self.prj, 'name': 'A'},
            {'content_object': su, 'project': self.prj, 'name': 'B'},
            {'content_object': su, 'project': self.prj, 'name': 'C'},
        ])

        response = self.request(
            user=self.user,
            url_kwargs={'location': su.id},
            get_data={'ordering': '-name'})
        assert response.status_code == 200
        assert len(response.content) == 3
        names = [resource['name'] for resource in response.content]
        assert(names == sorted(names, reverse=True))
示例#6
0
    def test_reverse_ordering(self):
        party = PartyFactory.create(project=self.prj)
        ResourceFactory.create_from_kwargs([
            {'content_object': party, 'project': self.prj, 'name': 'A'},
            {'content_object': party, 'project': self.prj, 'name': 'B'},
            {'content_object': party, 'project': self.prj, 'name': 'C'},
        ])

        response = self.request(
            user=self.user,
            url_kwargs={'party': party.id},
            get_data={'ordering': '-name'})
        assert response.status_code == 200
        assert len(response.content) == 3
        names = [resource['name'] for resource in response.content]
        assert(names == sorted(names, reverse=True))
    def test_ordering(self):
        party = PartyFactory.create(project=self.prj)
        ResourceFactory.create_from_kwargs([
            {'content_object': party, 'project': self.prj, 'name': 'A'},
            {'content_object': party, 'project': self.prj, 'name': 'B'},
            {'content_object': party, 'project': self.prj, 'name': 'C'},
        ])

        response = self.request(
            user=self.user,
            url_kwargs={'party': party.id},
            get_data={'ordering': 'name'})
        assert response.status_code == 200
        assert len(response.content) == 3
        names = [resource['name'] for resource in response.content]
        assert(names == sorted(names))
    def test_search_filter(self):
        not_found = self.storage.save('resources/bild.jpg', self.file)
        su = SpatialUnitFactory.create(project=self.prj)
        ResourceFactory.create_from_kwargs([
            {'content_object': su, 'project': self.prj,
                'file': self.file_name},
            {'content_object': su, 'project': self.prj,
                'file': self.file_name},
            {'content_object': su, 'project': self.prj,
                'file': not_found}
        ])

        response = self.request(
            user=self.user,
            url_kwargs={'organization': self.prj.organization.slug,
                        'project': self.prj.slug,
                        'location': su.id},
            get_data={'search': 'image'})
        assert response.status_code == 200
        assert len(response.content) == 2