Ejemplo n.º 1
0
 def test_wait_response(self):
     hapiproc = self.__create_test_instance()
     test_result = "test_result"
     test_id = 1
     pm = haplib.ParsedMessage()
     pm.message_dict = {"id": test_id, "result": test_result}
     pm.message_id = test_id
     hapiproc.get_reply_queue().put(pm)
     wait_response = testutils.get_priv_attr(hapiproc, "__wait_response")
     self.assertEquals(wait_response(test_id), test_result)
Ejemplo n.º 2
0
    def test_dispatch_receive_response(self):
        destination_queue = DummyQueue()
        test_id = "test"
        test_contents = haplib.ParsedMessage()
        test_contents.message_id = 1

        self.__dispatcher.attach_destination(destination_queue, test_id)
        acknowledge = testutils.get_priv_attr(self.__dispatcher,
                                              "__acknowledge")
        test_message = (test_id, test_contents.message_id)
        acknowledge(test_message)

        test_message = (test_id, test_contents)
        dispatch_queue = testutils.get_priv_attr(self.__dispatcher,
                                                 "__dispatch_queue")
        dispatch_queue.put(test_message)

        testutils.assertNotRaises(acknowledge, test_message)
        dispatch = testutils.get_priv_attr(self.__dispatcher, "__dispatch")
        testutils.assertNotRaises(dispatch)
Ejemplo n.º 3
0
    def call(self, msg):
        response_id = json.loads(msg)["id"]
        if self.__ms_flag:
            result = {
                "extendedInfo": "exampleExtraInfo",
                "serverId": 0,
                "url": "http://example.com:80",
                "type": 0,
                "nickName": "exampleName",
                "userName": "******",
                "password": "******",
                "pollingIntervalSec": 30,
                "retryIntervalSec": 10
            }
        else:
            result = "SUCCESS"

        pm = haplib.ParsedMessage()
        pm.message_dict = {"result": result, "id": response_id}
        pm.message_id = response_id
        self.__test_queue.put(pm)
Ejemplo n.º 4
0
 def get(self, boolean, timeout_sec):
     if self.counter == 0:
         self.counter += 1
         return True
     elif self.counter == 1:
         return haplib.ParsedMessage()
Ejemplo n.º 5
0
 def test_get_error_message(self):
     pm = haplib.ParsedMessage()
     actual = "error code: None, message ID: None, error message: "
     self.assertEquals(actual, pm.get_error_message())
Ejemplo n.º 6
0
 def test_create(self):
     pm = haplib.ParsedMessage()
     self.assertIsNone(pm.error_code)
     self.assertIsNone(pm.message_id)
     self.assertIsNone(pm.message_dict)
     self.assertEquals("", pm.error_message)