Added test for multiple client publications

This commit is contained in:
B.J. Dweck 2020-10-16 00:01:39 +02:00
parent 4db6393f9b
commit 96d7e00830

View File

@ -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,