Example #1
0
 def test_run_all(self, mock_run_status_check):
     tasks.run_all_checks()
     mock_run_status_check.assert_has_calls([
         call.apply_async((10102,), queue='critical_checks', routing_key='critical_checks'),
         call.apply_async((10101,), queue='normal_checks', routing_key='normal_checks'),
         call.apply_async((10104,), queue='normal_checks', routing_key='normal_checks'),
         call.apply_async((10103,), queue='normal_checks', routing_key='normal_checks'),
     ])
    def test_enabling_autogen_when_ready_and_paused(self, timed_task, ready_task):
        self.generator.autogenerate = False
        self.generator.save()

        self.assertFalse(self.generator.is_ready())

        Pause(agent=self.agent2,
              generator=self.generator,
              user=self.user,
              reason="1 week vacation.").save()

        Ready(agent=self.agent1,
              generator=self.generator,
              user=self.user).save()
        Ready(agent=self.agent2,
              generator=self.generator,
              user=self.user).save()

        self.assertTrue(self.generator.is_ready())
        self.assertFalse(timed_task.mock_calls)
        self.assertFalse(ready_task.mock_calls)

        self.generator.autogenerate = True
        self.generator.save()

        self.assertTrue(self.generator.is_ready())
        self.assertFalse(timed_task.mock_calls)
        self.assertEqual(ready_task.mock_calls,
                         [call.apply_async((self.generator.pk,))])
    def test_autogenerate_when_ready_and_enabled(self, timed_task, ready_task):
        self.assertTrue(self.generator.autogenerate)

        Ready(agent=self.agent1,
              generator=self.generator,
              user=self.user).save()
        self.assertFalse(self.generator.is_ready())

        self.assertFalse(timed_task.mock_calls)
        self.assertFalse(ready_task.mock_calls)

        Ready(agent=self.agent2,
              generator=self.generator,
              user=self.user).save()
        self.assertTrue(self.generator.is_ready())

        self.assertFalse(timed_task.mock_calls)
        self.assertEqual(ready_task.mock_calls,
                         [call.apply_async((self.generator.pk,))])