X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/3fceb197b7f492cf5cfcb4034b6e045638f128d4..de25649c03f4d7d476bf8764ba8671681bfd6324:/src/api/tests/tests.py diff --git a/src/api/tests/tests.py b/src/api/tests/tests.py index c37fef33b..e17db29c7 100644 --- a/src/api/tests/tests.py +++ b/src/api/tests/tests.py @@ -177,12 +177,15 @@ class BooksTests(ApiTest): '/api/filter-books/?lektura=true', []) - self.assert_slugs( - '/api/filter-books/?preview=true', - ['grandchild']) + Book.objects.filter(slug='grandchild').update(preview=True) + # Skipping: we don't allow previewed books in filtered list. + #self.assert_slugs( + # '/api/filter-books/?preview=true', + # ['grandchild']) self.assert_slugs( '/api/filter-books/?preview=false', ['child', 'parent']) + Book.objects.filter(slug='grandchild').update(preview=False) self.assert_slugs( '/api/filter-books/?audiobook=true', @@ -231,11 +234,6 @@ class BlogTests(ApiTest): self.assertEqual(self.load_json('/api/blog'), []) -class PreviewTests(ApiTest): - def unauth(self): - self.assert_json_response('/api/preview/', 'preview.json') - - class OAuth1Tests(ApiTest): @classmethod def setUpClass(cls): @@ -304,8 +302,8 @@ class OAuth1Tests(ApiTest): ).digest() h = b64encode(h).rstrip(b'\n') sign = quote(h) - query = u"{}&oauth_signature={}".format(base_query, sign) - response = self.client.get(u'/api/oauth/access_token/?' + query) + query = "{}&oauth_signature={}".format(base_query, sign) + response = self.client.get('/api/oauth/access_token/?' + query) access_token_data = parse_qs(response.content.decode('latin1')) access_token = access_token_data['oauth_token'][0] @@ -436,6 +434,8 @@ class AuthorizedTests(ApiTest): ['parent']) def test_subscription(self): + Book.objects.filter(slug='grandchild').update(preview=True) + self.assert_slugs('/api/preview/', ['grandchild']) self.assertEqual( self.signed_json('/api/username/'), @@ -454,6 +454,8 @@ class AuthorizedTests(ApiTest): self.signed('/api/epub/grandchild/').content, b"") + Book.objects.filter(slug='grandchild').update(preview=False) + def test_publish(self): response = self.signed('/api/books/', method='POST',