コード例 #1
0
    def test_localities_api_view(self):
        user = UserF.create(id=1, username='******')
        chgset = ChangesetF.create(
            social_user=user, created=datetime.datetime(2014, 11, 23, 12, 0)
        )
        dom = DomainF.create(name='test_domain', changeset=chgset)
        LocalityF.create(
            geom='POINT(16.9 45.4)', uuid='35570d8b22494bb6a88487a8108ffd69',
            changeset=chgset, domain=dom
        )

        LocalityF.create(
            geom='POINT(16 45)', uuid='35570d8b22494bb6a88487a8108ffd68',
            changeset=chgset, domain=dom
        )

        resp = self.client.get(
            reverse('api_localities'), {'bbox': '-180,-90,180,90'}
        )

        self.assertEqual(resp.status_code, 200)

        self.assertEqual(
            resp.content,
            u'[{"version": 1, "user_id": 1, "uuid": "35570d8b22494bb6a88487a81'
            u'08ffd69", "lnglat": "16.9,45.4"}, {"version": 1, "user_id": 1, "'
            u'uuid": "35570d8b22494bb6a88487a8108ffd68", "lnglat": "16,45"}]'
        )
コード例 #2
0
    def test_localities_view(self):
        LocalityF.create(id=1, geom='POINT(16 45)')
        resp = self.client.get(reverse('localities'))

        self.assertEqual(resp.status_code, 200)

        self.assertEqual(resp['Content-Type'], 'application/json')
        self.assertEqual(resp.content, '[{"i": 1, "g": [16.0, 45.0]}]')
コード例 #3
0
    def test_locality_api_view(self):
        user = UserF.create(id=1, username='******')
        chgset = ChangesetF.create(id=1,
                                   social_user=user,
                                   created=datetime.datetime(
                                       2014, 11, 23, 12, 0))
        dom = DomainF.create(name='test_domain', changeset=chgset)

        attr = AttributeF.create(key='test', changeset=chgset)

        spec = SpecificationF.create(domain=dom,
                                     attribute=attr,
                                     changeset=chgset)

        loc = LocalityF.create(geom='POINT(16.9 45.4)',
                               uuid='35570d8b22494bb6a88487a8108ffd69',
                               changeset=chgset,
                               domain=dom)

        ValueF.create(changeset=chgset,
                      specification=spec,
                      locality=loc,
                      data='test val')

        resp = self.client.get(
            reverse('api_locality',
                    kwargs={'uuid': '35570d8b22494bb6a88487a8108ffd69'}))

        self.assertEqual(resp.status_code, 200)

        self.assertEqual(
            resp.content,
            u'{"geom": [16.9, 45.4], "version": 1, "values": {"test": "test va'
            u'l"}, "uuid": "35570d8b22494bb6a88487a8108ffd69", "changeset": 1}'
        )
コード例 #4
0
ファイル: test_views.py プロジェクト: dimasciput/healthsites
    def test_locality_api_view(self):
        user = UserF.create(id=1, username='******')
        chgset = ChangesetF.create(
            id=1, social_user=user,
            created=datetime.datetime(2014, 11, 23, 12, 0)
        )
        dom = DomainF.create(name='test_domain', changeset=chgset)

        attr = AttributeF.create(key='test', changeset=chgset)

        spec = SpecificationF.create(
            domain=dom, attribute=attr, changeset=chgset
        )

        loc = LocalityF.create(
            geom='POINT(16.9 45.4)', uuid='35570d8b22494bb6a88487a8108ffd69',
            changeset=chgset, domain=dom
        )

        ValueF.create(
            changeset=chgset, specification=spec, locality=loc,
            data='test val'
        )

        resp = self.client.get(
            reverse(
                'api_locality',
                kwargs={'uuid': '35570d8b22494bb6a88487a8108ffd69'}
            )
        )

        self.assertEqual(resp.status_code, 200)

        self.assertEqual(
            resp.content,
            u'{"geom": [16.9, 45.4], "version": 1, "values": {"test": "test va'
            u'l"}, "uuid": "35570d8b22494bb6a88487a8108ffd69", "changeset": 1}'
        )