コード例 #1
0
 def test_fetch_all(self, testapp):
     res = testapp.get(
         "/application", headers={"X-Openpush-Key": "aaaaAAAAbbbbBBBB0000111-C1"}
     )
     data = res.json
     assert len(data) == 2
     assert set_of("registration_id", data) == {"app_c1_1", "app_c1_2"}
コード例 #2
0
 def test_delete(self, testapp):
     testapp.authorization = ("Basic", ("User 1", "password1"))
     res = testapp.delete("/client/2")
     assert res.status_int == 204
     res = testapp.get("/client")
     data = res.json
     assert "client_u1_2" not in set_of("name", data)
コード例 #3
0
 def test_delete(self, testapp):
     res = testapp.delete(
         "/application/2", headers={"X-Openpush-Key": "aaaaAAAAbbbbBBBB0000111-C1"}
     )
     assert res.status_int == 204
     res = testapp.get(
         "/application", headers={"X-Openpush-Key": "aaaaAAAAbbbbBBBB0000111-C2"}
     )
     data = res.json
     assert "app_c1_2" not in set_of("registration_id", data)
コード例 #4
0
 def test_create(self, testapp):
     testapp.authorization = ("Basic", ("User 1", "password1"))
     res = testapp.post_json("/client", {"name": "New Client"})
     data = res.json
     assert res.status_int == 201
     assert (data["token"] != "aaaaAAAAbbbbBBBB0000111-C1"
             and data["token"] != "aaaaAAAAbbbbBBBB0000111-C2")
     assert len(data["token"]) == 27
     res = testapp.get("/client")
     data = res.json
     assert len(data) == 3
     assert set_of("name",
                   data) == {"client_u1_1", "client_u1_2", "New Client"}
コード例 #5
0
 def test_create(self, testapp):
     res = testapp.post_json(
         "/application",
         {"registration_id": "New App"},
         headers={"X-Openpush-Key": "aaaaAAAAbbbbBBBB0000111-C1"},
     )
     assert res.status_int == 201
     data = res.json
     assert (
         data["routing_token"] != "aaaaAAAAbbbbBBBB0000111-A1"
         and data["routing_token"] != "aaaaAAAAbbbbBBBB0000111-A2"
     )
     assert len(data["routing_token"]) == 27
     res = testapp.get(
         "/application", headers={"X-Openpush-Key": "aaaaAAAAbbbbBBBB0000111-C1"}
     )
     data = res.json
     assert len(data) == 3
     assert set_of("registration_id", data) == {"app_c1_1", "app_c1_2", "New App"}
コード例 #6
0
 def test_fetch_all(self, testapp):
     testapp.authorization = ("Basic", ("User 1", "password1"))
     res = testapp.get("/client")
     data = res.json
     assert len(data) == 2
     assert set_of("name", data) == {"client_u1_1", "client_u1_2"}
コード例 #7
0
    def test_fetch_all(self, testapp):
        res = testapp.get('/v3/pets')
        data = res.json

        assert len(data) == 3
        assert set_of('name', data) == {'tama', 'mike', 'chibi'}
コード例 #8
0
    def test_search(self, testapp):
        res = testapp.post_json('/v3/search/pets', {
            'name': 'mike',
        })
        data = res.json

        assert len(data) == 1
        assert set_of('name', data) == {'mike'}

        res = testapp.post_json('/v3/search/pets', {
            'name': 'pochi',
        })
        data = res.json

        assert len(data) == 0

        res = testapp.post_json('/v3/search/pets', {
            'name': {
                'like': '%i%'
            },
        })
        data = res.json

        assert len(data) == 2
        assert set_of('name', data) == {'mike', 'chibi'}

        res = testapp.post_json('/v3/search/pets', {
            'name': {
                'like': '%i%'
            },
            'status': {
                '==': 'sold'
            },
        })
        data = res.json

        assert len(data) == 1
        assert set_of('name', data) == {'chibi'}

        res = testapp.post_json('/v3/search/pets', {
            'name': {
                'like': '%i%'
            },
            'status': {
                '==': 'sold'
            },
        })
        data = res.json

        assert len(data) == 1
        assert set_of('name', data) == {'chibi'}

        # by store
        res = testapp.post_json('/v3/search/pets', {
            'store.name': 'Pets Unlimited',
        })
        data = res.json

        assert len(data) == 2
        assert set_of('name', data) == {'tama', 'mike'}

        # error
        res = testapp.post_json(
            '/v3/search/pets',
            {
                'blah': 'blah',
            },
            expect_errors=True,
        )

        assert res.status_int == 400