Пример #1
0
    def test_delete(self, testapp):
        url = api.url_for(MapAPI, map_id=1)
        rv = testapp.delete_json(url, status=204)
        # empty content check
        with pytest.raises(ValueError) as ef:
            rv.json
        assert 'No JSON object' in str(ef.value)

        url = api.url_for(MapAPI, map_id=3)
        rv = testapp.delete_json(url, status=400)
        assert rv.json['error_code'] == MAP_ERROR
Пример #2
0
    def test_get(self, testapp):
        url = api.url_for(MapAPI, map_id=1)
        rv = testapp.get(url)
        #pytest.set_trace()
        assert rv.json['map']['map_name'] \
               == self.map1.map_name
        assert rv.json['map']['resource_path'] \
               == self.map1.resource_path

        # map_id:3 no exists
        url = api.url_for(MapAPI, map_id=3)
        rv = testapp.get(url, status=400)
        assert rv.json['error_code'] == MAP_ERROR
Пример #3
0
    def setup(self):
        self.data1 = {
            "user_id": 1,
            "user_name": "u1",
            "password": "******"
        }
        self.user1 = User.create(self.data1)
        self.url1 = api.url_for(UserAPI, user_id=1)

        self.data2 = {
            "user_id": 2,
            "user_name": "u2",
            "password": "******"
        }
        self.url2 = api.url_for(UserAPI, user_id=2)
Пример #4
0
    def test_put(self, testapp):
        url = api.url_for(MapAPI, map_id=2)
        rv = testapp.put_json(
            url,
            dict(map_name='map2_update', resource_path='/map/map2_update'),
            status=200
        )
        assert rv.json['map']['map_name'] == 'map2_update'
        assert rv.json['map']['resource_path'] == '/map/map2_update'

        url = api.url_for(MapAPI, map_id=3)
        rv = testapp.put_json(
            url,
            dict(map_mame='map3', resource_path='/maps/map3'),
            status=400
        )
        assert rv.json['error_code'] == MAP_ERROR
Пример #5
0
    def setup(self):
        self.data1 = {
            "user_id": 1,
            "user_name": "u1",
            "password": "******"
        }
        self.user1 = User.create(self.data1)

        self.data2 = {
            "user_id": 2,
            "user_name": "u2",
            "password": "******"
        }
        self.user2 = User.create(self.data2)

        self.url = api.url_for(UserListAPI)
Пример #6
0
 def format(self, file_name):
     return api.url_for(DownloadAPI, file_name=file_name, _external=True)
Пример #7
0
 def test_get(self, testapp):
     url = api.url_for(MapListAPI)
     rv = testapp.get(url, status=200)
     assert len(rv.json['maps']) == 2