コード例 #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_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}'
        )
コード例 #3
0
ファイル: test_utilities.py プロジェクト: tyrasd/healthsites
 def setUp(self):
     self.user = UserF.create(**{'username': '******', 'is_staff': True})
     self.user.set_password('password')
     self.user.save()
     self.attr = AttributeF.create(key='facility')
     self.attr2 = AttributeF.create(key='staff')
     self.attr3 = AttributeF.create(key='inpatient_service')
     self.attr4 = AttributeF.create(key='scope_of_service')
     self.locality = LocalityValue4F.create(
         name='locality test',
         val1__data='building',
         val1__specification__attribute=self.attr,
         val2__data='15|18',
         val2__specification__attribute=self.attr2,
         val3__data='5|7',
         val3__specification__attribute=self.attr3,
         val4__data='specialized care|'
         'general acute care|rehabilitation care|',
         val4__specification__attribute=self.attr4,
     )
コード例 #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}'
        )
コード例 #5
0
ファイル: test_importers.py プロジェクト: tyrasd/healthsites
 def setUp(self):
     UserF.create(id=-1, username='******')