

def test_enqueue_wait_splitpolicy(self):
    splitpolicy1 = self.mox.CreateMock(QueuePolicy)
    splitpolicy2 = self.mox.CreateMock(QueuePolicy)
    regpolicy = self.mox.CreateMock(QueuePolicy)
    env1 = Envelope('sender1@example.com', ['rcpt1@example.com'])
    env2 = Envelope('sender2@example.com', ['rcpt2@example.com'])
    env3 = Envelope('sender3@example.com', ['rcpt3@example.com'])
    splitpolicy1.apply(self.env).AndReturn([env1, env2])
    regpolicy.apply(env1)
    splitpolicy2.apply(env1)
    regpolicy.apply(env2)
    splitpolicy2.apply(env2).AndReturn([env2, env3])
    self.store.write(env1, IsA(float)).AndReturn('1234')
    self.store.write(env2, IsA(float)).AndReturn('5678')
    self.store.write(env3, IsA(float)).AndReturn('90AB')
    self.relay._attempt(env1, 0).InAnyOrder('relay')
    self.relay._attempt(env2, 0).InAnyOrder('relay')
    self.relay._attempt(env3, 0).InAnyOrder('relay')
    self.store.remove('1234').InAnyOrder('relay')
    self.store.remove('5678').InAnyOrder('relay')
    self.store.remove('90AB').InAnyOrder('relay')
    self.mox.ReplayAll()
    queue = Queue(self.store, self.relay, relay_pool=5)
    queue.add_policy(splitpolicy1)
    queue.add_policy(regpolicy)
    queue.add_policy(splitpolicy2)
    self.assertEqual([(env1, '1234'), (env2, '5678'), (env3, '90AB')], queue.enqueue(self.env))
    queue.relay_pool.join()

dataset/ETHPy150Open slimta/python-slimta/test/test_slimta_queue.py TestQueue.test_enqueue_wait_splitpolicy/original