def test_unmarshall(self): field = InlineObject(schema=IInlineExample) request = WebServiceTestRequest() request.setVirtualHostRoot(names=["devel"]) marshaller = InlineObjectFieldMarshaller(field, request) obj = InlineExample(self.factory.makePerson(), JobStatus.WAITING) result = marshaller.unmarshall(None, obj) self.assertThat( result, MatchesDict({ "person_link": Equals(canonical_url(obj.person, request=request)), "status": Equals("Waiting"), }))
def test_marshall_from_json_data(self): self.useFixture(ZopeAdapterFixture(inline_example_from_dict)) field = InlineObject(schema=IInlineExample) request = WebServiceTestRequest() request.setVirtualHostRoot(names=["devel"]) marshaller = InlineObjectFieldMarshaller(field, request) person = self.factory.makePerson() data = { "person_link": canonical_url(person, request=request), "status": "Running", } obj = marshaller.marshall_from_json_data(data) self.assertThat( obj, MatchesStructure.byEquality(person=person, status=JobStatus.RUNNING))