Refactor test configs.
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Fri, 19 Apr 2013 22:24:09 +0000 (00:24 +0200)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Fri, 19 Apr 2013 22:24:09 +0000 (00:24 +0200)
All the hook_* tests use the same config, so refactor it.

mediagoblin/tests/test_pluginapi.py

index 4bbb9de4daafb4ad9ee1c2e57e94aab6a9955e07..f03e868f4eaf76a1fdce915e94cec7ec57ea8e35 100644 (file)
@@ -177,19 +177,22 @@ def test_disabled_plugin():
     assert len(pman.plugins) == 0
 
 
+CONFIG_ALL_CALLABLES = [
+        ('mediagoblin', {}, []),
+        ('plugins', {}, [
+                ('mediagoblin.tests.testplugins.callables1', {}, []),
+                ('mediagoblin.tests.testplugins.callables2', {}, []),
+                ('mediagoblin.tests.testplugins.callables3', {}, []),
+            ])
+    ]
+
+
 @with_cleanup()
 def test_hook_handle():
     """
     Test the hook_handle method
     """
-    cfg = build_config([
-            ('mediagoblin', {}, []),
-            ('plugins', {}, [
-                    ('mediagoblin.tests.testplugins.callables1', {}, []),
-                    ('mediagoblin.tests.testplugins.callables2', {}, []),
-                    ('mediagoblin.tests.testplugins.callables3', {}, []),
-                    ])
-            ])
+    cfg = build_config(CONFIG_ALL_CALLABLES)
 
     mg_globals.app_config = cfg['mediagoblin']
     mg_globals.global_config = cfg
@@ -233,14 +236,7 @@ def test_hook_runall():
     """
     Test the hook_runall method
     """
-    cfg = build_config([
-            ('mediagoblin', {}, []),
-            ('plugins', {}, [
-                    ('mediagoblin.tests.testplugins.callables1', {}, []),
-                    ('mediagoblin.tests.testplugins.callables2', {}, []),
-                    ('mediagoblin.tests.testplugins.callables3', {}, []),
-                    ])
-            ])
+    cfg = build_config(CONFIG_ALL_CALLABLES)
 
     mg_globals.app_config = cfg['mediagoblin']
     mg_globals.global_config = cfg
@@ -289,14 +285,7 @@ def test_hook_transform():
     """
     Test the hook_transform method
     """
-    cfg = build_config([
-            ('mediagoblin', {}, []),
-            ('plugins', {}, [
-                    ('mediagoblin.tests.testplugins.callables1', {}, []),
-                    ('mediagoblin.tests.testplugins.callables2', {}, []),
-                    ('mediagoblin.tests.testplugins.callables3', {}, []),
-                    ])
-            ])
+    cfg = build_config(CONFIG_ALL_CALLABLES)
 
     mg_globals.app_config = cfg['mediagoblin']
     mg_globals.global_config = cfg