Esempio n. 1
0
    def test_should_raise_error_when_venue_does_not_exist(self):
        # Given
        venue = None

        # When
        with pytest.raises(ApiErrors) as error:
            check_existing_venue(venue)

        # Then
        assert error.value.errors["venue"] == ["Ce lieu n'existe pas"]
Esempio n. 2
0
def connect_venue_to_allocine(
    venue_provider_payload: Dict, find_venue_by_id: Callable, get_theaterid_for_venue: Callable
) -> AllocineVenueProvider:
    venue_id = dehumanize(venue_provider_payload["venueId"])
    venue = find_venue_by_id(venue_id)
    check_existing_venue(venue)

    theater_id = get_theaterid_for_venue(venue)
    venue_provider = _create_allocine_venue_provider(theater_id, venue_provider_payload, venue)
    venue_provider_price_rule = _create_allocine_venue_provider_price_rule(
        venue_provider, venue_provider_payload.get("price")
    )

    repository.save(venue_provider_price_rule)

    return venue_provider
Esempio n. 3
0
def connect_venue_to_provider(
    provider_class: object,
    stock_provider_repository: StockProviderRepository,
    venue_provider_payload: Dict,
    find_venue_by_id: Callable,
) -> VenueProvider:
    venue_id = dehumanize(venue_provider_payload["venueId"])
    venue = find_venue_by_id(venue_id)
    check_existing_venue(venue)
    if provider_class not in STANDARD_STOCK_PROVIDERS:
        api_errors = ApiErrors()
        api_errors.status_code = ERROR_CODE_PROVIDER_NOT_SUPPORTED
        api_errors.add_error("provider", "Provider non pris en charge")
        raise api_errors

    _check_venue_can_be_synchronized_with_provider(
        venue.siret, stock_provider_repository.can_be_synchronized, STANDARD_STOCK_PROVIDERS[provider_class]
    )
    new_venue_provider = _connect_stock_providers_to_venue(venue, venue_provider_payload)
    return new_venue_provider