def test1_param_json_marshal(self): "request param is correctly marshalled to JSON" context = self.parsed["contexts"][self.opspec["context"]] parametrize(self.opspec, context=context) marshal_request_params(self.opspec, self.parsed.get("defaults", {})) result = self.opspec["request"]["params"]["note"] assert self.opspec["request"]["params"]["note"] == result
def test1_explicit_parametrization(self): "data structure is correctly parametrized" testopname = "add-reservation" testop = self._get_expanded_testop(testopname) testcontext = {"customers": ["John Doe", "Jane Doe"], "size": "double"} parametrize(testop, context=testcontext) result = testop["request"]["body"]["value"] assert testop["request"]["body"]["value"] == testcontext
def test5_parametrize_access_listelement(self): "$param/0 works" testopname = "list-rooms" testop = self._get_expanded_testop(testopname) testop["request"]["params"]["testparam"] = "$customers/0" testcontext = {"customers": ["John Doe", "Jane Doe"], "size": "double"} parametrize(testop, context=testcontext) assert testop["request"]["params"]["testparam"] == "John Doe"
def test6_parametrize_access_mapelement(self): "$param/name works; note that 'name' must not contain whitespaces" testopname = "list-rooms" testop = self._get_expanded_testop(testopname) testop["request"]["params"]["testparam"] = "$customers/JohnDoe" testcontext = { "customers": { "JohnDoe": True, "Jane Doe": False }, "size": "double" } parametrize(testop, context=testcontext) assert testop["request"]["params"]["testparam"] == True
def test3_parametrize_partially_from_static_context_nofail(self): "can handle partial parametrization from larger static context" testopname = "list-doublerooms" testop = self._get_expanded_testop(testopname) testcontext = self.contexts[testop["context"]] parametrized = parametrize(testop, context=testcontext) assert parametrized["request"]["params"]["size"] == testcontext["size"]
def test2_parametrize_from_static_context(self): "data structure is correctly parametrized from context embedded in API" testopname = "add-reservation" testop = self._get_expanded_testop(testopname) testcontext = self.contexts[testop["context"]] parametrized = parametrize(testop, context=testcontext) assert parametrized["request"]["body"]["value"] == testcontext
def test4_parametrize_two_variables(self): "can replace $name1 $name2" testopname = "add-note" testop = self._get_expanded_testop(testopname) testcontext = self.contexts[testop["context"]] parametrized = parametrize(testop, context=testcontext) assert parametrized["request"]["body"] == " ".join( testcontext.values())