Some cleaning.
[wolnelektury.git] / apps / api / tests.py
index 74417ac..87c4f75 100644 (file)
@@ -1,30 +1,29 @@
 # -*- 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.
+#
+from os import path
 
-from datetime import datetime
-
+from django.core.files.uploadedfile import SimpleUploadedFile
 from django.test import TestCase
-from django.utils import simplejson as json
-from django.conf import settings
+from django.test.utils import override_settings
+import json
 
-from api.helpers import timestamp
 from catalogue.models import Book, Tag
-from picture.tests.utils import RequestFactory
 from picture.forms import PictureImportForm
 from picture.models import Picture
 import picture.tests
-from django.core.files.uploadedfile import SimpleUploadedFile
-from os import path
 
 
+@override_settings(
+    API_WAIT=-1,
+    NO_SEARCH_INDEX = True,
+    CACHES = {'api': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'},
+              'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'},
+              'permanent': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}}
+)
 class ApiTest(TestCase):
-
-    def setUp(self):
-        self.old_api_wait = settings.API_WAIT
-        settings.API_WAIT = -1
-
-    def tearDown(self):
-        settings.API_WAIT = self.old_api_wait
+    pass
 
 
 class ChangesTest(ApiTest):
@@ -37,10 +36,10 @@ class ChangesTest(ApiTest):
         book.save()
 
         changes = json.loads(self.client.get('/api/changes/0.json?book_fields=title&tag_fields=name').content)
-        self.assertEqual(changes['updated']['books'], 
+        self.assertEqual(changes['updated']['books'],
                          [{'id': book.id, 'title': book.title}],
                          'Invalid book format in changes')
-        self.assertEqual(changes['updated']['tags'], 
+        self.assertEqual(changes['updated']['tags'],
                          [{'id': tag.id, 'name': tag.name}],
                          'Invalid tag format in changes')
 
@@ -159,4 +158,4 @@ class PictureTests(ApiTest):
         if import_form.is_valid():
             import_form.save()
 
-        pic = Picture.objects.get(slug=slug)
+        Picture.objects.get(slug=slug)