Ejemplo n.º 1
0
    def test_create_cunsumer(self, dlq_con_mock, rt_con_mock, wrk_con_mock,
                             create_cunsumer_mock, producer_mock,
                             exchange_mock, connection_mock, sleep_mock):
        # create a basic orchestrator
        orchestrator = Orchestrator(rabbitmq_url="test.rabbitmq.com:8000")

        with self.assertRaises(EasyJobServiceNotStarted) as e:
            orchestrator.create_work_cunsumer()

        with self.assertRaises(EasyJobServiceNotStarted) as e:
            orchestrator.create_retry_queue_consumer()

        with self.assertRaises(EasyJobServiceNotStarted) as e:
            orchestrator.create_dead_letter_queue_consumer()

        orchestrator.start_service(run_health_check=False)

        # test work queue
        orchestrator.create_work_cunsumer()
        wrk_con_mock.assert_called()

        # test retry queue
        orchestrator.create_retry_queue_consumer()
        rt_con_mock.assert_called()

        # test deal letter queue
        orchestrator.create_dead_letter_queue_consumer()
        dlq_con_mock.assert_called()
Ejemplo n.º 2
0
    def test_start_service(self, sleep_mock, create_cunsumer_mock,
                           _setup_entities_mock):
        # create a basic orchestrator
        orchestrator = Orchestrator(rabbitmq_url="test.rabbitmq.com:8000")

        orchestrator.start_service(run_health_check=False)
        _setup_entities_mock.assert_called()
        create_cunsumer_mock.assert_called()

        self.assertEqual(
            create_cunsumer_mock.call_count, constants.DEFAULT_WORKER_COUNT +
            constants.DEFAULT_RETRY_CONSUMER_COUNT +
            constants.DEFAULT_DLQ_CONSUMER_COUNT)