예제 #1
0
    def test_should_run_indexing_until_reaching_max_pool_size(
        self,
        mock_get_venue_providers,
        mock_delete_venue_providers,
        mock_get_number_of_venue_providers_currently_in_sync,
        mock_run_indexing,
        mock_sleep,
        mock_wait_time_for_available_worker,
    ):
        # Given
        client = MagicMock()
        venue_provider1 = {"id": 1, "providerId": 1, "venueId": 1}
        venue_provider2 = {"id": 2, "providerId": 2, "venueId": 2}
        venue_provider3 = {"id": 3, "providerId": 3, "venueId": 3}
        mock_get_venue_providers.return_value = [venue_provider1, venue_provider2, venue_provider3]
        mock_get_number_of_venue_providers_currently_in_sync.side_effect = [0, 1, 2, 1]
        mock_wait_time_for_available_worker.return_value = 2

        # When
        process_multi_indexing(client=client)

        # Then
        assert mock_run_indexing.call_count == 3
        assert mock_run_indexing.call_args_list == [
            call(client=client, venue_provider={"id": 1, "providerId": 1, "venueId": 1}),
            call(client=client, venue_provider={"id": 2, "providerId": 2, "venueId": 2}),
            call(client=client, venue_provider={"id": 3, "providerId": 3, "venueId": 3}),
        ]
        mock_sleep.assert_called_once_with(mock_wait_time_for_available_worker)
예제 #2
0
    def test_should_retrieve_venue_providers_to_process(self, mock_get_venue_providers):
        # Given
        client = MagicMock()

        # When
        process_multi_indexing(client=client)

        # Then
        mock_get_venue_providers.assert_called_once_with(client=client)
예제 #3
0
    def test_should_delete_venue_providers_to_process(self, mock_get_venue_providers, mock_delete_venue_providers):
        # Given
        client = MagicMock()
        mock_get_venue_providers.return_value = []

        # When
        process_multi_indexing(client=client)

        # Then
        mock_delete_venue_providers.assert_called_once_with(client=client)
예제 #4
0
def index_offers_in_algolia_by_venue_provider(app):
    process_multi_indexing(client=app.redis_client)