Browse Source

move cachebusters names to constants.py

Rafał Pitoń 8 years ago
parent
commit
c247c48b81

+ 0 - 1
misago/acl/__init__.py

@@ -1,4 +1,3 @@
 from .api import get_user_acl, add_acl, serialize_acl
 
-
 default_app_config = 'misago.acl.apps.MisagoACLsConfig'

+ 1 - 0
misago/acl/constants.py

@@ -0,0 +1 @@
+ACL_CACHEBUSTER = 'misago_acl'

+ 3 - 1
misago/acl/migrations/0002_acl_version_tracker.py

@@ -6,9 +6,11 @@ from django.db import migrations, models
 
 from misago.core.migrationutils import cachebuster_register_cache
 
+from misago.acl.constants import ACL_CACHEBUSTER
+
 
 def register_acl_version_tracker(apps, schema_editor):
-    cachebuster_register_cache(apps, 'misago_acl')
+    cachebuster_register_cache(apps, ACL_CACHEBUSTER)
 
 
 class Migration(migrations.Migration):

+ 8 - 2
misago/acl/tests/test_api.py

@@ -1,14 +1,20 @@
+from django.contrib.auth import get_user_model
 from django.test import TestCase
 
-from misago.users.models import AnonymousUser, User
+from misago.users.models import AnonymousUser
 
 from ..api import get_user_acl
 
 
+UserModel = get_user_model()
+
+
 class GetUserACLTests(TestCase):
     def test_get_authenticated_acl(self):
         """get ACL for authenticated user"""
-        test_user = User.objects.create_user('Bob', 'bob@bob.com', 'pass123')
+        test_user = UserModel.objects.create_user(
+            'Bob', 'bob@bob.com', 'pass123')
+
         acl = get_user_acl(test_user)
 
         self.assertTrue(acl)

+ 6 - 6
misago/acl/tests/test_providers.py

@@ -67,20 +67,20 @@ class PermissionProvidersTests(TestCase):
         """its possible to register and get annotators"""
         providers = PermissionProviders()
 
-        def test_annotator(*args):
+        def mock_annotator(*args):
             pass
 
-        providers.acl_annotator(TestType, test_annotator)
+        providers.acl_annotator(TestType, mock_annotator)
         annotators_list = providers.get_type_annotators(TestType())
-        self.assertEqual(annotators_list[0], test_annotator)
+        self.assertEqual(annotators_list[0], mock_annotator)
 
     def test_serializers(self):
         """its possible to register and get annotators"""
         providers = PermissionProviders()
 
-        def test_serializer(*args):
+        def mock_serializer(*args):
             pass
 
-        providers.acl_serializer(TestType, test_serializer)
+        providers.acl_serializer(TestType, mock_serializer)
         serializers_list = providers.get_type_serializers(TestType())
-        self.assertEqual(serializers_list[0], test_serializer)
+        self.assertEqual(serializers_list[0], mock_serializer)

+ 5 - 6
misago/acl/version.py

@@ -1,16 +1,15 @@
-from misago.core import cachebuster as cb
+from misago.core import cachebuster
 
-
-ACL_CACHE_NAME = 'misago_acl'
+from .constants import ACL_CACHEBUSTER
 
 
 def get_version():
-    return cb.get_version(ACL_CACHE_NAME)
+    return cachebuster.get_version(ACL_CACHEBUSTER)
 
 
 def is_valid(version):
-    return cb.is_valid(ACL_CACHE_NAME, version)
+    return cachebuster.is_valid(ACL_CACHEBUSTER, version)
 
 
 def invalidate():
-    cb.invalidate(ACL_CACHE_NAME)
+    cachebuster.invalidate(ACL_CACHEBUSTER)

+ 9 - 9
misago/core/tests/test_apipatch.py

@@ -21,40 +21,40 @@ class ApiPatchTests(TestCase):
         """add method adds function to patch object"""
         patch = ApiPatch()
 
-        def test_function():
+        def mock_function():
             pass
-        patch.add('test-add', test_function)
+        patch.add('test-add', mock_function)
 
         self.assertEqual(len(patch._actions), 1)
         self.assertEqual(patch._actions[0]['op'], 'add')
         self.assertEqual(patch._actions[0]['path'], 'test-add')
-        self.assertEqual(patch._actions[0]['handler'], test_function)
+        self.assertEqual(patch._actions[0]['handler'], mock_function)
 
     def test_remove(self):
         """remove method adds function to patch object"""
         patch = ApiPatch()
 
-        def test_function():
+        def mock_function():
             pass
-        patch.remove('test-remove', test_function)
+        patch.remove('test-remove', mock_function)
 
         self.assertEqual(len(patch._actions), 1)
         self.assertEqual(patch._actions[0]['op'], 'remove')
         self.assertEqual(patch._actions[0]['path'], 'test-remove')
-        self.assertEqual(patch._actions[0]['handler'], test_function)
+        self.assertEqual(patch._actions[0]['handler'], mock_function)
 
     def test_replace(self):
         """replace method adds function to patch object"""
         patch = ApiPatch()
 
-        def test_function():
+        def mock_function():
             pass
-        patch.replace('test-replace', test_function)
+        patch.replace('test-replace', mock_function)
 
         self.assertEqual(len(patch._actions), 1)
         self.assertEqual(patch._actions[0]['op'], 'replace')
         self.assertEqual(patch._actions[0]['path'], 'test-replace')
-        self.assertEqual(patch._actions[0]['handler'], test_function)
+        self.assertEqual(patch._actions[0]['handler'], mock_function)
 
     def test_validate_action(self):
         """validate_action method validates action dict"""