Author: rjollos
Date: Tue Jul 16 23:02:37 2013
New Revision: 1503938
URL: http://svn.apache.org/r1503938
Log:
Added additional unit tests for `ProductizedHref`. Refs #579.
Modified:
bloodhound/trunk/bloodhound_multiproduct/tests/hooks.py
Modified: bloodhound/trunk/bloodhound_multiproduct/tests/hooks.py
URL:
http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_multiproduct/tests/hooks.py?rev=1503938&r1=1503937&r2=1503938&view=diff
==============================================================================
--- bloodhound/trunk/bloodhound_multiproduct/tests/hooks.py (original)
+++ bloodhound/trunk/bloodhound_multiproduct/tests/hooks.py Tue Jul 16 23:02:37
2013
@@ -30,12 +30,39 @@ from multiproduct.hooks import Productiz
class ProductizedHrefTestCase(unittest.TestCase):
- def test_params_is_dictionary(self):
- ghref = Href('/base')
- phref = ProductizedHref(ghref, '/product')
- self.assertIn(phref({'param': 'value', 'other': 'other value'}),
- ['/product?param=value&other=other+value',
- '/product?other=other+value¶m=value'])
+ def setUp(self):
+ self.ghref = Href('/gbase')
+ self.phref = ProductizedHref(self.ghref, '/gbase/product')
+
+ def test_paths_no_transform(self):
+ self.assertEqual('/gbase/admin', self.phref.admin())
+ self.assertEqual('/gbase/logout', self.phref.logout())
+ self.assertEqual('/gbase/prefs', self.phref('prefs'))
+ self.assertEqual('/gbase/verify_email?a=1&b=cde',
+ self.phref('verify_email', a=1, b='cde'))
+
+ def test_static_path_no_transform(self):
+ self.assertEqual('/gbase/js', self.phref('js/'))
+ self.assertEqual('/gbase/css', self.phref('css/'))
+ self.assertEqual('/gbase/img', self.phref('img/'))
+
+ def test_params_as_args(self):
+ self.assertEqual('/gbase/product/ticket/540',
+ self.phref('ticket', 540))
+ self.assertEqual('/gbase/product/ticket/540',
+ self.phref.ticket(540))
+
+ def test_params_as_kwargs(self):
+ self.assertIn(self.phref('ticket', param='value',
+ other='other value'),
+ ['/gbase/product/ticket?param=value&other=other+value',
+ '/gbase/product/ticket?other=other+value¶m=value'])
+
+ def test_params_as_dictionary(self):
+ self.assertIn(self.phref.ticket({'param': 'value',
+ 'other': 'other value'}),
+ ['/gbase/product/ticket/?param=value&other=other+value',
+ '/gbase/product/ticket?other=other+value¶m=value'])
def test_suite():