Пример #1
0
 def testsignal_resp_handler_remote_action(self):
     """
     Test to check the handling remote action method  with a response of the signal class.
     """
     sig_dict, signal = self.setup_vars_mocks()
     cbt = CBT()
     cbt.request.params = {"RecipientId": "1", "OverlayId": "A0FB389"}
     jid_cache = JidCache(signal, 5)
     jid_cache.add_entry("1", "2345")
     transport = XmppTransport.factory(
         "1", sig_dict["Signal"]["Overlays"]["A0FB389"], signal,
         signal._presence_publisher, None, None)
     transport.send_msg = MagicMock()
     signal._circles = {
         "A0FB389": {
             "JidCache": jid_cache,
             "Transport": transport
         }
     }
     cbt.tag = "1"
     signal.submit_cbt(cbt)
     resp = CBT.Response()
     cbt.response = resp
     rem_act = {"InitiatorId": "1", "OverlayId": "A0FB389"}
     signal._remote_acts["1"] = rem_act
     signal.submit_cbt(cbt)
     signal.transmit_remote_act = MagicMock()
     signal.free_cbt = MagicMock()
     signal.resp_handler_remote_action(cbt)
     signal.transmit_remote_act.assert_called_once()
     signal.free_cbt.assert_called_once()
     print("Passed : testsignal_resp_handler_remote_action")
Пример #2
0
 def testjid_cache_add_lookup_entry(self):
     """
     Test to check the lookup method of the jid-cache of the signal class.
     """
     sig_dict, signal = self.setup_vars_mocks()
     jid_cache = JidCache(signal, 30)
     jid_cache.add_entry("123", "2345")
     assert jid_cache.lookup("123") == "2345"
     print("Passed : testjid_cache_add_lookup_entry")
Пример #3
0
 def testjid_cache_scavenge(self):
     """
     Test to check the scavenge method of the jid-cache of the signal class.
     """
     sig_dict, signal = self.setup_vars_mocks()
     jid_cache = JidCache(signal, 5)
     jid_cache.add_entry("123", "2345")
     assert jid_cache.lookup("123") == "2345"
     sleep(5)
     jid_cache.scavenge()
     assert jid_cache.lookup("123") is None
     print("Passed : testjid_cache_scavenge")
Пример #4
0
 def testtransmit_remote_act(self):
     """
     Test to check the transmit remote action method of the signal class.
     """
     rem_act = {"InitiatorId": "1", "OverlayId": "A0FB389"}
     sig_dict, signal = self.setup_vars_mocks()
     jid_cache = JidCache(signal, 5)
     jid_cache.add_entry("1", "2345")
     transport = XmppTransport.factory(
         "1", sig_dict["Signal"]["Overlays"]["A0FB389"], signal,
         signal._presence_publisher, None, None)
     transport.send_msg = MagicMock()
     signal._circles = {
         "A0FB389": {
             "JidCache": jid_cache,
             "Transport": transport
         }
     }
     signal.transmit_remote_act(rem_act, "1", "invk")
     transport.send_msg.assert_called_once()
     print("Passed : testtransmit_remote_act")