From e59491c25cd167238239b337afdf0a3814f9a029 Mon Sep 17 00:00:00 2001 From: hellmanj Date: Thu, 22 Jan 2015 15:22:56 -0500 Subject: [PATCH] add exception when _resolve_url gets a template but no arguments to resolve it instead of trying to open the unresolved template --- robotpageobjects/base.py | 3 +++ tests/test_unit.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/robotpageobjects/base.py b/robotpageobjects/base.py index 509d2d5..4180a07 100755 --- a/robotpageobjects/base.py +++ b/robotpageobjects/base.py @@ -678,6 +678,9 @@ def _resolve_url(self, *args): self.uri_vars = uri_vars return uritemplate.expand(self.baseurl + self.uri, uri_vars) else: + if uri_type == 'template': + raise exceptions.UriResolutionError('%s has uri template %s , but no arguments were given to resolve it' % + (pageobj_name, self.uri)) # the user wants to open the default uri return self.baseurl + self.uri diff --git a/tests/test_unit.py b/tests/test_unit.py index 196c70c..4c667ea 100755 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -250,6 +250,14 @@ def test_too_many_vars_passed_to_uri_template_in_robot(self): po._is_robot = True po._resolve_url("pid=foo", "bar=baz") + @raises(exceptions.UriResolutionError) + def test_no_vars_passed_to_uri_template(self): + """There is a template but no variables are possed in.""" + + self.set_baseurl_env(base_file=False, arbitrary_base="http://www.ncbi.nlm.nih.gov") + self.PO.uri_template = "/pubmed/{pid}" + self.PO()._resolve_url() + @raises(exceptions.UriResolutionError) def test_wrong_var_name_in_robot(self): self.set_baseurl_env()