test_api.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:openwisp-controller 作者: openwisp 项目源码 文件源码
def test_put_update_coordinates(self):
        self.assertEqual(self.location_model.objects.count(), 0)
        dl = self._create_object_location()
        url = reverse(self.url_name, args=[dl.device.pk])
        url = '{0}?key={1}'.format(url, dl.device.key)
        self.assertEqual(self.location_model.objects.count(), 1)
        coords = json.loads(Point(2, 23).geojson)
        feature = json.dumps({'type': 'Feature', 'geometry': coords})
        r = self.client.put(url, feature, content_type='application/json')
        self.assertEqual(r.status_code, 200)
        self.assertDictEqual(r.json(), {
            'type': 'Feature',
            'geometry': coords,
            'properties': {'name': dl.location.name}
        })
        self.assertEqual(self.location_model.objects.count(), 1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号