2018-05-09 18:42:50 +00:00
|
|
|
from tests import BaseTestCase
|
2019-03-27 15:24:15 +00:00
|
|
|
|
2018-05-09 18:42:50 +00:00
|
|
|
|
|
|
|
class TestQueryFavoriteResource(BaseTestCase):
|
|
|
|
def test_favorite(self):
|
|
|
|
query = self.factory.create_query()
|
|
|
|
|
|
|
|
rv = self.make_request('post', '/api/queries/{}/favorite'.format(query.id))
|
|
|
|
self.assertEqual(rv.status_code, 200)
|
|
|
|
|
|
|
|
rv = self.make_request('get', '/api/queries/{}'.format(query.id))
|
|
|
|
self.assertEqual(rv.json['is_favorite'], True)
|
2018-09-16 06:43:44 +00:00
|
|
|
|
2018-07-11 13:35:48 +00:00
|
|
|
def test_duplicate_favorite(self):
|
|
|
|
query = self.factory.create_query()
|
|
|
|
|
|
|
|
rv = self.make_request('post', '/api/queries/{}/favorite'.format(query.id))
|
|
|
|
self.assertEqual(rv.status_code, 200)
|
|
|
|
|
|
|
|
rv = self.make_request('post', '/api/queries/{}/favorite'.format(query.id))
|
|
|
|
self.assertEqual(rv.status_code, 200)
|
|
|
|
|
2018-05-09 18:42:50 +00:00
|
|
|
def test_unfavorite(self):
|
|
|
|
query = self.factory.create_query()
|
|
|
|
rv = self.make_request('post', '/api/queries/{}/favorite'.format(query.id))
|
|
|
|
rv = self.make_request('delete', '/api/queries/{}/favorite'.format(query.id))
|
|
|
|
self.assertEqual(rv.status_code, 200)
|
|
|
|
|
|
|
|
rv = self.make_request('get', '/api/queries/{}'.format(query.id))
|
|
|
|
self.assertEqual(rv.json['is_favorite'], False)
|
|
|
|
|
2018-09-16 06:43:44 +00:00
|
|
|
|
2018-05-09 18:42:50 +00:00
|
|
|
class TestQueryFavoriteListResource(BaseTestCase):
|
|
|
|
def test_get_favorites(self):
|
|
|
|
rv = self.make_request('get', '/api/queries/favorites')
|
2018-09-16 06:43:44 +00:00
|
|
|
self.assertEqual(rv.status_code, 200)
|