From 96d7e00830bc3ac3fca07566b73fd4fa026ead2f Mon Sep 17 00:00:00 2001 From: Benjamin Dweck Date: Fri, 16 Oct 2020 00:01:39 +0200 Subject: [PATCH] Added test for multiple client publications --- test/test_integration_pub_sub.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test_integration_pub_sub.py b/test/test_integration_pub_sub.py index 064e54e..ea3bf10 100644 --- a/test/test_integration_pub_sub.py +++ b/test/test_integration_pub_sub.py @@ -72,6 +72,18 @@ class GivenBrokerAndTorchAgent(unittest.TestCase): database = self.loadDatabase() self.assertEqual(database['client2']['onionAddress'], "crazy_onion2.onion") + def test_when_agent_publishes_multiple_hosts_should_provide_latest(self): + self.run_subscriber() + agent_publish("client2", "crazy_onion2-34.onion") + agent_publish("client3", "crazy_onion3.onion") + agent_publish("client1", "crazy_onion1.onion") + agent_publish("client2", "crazy_onion2-56.onion") + agent_publish("client3", "crazy_onion3.onion") + database = self.loadDatabase() + self.assertEqual(database['client1']['onionAddress'], "crazy_onion1.onion") + self.assertEqual(database['client2']['onionAddress'], "crazy_onion2-56.onion") + self.assertEqual(database['client3']['onionAddress'], "crazy_onion3.onion") + @staticmethod def run_subscriber(): threading.Thread(target=torch_sub.subscribe,