-# -*- 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.
#
'/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',
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):
['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/'),
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"<epub>")):
self.assertEqual(
self.signed('/api/epub/grandchild/').content,
b"<epub>")
+ Book.objects.filter(slug='grandchild').update(preview=False)
+
def test_publish(self):
response = self.signed('/api/books/',
method='POST',