X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/967eed676fc83d15b26149047f353ac61faa8217..4e361d55331351f56077e5f9999ecb4ee7e93819:/src/api/tests/tests.py diff --git a/src/api/tests/tests.py b/src/api/tests/tests.py index eccdd04a8..993a52409 100644 --- a/src/api/tests/tests.py +++ b/src/api/tests/tests.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # @@ -178,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', @@ -232,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): @@ -437,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/'), @@ -445,17 +444,18 @@ class AuthorizedTests(ApiTest): self.signed('/api/epub/grandchild/').status_code, 403) - with patch('api.fields.user_is_subscribed', return_value=True): + with patch('club.models.Membership.is_active_for', return_value=True): self.assertEqual( self.signed_json('/api/username/'), {"username": "test", "premium": True}) - with patch('paypal.permissions.user_is_subscribed', return_value=True): with patch('django.core.files.storage.Storage.open', return_value=BytesIO(b"")): self.assertEqual( 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',