def check_new_shard(agent_medium, shard_medium): agent = agent_medium.get_agent() shard = shard_medium.get_agent() new_shards = agent.get_new_shards() old_shards = agent.get_old_shards() self.assertEqual(len(new_shards), 1) self.assertEqual(len(old_shards), 0) self.assertEqual(new_shards[0], IRecipient(shard)) agent.clear()
def check_shard_gone(agent_medium, *shard_mediums): agent = agent_medium.get_agent() shards = [IRecipient(m.get_agent()) for m in shard_mediums] new_shards = agent.get_new_shards() old_shards = agent.get_old_shards() self.assertEqual(len(new_shards), 0) self.assertEqual(len(old_shards), len(shards)) self.assertEqual(set(old_shards), set(shards)) agent.clear()
def check_no_changes(agent_medium): agent = agent_medium.get_agent() new_shards = agent.get_new_shards() old_shards = agent.get_old_shards() self.assertEqual(len(new_shards), 0) self.assertEqual(len(old_shards), 0)