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()