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")
def testsignal_timer_method(self): """ Test to check the timer method of the signal class. """ sig_dict, signal = self.setup_vars_mocks() transport = XmppTransport.factory( "1", sig_dict["Signal"]["Overlays"]["A0FB389"], signal, signal._presence_publisher, None, None) rem_acts = {} jid_cache = JidCache(signal, 5) jid_cache.scavenge = MagicMock() signal.scavenge_pending_cbts = MagicMock() transport.event_loop = MagicMock() signal._circles = { "A0FB389": { "Announce": 0, "Transport": transport, "OutgoingRemoteActs": rem_acts, "JidCache": jid_cache } } signal._circles["A0FB389"][ "Transport"].event_loop.call_soon_threadsafe = MagicMock() signal.timer_method() signal._circles["A0FB389"][ "Transport"].event_loop.call_soon_threadsafe.assert_called_once() jid_cache.scavenge.assert_called_once() signal.scavenge_pending_cbts.assert_called_once() print("Passed : testsignal_timer_method")