コード例 #1
0
    def test_should_return_venue_ids(self):
        # Given
        client = MagicMock()
        client.lrange = MagicMock()

        # When
        get_venue_ids(client=client)

        # Then
        client.lrange.assert_called_once_with("venue_ids", 0, 1)
コード例 #2
0
def batch_indexing_offers_in_algolia_by_venue(client: Redis) -> None:
    venue_ids = get_venue_ids(client=client)

    if len(venue_ids) > 0:
        for venue_id in venue_ids:
            page = 0
            has_still_offers = True

            while has_still_offers:
                offer_ids_as_tuple = offer_queries.get_paginated_offer_ids_by_venue_id(
                    limit=settings.ALGOLIA_OFFERS_BY_VENUE_CHUNK_SIZE,
                    page=page,
                    venue_id=venue_id)
                offer_ids_as_int = from_tuple_to_int(offer_ids_as_tuple)

                if len(offer_ids_as_int) > 0:
                    logger.info(
                        "[ALGOLIA] processing offers for venue %s from page %s...",
                        venue_id, page)
                    process_eligible_offers(client=client,
                                            offer_ids=offer_ids_as_int,
                                            from_provider_update=False)
                    logger.info(
                        "[ALGOLIA] offers for venue %s from page %s processed!",
                        venue_id, page)
                else:
                    has_still_offers = False
                    logger.info(
                        "[ALGOLIA] processing of offers for venue %s finished!",
                        venue_id)
                page += 1
        delete_venue_ids(client=client)
コード例 #3
0
    def test_should_return_empty_array_when_exception(self):
        # Given
        client = MagicMock()
        client.lrange = MagicMock()
        client.lrange.side_effect = redis.exceptions.RedisError

        # When
        result = get_venue_ids(client=client)

        # Then
        assert result == []