Beispiel #1
0
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())
Beispiel #2
0
 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
     )
Beispiel #3
0
 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
     )
Beispiel #4
0
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)
Beispiel #5
0
def main():
    timer = MinuteTimer(datetime.utcnow, sleep)
    connection = AMQPConnection()
    metranome = Metranome(connection, timer, continue_policy=run_all_the_frickin_time)
    metranome.run()
Beispiel #6
0
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()