コード例 #1
0
 def test_get_favorites__success(self):
     user = add_user(USER1, PASS1)
     item = add_item()
     add_favorite(user, item)
     resp = open_with_auth(self.app, API_ENDPOINT.format('favorites/'),
                           'GET', user.email, PASS1, None, None)
     assert resp.status_code == OK
     expected_result = EXPECTED_RESULTS['get_favorites__success']
     assert_valid_response(resp.data, expected_result)
コード例 #2
0
    def test_delete_only_one_favorites__success(self):
        user = add_user(USER1, PASS1)
        item = add_item()
        item2 = add_item()
        item3 = add_item()
        favorite = add_favorite(user, item)
        add_favorite(user, item2)
        add_favorite(user, item3)
        user_path = 'favorites/{}'.format(str(favorite.uuid))
        resp = open_with_auth(self.app, API_ENDPOINT.format(user_path),
                              'DELETE', user.email, PASS1, None, None)

        assert resp.status_code == OK
        assert Favorite.select().count() == 2
コード例 #3
0
    def test_delete_favorites__fail(self):
        user = add_user(USER1, PASS1)
        item = add_item()
        favorite = add_favorite(user, item)
        user_path = 'favorites/{}'.format(str(favorite.uuid))
        resp = open_with_auth(self.app, API_ENDPOINT.format(user_path),
                              'DELETE', user.email, PASS2, None, None)

        assert resp.status_code == UNAUTHORIZED
コード例 #4
0
    def test_delete_alien_favorites__fail(self):
        user1 = add_user(USER1, PASS1)
        user2 = add_user(USER2, PASS2)
        item = add_item()
        favorite = add_favorite(user2, item)
        user_path = 'favorites/{}'.format(str(favorite.uuid))
        resp = open_with_auth(self.app, API_ENDPOINT.format(user_path),
                              'DELETE', user1.email, PASS1, None, None)

        assert resp.status_code == NOT_FOUND
        assert Favorite.select().count() == 1