def test_from_dict(self): serialized = {"id": 1, "type": "Put", "extra_1": "abc", "extra_2": {"field": "data"}} request = Request.from_dict(serialized) self.assertEquals(1, request.id_) self.assertEquals("Put", request.type_) self.assertEquals("abc", request.fields["extra_1"]) self.assertEquals({"field": "data"}, request.fields["extra_2"]) self.assertIsNone(request.context) self.assertIsNone(request.response_queue)
def on_message(self, message): """ Pass on received message to Process Args: message(str): Received message """ d = json.loads(message, object_pairs_hook=OrderedDict) request = Request.from_dict(d) request.context = self self.servercomms.on_request(request)
def test_from_dict(self): serialized = { "id": 1, "type": "Put", "extra_1": "abc", "extra_2": { "field": "data" } } request = Request.from_dict(serialized) self.assertEquals(1, request.id_) self.assertEquals("Put", request.type_) self.assertEquals("abc", request.fields["extra_1"]) self.assertEquals({"field": "data"}, request.fields["extra_2"]) self.assertIsNone(request.context) self.assertIsNone(request.response_queue)