def test_resolve(self): """ Assert we can resolve a well formed type_name, link_name, and params """ resolver = MsgTypeToUrlLinkResolver(self.resolver_maps_config) resolve_params = { 'param1': 'foo', 'param2': 'bar', } url = resolver.resolve( 'test-type.type-with-links', '_click_link', resolve_params ) self.assertEqual(url, '/path/to/foo/url/bar') # now see if first wildcard properly resolves url = resolver.resolve( 'test-type.different', '_click_link', resolve_params ) self.assertEqual(url, '/parent/foo') # now see if the global wildcard resolves url = resolver.resolve( 'only-match-at-root', '_click_link', resolve_params ) self.assertEqual(url, '/root')
def test_resolve(self): """ Assert we can resolve a well formed type_name, link_name, and params """ resolver = MsgTypeToUrlLinkResolver(self.resolver_maps_config) resolve_params = { 'param1': 'foo', 'param2': 'bar', } url = resolver.resolve( 'test-type.type-with-links', '_click_link', resolve_params ) self.assertEqual(url, '/path/to/foo/url/bar') # now see if first wildcard properly resolves url = resolver.resolve( 'test-type.different', '_click_link', resolve_params ) self.assertEqual(url, '/parent/foo') # now see if the global wildcard resolves url = resolver.resolve( 'only-match-at-root', '_click_link', resolve_params ) self.assertEqual(url, '/root')
def test_missing_formatting_param(self): """ Failure case wheen the msg_type cannot be found """ resolver = MsgTypeToUrlLinkResolver({ '_click_link': { # this will conver msg type 'test-type.type-with-links' # to /path/to/{param1}/url/{param2} with param subsitutations # that are passed in with the message 'test-type.type-with-links': '/path/to/{param1}/url/{param2}' } }) url = resolver.resolve('test-type.type-with-links', '_click_link', { 'param1': 'foo', }) self.assertIsNone(url)
def test_missing_formatting_param(self): """ Failure case wheen the msg_type cannot be found """ resolver = MsgTypeToUrlLinkResolver({ '_click_link': { # this will conver msg type 'test-type.type-with-links' # to /path/to/{param1}/url/{param2} with param subsitutations # that are passed in with the message 'test-type.type-with-links': '/path/to/{param1}/url/{param2}' } }) url = resolver.resolve( 'test-type.type-with-links', '_click_link', { 'param1': 'foo', } ) self.assertIsNone(url)