Remove hotjar.
[wolnelektury.git] / src / api / tests / tests.py
index c37fef3..e17db29 100644 (file)
@@ -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"<epub>")
 
+        Book.objects.filter(slug='grandchild').update(preview=False)
+
     def test_publish(self):
         response = self.signed('/api/books/',
                                method='POST',