示例#1
0
 def from_structure(structure):
     responses = []
     for response in structure.get("responses", ()):
         if "proxy" in response:
             responses.append(Proxy.from_structure(response))
         else:
             responses.append(Response.from_structure(response))
     return Stub(
         [
             Predicate.from_structure(predicate)
             for predicate in structure.get("predicates", ())
         ],
         responses,
     )
示例#2
0
 def from_structure(structure: JsonStructure) -> "Stub":
     responses: List[Union[Proxy, Response]] = []
     for response in structure.get("responses", ()):
         if "proxy" in response:
             responses.append(Proxy.from_structure(response))
         else:
             responses.append(Response.from_structure(response))
     return Stub(
         [
             Predicate.from_structure(predicate)
             for predicate in structure.get("predicates", ())
         ],
         responses,
     )
示例#3
0
文件: stubs.py 项目: brunns/mbtest
 def from_structure(cls, structure: JsonStructure) -> "Stub":
     responses: List[Union[InjectionResponse, Proxy, Response]] = []
     for response in structure.get("responses", ()):
         if "proxy" in response:
             responses.append(Proxy.from_structure(response))
         elif "inject" in response:
             responses.append(InjectionResponse.from_structure(response))
         else:
             responses.append(Response.from_structure(response))
     return cls(
         [
             BasePredicate.from_structure(predicate)
             for predicate in structure.get("predicates", ())
         ],
         responses,
     )