コード例 #1
0
ファイル: test_request.py プロジェクト: willrogers/pymalcolm
 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)
コード例 #2
0
ファイル: wsservercomms.py プロジェクト: willrogers/pymalcolm
    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)
コード例 #3
0
ファイル: wsservercomms.py プロジェクト: willrogers/pymalcolm
    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)
コード例 #4
0
 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)