Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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"
Пример #4
0
 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
Пример #5
0
 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"]
Пример #6
0
 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
Пример #7
0
 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())