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