class TestMetranome(TestCase): def setUp(self): self.continue_policy = MagicMock(side_effect=[True, False]) self.mock_connection = MagicMock(AMQPConnection) self.timer = MagicMock(MinuteTimer) self.mn = Metranome( self.mock_connection, self.timer, self.continue_policy ) def should_publish_datetime(self): self.mn.run() self.mock_connection.publish_datetime.assert_called_once_with(self.timer.wait())
def setUp(self): self.continue_policy = MagicMock(side_effect=[True, False]) self.mock_connection = MagicMock(AMQPConnection) self.timer = MagicMock(MinuteTimer) self.mn = Metranome( self.mock_connection, self.timer, self.continue_policy )
def setUp(self): self.continue_policy = MagicMock(side_effect=[True, False]) self.mock_connection = MagicMock(AMQPConnection) self.mock_connection.get_lock.side_effect=NotLockableException() self.timer = MagicMock() self.mn = Metranome( self.mock_connection, self.timer, self.continue_policy )
class TestMetranomeWithoutLock(TestCase): def setUp(self): self.continue_policy = MagicMock(side_effect=[True, False]) self.mock_connection = MagicMock(AMQPConnection) self.mock_connection.get_lock.side_effect=NotLockableException() self.timer = MagicMock() self.mn = Metranome( self.mock_connection, self.timer, self.continue_policy ) def test_should_stop_running(self): self.assertEqual(self.mn.run(), False)
def main(): timer = MinuteTimer(datetime.utcnow, sleep) connection = AMQPConnection() metranome = Metranome(connection, timer, continue_policy=run_all_the_frickin_time) metranome.run()
def main(): timer = MinuteTimer(datetime.utcnow, sleep) connection = create_amqp_connection_from_config(config) metranome = Metranome(connection, timer, continue_policy=run_all_the_frickin_time) metranome.run()