aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2013-04-19 16:28:41 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2013-04-19 16:28:41 -0500
commita0e7699a45582d475d293350bcd2ba10ec5a8c43 (patch)
tree47036a30de54ba94680f74e78d3cceb41c822fd4
parent234ddad607fa8d38e01c9ff1386fc32427c99d8f (diff)
downloadmediagoblin-a0e7699a45582d475d293350bcd2ba10ec5a8c43.tar.lz
mediagoblin-a0e7699a45582d475d293350bcd2ba10ec5a8c43.tar.xz
mediagoblin-a0e7699a45582d475d293350bcd2ba10ec5a8c43.zip
Added new tests to test hook_transform()
-rw-r--r--mediagoblin/tests/test_pluginapi.py21
-rw-r--r--mediagoblin/tests/testplugins/callables1/__init__.py8
-rw-r--r--mediagoblin/tests/testplugins/callables2/__init__.py3
-rw-r--r--mediagoblin/tests/testplugins/callables3/__init__.py3
4 files changed, 32 insertions, 3 deletions
diff --git a/mediagoblin/tests/test_pluginapi.py b/mediagoblin/tests/test_pluginapi.py
index dbc4b7c8..4bbb9de4 100644
--- a/mediagoblin/tests/test_pluginapi.py
+++ b/mediagoblin/tests/test_pluginapi.py
@@ -284,3 +284,24 @@ def test_hook_runall():
"Hi, I'm the third"]
+@with_cleanup()
+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', {}, []),
+ ])
+ ])
+
+ mg_globals.app_config = cfg['mediagoblin']
+ mg_globals.global_config = cfg
+
+ setup_plugins()
+
+ assert pluginapi.hook_transform(
+ "expand_tuple", (-1, 0)) == (-1, 0, 1, 2, 3)
diff --git a/mediagoblin/tests/testplugins/callables1/__init__.py b/mediagoblin/tests/testplugins/callables1/__init__.py
index 9c278b49..260a2078 100644
--- a/mediagoblin/tests/testplugins/callables1/__init__.py
+++ b/mediagoblin/tests/testplugins/callables1/__init__.py
@@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from mediagoblin.tools.pluginapi import CantHandleIt
-
def setup_plugin():
pass
@@ -30,12 +28,16 @@ def multi_handle(call_log):
return "the first returns"
def multi_handle_with_canthandle(call_log):
- raise CantHandleIt("I just can't accept this stupid method")
+ return None
+
+def expand_tuple(tuple):
+ return tuple + (1,)
hooks = {
'setup': setup_plugin,
'just_one': just_one,
'multi_handle': multi_handle,
'multi_handle_with_canthandle': multi_handle_with_canthandle,
+ 'expand_tuple': expand_tuple,
}
diff --git a/mediagoblin/tests/testplugins/callables2/__init__.py b/mediagoblin/tests/testplugins/callables2/__init__.py
index aaab5b21..9d5cf950 100644
--- a/mediagoblin/tests/testplugins/callables2/__init__.py
+++ b/mediagoblin/tests/testplugins/callables2/__init__.py
@@ -29,10 +29,13 @@ def multi_handle_with_canthandle(call_log):
call_log.append("Hi, I'm the second")
return "the second returns"
+def expand_tuple(this_tuple):
+ return this_tuple + (2,)
hooks = {
'setup': setup_plugin,
'just_one': just_one,
'multi_handle': multi_handle,
'multi_handle_with_canthandle': multi_handle_with_canthandle,
+ 'expand_tuple': expand_tuple,
}
diff --git a/mediagoblin/tests/testplugins/callables3/__init__.py b/mediagoblin/tests/testplugins/callables3/__init__.py
index 8d0c9c25..04efc8fc 100644
--- a/mediagoblin/tests/testplugins/callables3/__init__.py
+++ b/mediagoblin/tests/testplugins/callables3/__init__.py
@@ -29,10 +29,13 @@ def multi_handle_with_canthandle(call_log):
call_log.append("Hi, I'm the third")
return "the third returns"
+def expand_tuple(this_tuple):
+ return this_tuple + (3,)
hooks = {
'setup': setup_plugin,
'just_one': just_one,
'multi_handle': multi_handle,
'multi_handle_with_canthandle': multi_handle_with_canthandle,
+ 'expand_tuple': expand_tuple,
}