示例#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)
    def test_wait_response(self):
        exact_result = "test_result"
        exact_id = 1
        reply_queue = self.reply_queue
        pm = haplib.ParsedMessage()
        pm.message_dict = {"id": exact_id, "result": exact_result}
        pm.message_id = exact_id
        reply_queue.put(pm)
        wait_response = common.returnPrivObj(self.processor, "__wait_response")
        output = wait_response(exact_id)

        self.assertEquals(output, exact_result)
    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 = common.returnPrivObj(self.__dispatcher, "__acknowledge")
        test_message = (test_id, test_contents.message_id)
        acknowledge(test_message)

        test_message = (test_id, test_contents)
        dispatch_queue = common.returnPrivObj(self.__dispatcher,
                                              "__dispatch_queue")
        dispatch_queue.put(test_message)

        common.assertNotRaises(acknowledge, test_message)
        dispatch = common.returnPrivObj(self.__dispatcher, "__dispatch")
        common.assertNotRaises(dispatch)
示例#4
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)
示例#5
0
 def get(self, boolean, timeout_sec):
     if self.counter == 0:
         self.counter += 1
         return True
     elif self.counter == 1:
         return haplib.ParsedMessage()
示例#6
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())
示例#7
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)