Пример #1
0
    def test_create_new_offerer_attachment_with_validation_token_if_siren_is_already_registered(
            self, mock_maybe_send_offerer_validation_email):
        # Given
        offerers_factories.VirtualVenueTypeFactory()
        user = users_factories.UserFactory()
        offerer_informations = CreateOffererQueryModel(
            name="Test Offerer",
            siren="418166096",
            address="123 rue de Paris",
            postalCode="93100",
            city="Montreuil")
        offerer = offerers_factories.OffererFactory(
            siren=offerer_informations.siren)

        # When
        created_user_offerer = offerers_api.create_offerer(
            user, offerer_informations)

        # Then
        created_offerer = created_user_offerer.offerer
        assert created_offerer.name == offerer.name
        assert created_offerer.validationToken is None

        assert created_user_offerer.userId == user.id
        assert created_user_offerer.validationToken is not None

        assert not created_user_offerer.user.has_pro_role

        mock_maybe_send_offerer_validation_email.assert_called_once_with(
            created_user_offerer.offerer, created_user_offerer)
Пример #2
0
    def test_keep_offerer_validation_token_if_siren_is_already_registered_but_not_validated(
            self, mock_maybe_send_offerer_validation_email):
        # Given
        offerers_factories.VirtualVenueTypeFactory()
        user = users_factories.UserFactory()
        offerer_informations = CreateOffererQueryModel(
            name="Test Offerer",
            siren="418166096",
            address="123 rue de Paris",
            postalCode="93100",
            city="Montreuil")
        offerer = offerers_factories.OffererFactory(
            siren=offerer_informations.siren, validationToken="TOKEN")

        # When
        created_user_offerer = offerers_api.create_offerer(
            user, offerer_informations)

        # Then
        created_offerer = created_user_offerer.offerer
        assert created_offerer.name == offerer.name
        assert created_offerer.validationToken == "TOKEN"

        assert created_user_offerer.userId == user.id
        assert created_user_offerer.validationToken is not None
Пример #3
0
    def test_create_digital_venue_if_siren_is_not_already_registered(
            self, mock_maybe_send_offerer_validation_email):
        # Given
        offerers_factories.VirtualVenueTypeFactory()
        user = users_factories.UserFactory()
        offerer_informations = CreateOffererQueryModel(
            name="Test Offerer",
            siren="418166096",
            address="123 rue de Paris",
            postalCode="93100",
            city="Montreuil")

        # When
        created_user_offerer = offerers_api.create_offerer(
            user, offerer_informations)

        # Then
        created_offerer = created_user_offerer.offerer
        assert len(created_offerer.managedVenues) == 1
        assert created_offerer.managedVenues[0].isVirtual is True
Пример #4
0
def create_offerer(body: CreateOffererQueryModel) -> GetOffererResponseModel:
    user_offerer = api.create_offerer(current_user, body)

    return GetOffererResponseModel.from_orm(user_offerer.offerer)