예제 #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())
예제 #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
     )
예제 #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
     )
예제 #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)
예제 #5
0
파일: main.py 프로젝트: bkjones/metranome
def main():
    timer = MinuteTimer(datetime.utcnow, sleep)
    connection = AMQPConnection()
    metranome = Metranome(connection, timer, continue_policy=run_all_the_frickin_time)
    metranome.run()
예제 #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()