diff options
| author | Chris McDonough <chrism@plope.com> | 2011-08-06 19:10:42 -0400 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2011-08-06 19:10:42 -0400 |
| commit | fc38f448d9b35d18f0b7d687efc659e1a2b8ec7c (patch) | |
| tree | 383f33872f72f885fd2b11460811a7fdacd34333 | |
| parent | 1311321d454ded6226b09f929ebc9e4aa2c12771 (diff) | |
| download | pyramid-fc38f448d9b35d18f0b7d687efc659e1a2b8ec7c.tar.gz pyramid-fc38f448d9b35d18f0b7d687efc659e1a2b8ec7c.tar.bz2 pyramid-fc38f448d9b35d18f0b7d687efc659e1a2b8ec7c.zip | |
write tests for ptweens
| -rw-r--r-- | pyramid/tests/test_paster.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/pyramid/tests/test_paster.py b/pyramid/tests/test_paster.py index 3cf249c5c..58ed73d2c 100644 --- a/pyramid/tests/test_paster.py +++ b/pyramid/tests/test_paster.py @@ -824,6 +824,79 @@ class TestBootstrap(unittest.TestCase): self.assertEqual(result['root'], self.root) self.assert_('closer' in result) +class TestPTweensCommand(unittest.TestCase): + def _getTargetClass(self): + from pyramid.paster import PTweensCommand + return PTweensCommand + + def _makeOne(self): + cmd = self._getTargetClass()('ptweens') + cmd.bootstrap = (DummyBootstrap(),) + cmd.args = ('/foo/bar/myapp.ini#myapp',) + return cmd + + def test_command_no_tweens(self): + command = self._makeOne() + command._get_tweens = lambda *arg: None + L = [] + command.out = L.append + result = command.command() + self.assertEqual(result, None) + self.assertEqual(L, []) + + def test_command_implicit_tweens_only(self): + command = self._makeOne() + tweens = DummyTweens([('name', 'item')], None) + command._get_tweens = lambda *arg: tweens + L = [] + command.out = L.append + result = command.command() + self.assertEqual(result, None) + self.assertEqual( + L, + ['"pyramid.tweens" config value NOT set (implicitly ordered tweens used)', + '', + 'Position Name ', + '-------- ---- ', + '0 name ', + '']) + + def test_command_implicit_and_explicit_tweens(self): + command = self._makeOne() + tweens = DummyTweens([('name', 'item')], [('name2', 'item2')]) + command._get_tweens = lambda *arg: tweens + L = [] + command.out = L.append + result = command.command() + self.assertEqual(result, None) + self.assertEqual( + L, + ['"pyramid.tweens" config value set (explicitly ordered tweens used)', + '', + 'Explicit Tween Chain (used)', + '', + 'Position Name ', + '-------- ---- ', + '0 name2 ', + '', + 'Implicit Tween Chain (not used)', + '', + 'Position Name ', + '-------- ---- ', + '0 name ', + '' + ]) + + def test__get_tweens(self): + command = self._makeOne() + registry = DummyRegistry() + self.assertEqual(command._get_tweens(registry), None) + +class DummyTweens(object): + def __init__(self, implicit, explicit): + self.implicit = implicit + self.explicit = explicit + class Dummy: pass |
