Example #1
0
def test_only_suspend_pro_users_in_given_emails_providers_list():
    # Given
    fraudulent_emails_providers = ["example.com"]
    admin_user = AdminFactory(email="*****@*****.**")
    pro_fraudulent_user_with_uppercase_domain = ProFactory(
        email="*****@*****.**")
    pro_fraudulent_user_with_subdomain = ProFactory(
        email="*****@*****.**")
    beneficiary_fraudulent_user = BeneficiaryGrant18Factory(
        email="*****@*****.**")
    offerer1 = OffererFactory()
    UserOffererFactory(user=pro_fraudulent_user_with_uppercase_domain,
                       offerer=offerer1)
    offerer2 = OffererFactory()
    UserOffererFactory(user=pro_fraudulent_user_with_subdomain,
                       offerer=offerer2)

    # When
    suspend_fraudulent_pro_by_email_providers(fraudulent_emails_providers,
                                              admin_user,
                                              dry_run=False)

    # Then
    assert not pro_fraudulent_user_with_uppercase_domain.isActive

    # Do not handle sub-domains
    assert pro_fraudulent_user_with_subdomain.isActive
    assert beneficiary_fraudulent_user.isActive
Example #2
0
def test_suspend_pro_user_with_many_offerers_and_delete_all_offerers():
    fraudulent_emails_providers = ["example.com"]
    admin_user = AdminFactory(email="*****@*****.**")
    fraudulent_user = ProFactory(email="*****@*****.**", )
    first_offerer = OffererFactory()
    UserOffererFactory(user=fraudulent_user, offerer=first_offerer)
    second_offerer = OffererFactory()
    UserOffererFactory(user=fraudulent_user, offerer=second_offerer)

    suspend_fraudulent_pro_by_email_providers(fraudulent_emails_providers,
                                              admin_user,
                                              dry_run=False)

    assert not fraudulent_user.isActive
    assert Offerer.query.count() == 0
Example #3
0
    def when_successful_and_existing_offerer_creates_editor_user_offerer_and_does_not_log_in(
            self, app):
        # Given
        VirtualVenueTypeFactory()
        offerer = OffererFactory(siren="349974931",
                                 validationToken="not_validated")
        pro = ProFactory(email="*****@*****.**", publicName="bobby")
        UserOffererFactory(user=pro, offerer=offerer)

        data = BASE_DATA_PRO.copy()

        # When
        response = TestClient(app.test_client()).post("/users/signup/pro",
                                                      json=data)

        # Then
        assert response.status_code == 204
        assert "Set-Cookie" not in response.headers
        pro = User.query.filter_by(email="*****@*****.**").first()
        assert pro is not None
        offerer = Offerer.query.filter_by(siren="349974931").first()
        assert offerer is not None
        user_offerer = UserOfferer.query.filter_by(user=pro,
                                                   offerer=offerer).first()
        assert user_offerer is not None
        assert user_offerer.validationToken is not None
Example #4
0
    def when_offerer_already_have_user_offerer_new_user_offerer_has_validation_token(
            self, mock_api_entreprise, make_validation_email_object, app):
        # Given
        make_validation_email_object.return_value = {"Html-part": None}
        mock_api_entreprise.return_value = MagicMock(
            status_code=200,
            text="",
            json=MagicMock(
                return_value=copy.deepcopy(api_entreprise_json_mock)))

        pro = ProFactory()
        offerer = OffererFactory()
        UserOffererFactory(offerer=offerer, validationToken=None)
        VirtualVenueTypeFactory()
        body = {
            "name": offerer.name,
            "siren": offerer.siren,
            "address": offerer.address,
            "postalCode": offerer.postalCode,
            "city": offerer.city,
        }

        # when
        response = TestClient(app.test_client()).with_session_auth(
            pro.email).post("/offerers", json=body)

        # then
        assert response.status_code == 201
        offerer = Offerer.query.first()
        created_user_offerer = (UserOfferer.query.filter(
            UserOfferer.offerer == offerer).filter(
                UserOfferer.user == pro).one())
        assert created_user_offerer.validationToken is not None
Example #5
0
    def test_when_geolocation_is_missing(self, app):
        # given
        offerer = OffererFactory(siren="828768000")
        VenueTypeFactory(label="Librairie")
        VenueFactory()
        csv_row = OrderedDict([
            ("Street Address", "46 AV DE LA ROUE"),
            ("Email", "*****@*****.**"),
            ("adresse", "46 AV DE LA ROUE, 92240"),
            ("code_postal", "92240"),
            ("commune", "MALAKOFF"),
            ("Département", "92"),
            ("nom_lieu", ""),
            ("SIRET", "76800828012119.0"),
            ("geoloc", ""),
            ("Catégorie", "Librairie"),
            ("nom_structure", "Ma structure"),
        ])

        # when
        venue = create_venue_from_csv(csv_row, offerer)

        # then
        assert venue.latitude is None
        assert venue.longitude is None
    def test_should_not_be_stuck_because_of_no_siren_offerer_and_print_a_list_of_errored_venues(
            self, stub_read_venue_type_from_file, app, capsys):
        # Given
        offerer = OffererFactory(siren=None)
        VenueTypeFactory(label="old_type", id=1)
        VenueTypeFactory(label="new_type", id=25)
        VenueFactory(managingOfferer=offerer,
                     name="CMOI",
                     id=121,
                     venueTypeId=1)
        VenueFactory(managingOfferer=offerer,
                     name="AUSSI MOI",
                     id=99,
                     siret="12345678912354",
                     venueTypeId=1)

        stub_read_venue_type_from_file.return_value = [("121", "new_type"),
                                                       ("99", "new_type")]

        # When
        update_venue_type("fake/path")

        # Then
        captured = capsys.readouterr()
        updated_venue1 = Venue.query.filter_by(id=121).one()
        updated_venue2 = Venue.query.filter_by(id=99).one()
        assert updated_venue1.venueTypeId == 1
        assert updated_venue2.venueTypeId == 1
        assert "0 venues have been updated" in captured.out
        assert "Venues in error : 121, 99" in captured.out
Example #7
0
def test_cancel_bookings_when_offerer_has_one_or_more():
    # Given
    fraudulent_emails_providers = ["example.com"]
    admin_user = AdminFactory(email="*****@*****.**")
    beneficiary1 = BeneficiaryGrant18Factory(email="*****@*****.**")
    beneficiary2 = BeneficiaryGrant18Factory(email="*****@*****.**")
    fraudulent_user = ProFactory(email="*****@*****.**", )
    offerer_with_bookings = OffererFactory()
    UserOffererFactory(user=fraudulent_user, offerer=offerer_with_bookings)
    offer1 = OfferFactory(venue__managingOfferer=offerer_with_bookings)
    offer2 = OfferFactory(venue__managingOfferer=offerer_with_bookings)
    stock1 = StockFactory(offer=offer1)
    stock2 = StockFactory(offer=offer2)
    booking1 = BookingFactory(user=beneficiary1, stock=stock1)
    booking2 = BookingFactory(user=beneficiary2, stock=stock2)

    # When
    suspend_fraudulent_pro_by_email_providers(fraudulent_emails_providers,
                                              admin_user,
                                              dry_run=False)

    # Then
    assert Offerer.query.count() == 1
    assert Venue.query.count() == 2
    assert Offer.query.count() == 2
    assert Stock.query.count() == 2
    assert Booking.query.count() == 2
    assert booking1.isCancelled
    assert booking1.status is BookingStatus.CANCELLED
    assert booking1.cancellationReason is BookingCancellationReasons.FRAUD
    assert booking2.isCancelled
    assert booking2.status is BookingStatus.CANCELLED
    assert booking2.cancellationReason is BookingCancellationReasons.FRAUD
    def test_should_send_two_emails_to_offerer_when_expired_books_bookings_and_other_bookings_cancelled(
            self):
        offerer = OffererFactory()
        expired_today_dvd_booking = booking_factories.IndividualBookingFactory(
            stock__offer__name="Intouchables",
            stock__offer__bookingEmail="*****@*****.**",
            stock__offer__subcategoryId=subcategories.SUPPORT_PHYSIQUE_FILM.id,
        )
        expired_today_book_booking = booking_factories.IndividualBookingFactory(
            stock__offer__name="Les misérables",
            stock__offer__bookingEmail="*****@*****.**",
            stock__offer__subcategoryId=subcategories.LIVRE_PAPIER.id,
        )

        send_expired_individual_bookings_recap_email_to_offerer(
            offerer, [expired_today_dvd_booking, expired_today_book_booking])

        assert len(mails_testing.outbox) == 2
        assert mails_testing.outbox[0].sent_data["Mj-TemplateID"] == 3095184
        assert mails_testing.outbox[0].sent_data["Vars"][
            "withdrawal_period"] == 10
        assert mails_testing.outbox[0].sent_data["Vars"]["bookings"][0][
            "offer_name"] == "Les misérables"
        assert mails_testing.outbox[1].sent_data["Mj-TemplateID"] == 3095184
        assert mails_testing.outbox[1].sent_data["Vars"][
            "withdrawal_period"] == 30
        assert mails_testing.outbox[1].sent_data["Vars"]["bookings"][0][
            "offer_name"] == "Intouchables"
Example #9
0
    def test_map_a_venue_from_ordered_dict(self, app):
        # given
        offerer = OffererFactory(siren="828768000")
        VenueTypeFactory(label="Librairie")
        csv_row = OrderedDict([
            ("Street Address", "46 AV DE LA ROUE"),
            ("adresse", "46 AV DE LA ROUE, 92240"),
            ("code_postal", "92240"),
            ("commune", "MALAKOFF"),
            ("Département", "92"),
            ("SIRET", "82876800012119"),
            ("nom_lieu", "Not_found"),
            ("geoloc", "[45.847218, 12.360398]"),
            ("Catégorie", "Librairie"),
            ("Email", "*****@*****.**"),
        ])

        # when
        venue = create_venue_from_csv(csv_row, offerer)

        # then
        assert isinstance(venue, Venue)
        assert venue.address == "46 AV DE LA ROUE"
        assert venue.postalCode == "92240"
        assert venue.city == "MALAKOFF"
        assert venue.departementCode == "92"
        assert venue.siret == "82876800012119"
        assert venue.name == "Not_found"
        assert venue.publicName == "Not_found"
        assert venue.latitude == 45.847218
        assert venue.longitude == 12.360398
        assert venue.bookingEmail == "*****@*****.**"
Example #10
0
    def test_should_send_email_to_offerer_when_expired_bookings_cancelled(
            self, app):
        offerer = OffererFactory()
        expired_today_dvd_booking = BookingFactory()
        expired_today_cd_booking = BookingFactory()

        send_expired_bookings_recap_email_to_offerer(
            offerer, [expired_today_cd_booking, expired_today_dvd_booking])

        assert mails_testing.outbox[0].sent_data["Mj-TemplateID"] == 1952508
Example #11
0
    def test_raise_error_when_user_relative_to_csv_not_created(self):
        # given
        blake = User(email="*****@*****.**")
        blakes_company = OffererFactory(siren="362521879",
                                        name="MyBletcheyCompany",
                                        id=234)

        # when
        with pytest.raises(UserNotCreatedException):
            fill_user_offerer_from(UserOfferer(), blake, blakes_company)
def test_maybe_send_offerer_validation_email_does_not_send_email_if_all_validated(app):
    # Given
    user = users_factories.UserFactory()
    offerer = OffererFactory()
    user_offerer = UserOffererFactory(offerer=offerer, user=user)

    # When
    maybe_send_offerer_validation_email(offerer, user_offerer)

    # Then
    assert not mails_testing.outbox
Example #13
0
    def test_email(self):
        offerer = OffererFactory(name="Le Théâtre SAS")

        mail_data = retrieve_data_for_offerer_attachment_validation_email(
            offerer)

        assert mail_data == {
            "MJ-TemplateID": 778756,
            "MJ-TemplateLanguage": True,
            "Vars": {
                "nom_structure": "Le Théâtre SAS"
            },
        }
    def test_should_send_email_to_offerer_when_expired_bookings_cancelled(
            self, app):
        offerer = OffererFactory()
        expired_today_dvd_booking = booking_factories.IndividualBookingFactory(
            stock__offer__bookingEmail="*****@*****.**")
        expired_today_cd_booking = booking_factories.IndividualBookingFactory(
            stock__offer__bookingEmail="*****@*****.**")

        send_expired_individual_bookings_recap_email_to_offerer(
            offerer, [expired_today_cd_booking, expired_today_dvd_booking])
        assert len(mails_testing.outbox) == 1
        assert mails_testing.outbox[0].sent_data["Mj-TemplateID"] == 3095184
        assert mails_testing.outbox[0].sent_data["Vars"]
Example #15
0
    def test_should_send_email_to_offerer_when_expired_bookings_cancelled(
            self, app):
        offerer = OffererFactory()
        expired_today_dvd_booking = BookingFactory()
        expired_today_cd_booking = BookingFactory()
        mocked_send_email = Mock()

        send_expired_bookings_recap_email_to_offerer(
            offerer, [expired_today_cd_booking, expired_today_dvd_booking],
            mocked_send_email)

        mocked_send_email.assert_called_once()
        mocked_send_email.call_args_list[0][1]["MJ-TemplateID"] = 1952508
        mocked_send_email.call_args_list[0][1][
            "recipients"] = "*****@*****.**"
Example #16
0
    def when_successful_and_mark_pro_user_as_no_cultural_survey_needed(
            self, app):
        # Given
        OffererFactory(siren="349974931")

        data = BASE_DATA_PRO.copy()

        # When
        response = TestClient(app.test_client()).post("/users/signup/pro",
                                                      json=data)

        # Then
        assert response.status_code == 204
        user = User.query.filter_by(email="*****@*****.**").first()
        assert user.needsToFillCulturalSurvey == False
    def test_should_return_payments_from_multiple_venues(self, app):
        # Given
        offerer = OffererFactory()
        payments_factories.PaymentStatusFactory(
            payment__booking__stock__offer__venue__managingOfferer=offerer,
            status=TransactionStatus.SENT)
        payments_factories.PaymentStatusFactory(
            payment__booking__stock__offer__venue__managingOfferer=offerer,
            status=TransactionStatus.SENT)

        # When
        payments = find_all_offerer_payments(offerer.id, reimbursement_period)

        # Then
        assert len(payments) == 2
Example #18
0
def test_suspend_pros_in_given_emails_providers_list():
    # Given
    fraudulent_emails_providers = ["example.com"]
    admin_user = AdminFactory(email="*****@*****.**")
    fraudulent_user = ProFactory(email="*****@*****.**", )
    offerer = OffererFactory()
    UserOffererFactory(user=fraudulent_user, offerer=offerer)

    # When
    suspend_fraudulent_pro_by_email_providers(fraudulent_emails_providers,
                                              admin_user,
                                              dry_run=False)

    # Then
    assert not fraudulent_user.isActive
Example #19
0
    def test_returns_a_user_offerer_built_with_user_and_offerer_relative_to_csv_row(
            self):
        # given
        blake = ProFactory(email="*****@*****.**", id=123)
        blakes_company = OffererFactory(siren="362521879",
                                        name="MyBletcheyCompany",
                                        id=234)

        # when
        user_offerer = fill_user_offerer_from(UserOfferer(), blake,
                                              blakes_company)

        # then
        assert user_offerer.user == blake
        assert user_offerer.offerer == blakes_company
Example #20
0
def test_delete_offerer_and_venue():
    # Given
    fraudulent_emails_providers = ["example.com"]
    admin_user = AdminFactory(email="*****@*****.**")
    fraudulent_user = ProFactory(email="*****@*****.**", )
    offerer = OffererFactory()
    UserOffererFactory(user=fraudulent_user, offerer=offerer)
    VenueFactory(managingOfferer=offerer)

    # When
    suspend_fraudulent_pro_by_email_providers(fraudulent_emails_providers,
                                              admin_user,
                                              dry_run=False)

    # Then
    assert Offerer.query.count() == 0
    assert Venue.query.count() == 0
    def test_should_not_delete_product_and_deactivate_associated_offer_when_it_changes_to_paper_press_product(
        self, get_lines_from_thing_file, get_files_to_process_from_titelive_ftp, app
    ):
        # Given
        files_list = list()
        files_list.append("Quotidien30.tit")

        DATA_LINE_PARTS = BASE_DATA_LINE_PARTS[:]
        DATA_LINE_PARTS[13] = "R"
        DATA_LINE_PARTS[26] = "2,10"

        data_line = "~".join(DATA_LINE_PARTS)

        get_files_to_process_from_titelive_ftp.return_value = files_list

        get_lines_from_thing_file.return_value = iter([data_line])

        titelive_provider = activate_provider("TiteLiveThings")
        repository.save(titelive_provider)

        beneficiary = users_factories.BeneficiaryGrant18Factory(email="*****@*****.**")
        offerer = OffererFactory(siren="123456789")
        venue = VenueFactory(managingOfferer=offerer)
        product = ThingProductFactory(
            idAtProviders="9782895026310",
            name="Presse papier",
            subcategoryId=subcategories.LIVRE_PAPIER.id,
            dateModifiedAtLastProvider=datetime(2001, 1, 1),
            lastProviderId=titelive_provider.id,
        )
        offer = ThingOfferFactory(product=product, venue=venue, isActive=True)
        stock = ThingStockFactory(offer=offer, price=0)
        BookingFactory(user=beneficiary, stock=stock)

        titelive_things = TiteLiveThings()

        # When
        titelive_things.updateObjects()

        # Then
        offer = Offer.query.one()
        assert offer.isActive is False
        assert Product.query.count() == 1
Example #22
0
    def test_created_pro_is_activated_with_90_days_reset_password(self, app):
        # Given
        VirtualVenueTypeFactory()
        VenueTypeFactory(label="Librairie")
        offerer = OffererFactory(siren="636710003")
        VenueFactory(managingOfferer=offerer)
        VirtualVenueFactory(managingOfferer=offerer)
        csv_row = OrderedDict([
            ("", "104"),
            ("Company ID", "1099515212"),
            ("Email", "*****@*****.**"),
            ("First Name", "Anthony"),
            ("Last Name", "Champion"),
            ("Phone", "01 02 34 56 78"),
            ("Postal Code", "44016.0"),
            ("City", "NANTES CEDEX 1"),
            ("SIRET", "63671000326012"),
            ("SIREN", "636710003"),
            ("Département", "44"),
            ("Name", "Fictive"),
            ("Catégorie", "Librairie"),
            ("Street Address", "45 RUE DU JOYEUX LURON"),
            ("nom_structure", "SARL"),
            ("adresse", "45 RUE DU JOYEUX LURON, 44000"),
            ("code_postal", "44000"),
            ("commune", "NANTES"),
            ("geoloc", "[44.455621, -2.546101]"),
            ("nom_lieu", "Ma librairie"),
            ("siege_social", "45 RUE DU JOYEUX LURON, 44000"),
            ("lieu_deja_inscrit", "0"),
            ("structure_deja_inscrite", "0"),
        ])

        # When
        import_new_offerer_from_csv(csv_row)

        # Then
        user = User.query.first()
        token = Token.query.first()
        assert not user.validationToken
        assert token.user == user
        assert token.expirationDate == datetime(2021, 8, 2)
def test_maybe_send_offerer_validation_email_sends_email_to_pass_culture_when_objects_to_validate(
    mock_api_entreprise, app
):
    # Given
    response_return_value = MagicMock(status_code=200, text="")
    response_return_value.json = MagicMock(
        return_value={
            "unite_legale": {"etablissement_siege": {"siret": ""}, "etablissements": [], "activite_principale": ""}
        }
    )
    mock_api_entreprise.return_value = response_return_value
    user = users_factories.UserFactory()
    offerer = OffererFactory(validationToken="12356")
    user_offerer = UserOffererFactory(offerer=offerer, user=user)

    # When
    maybe_send_offerer_validation_email(offerer, user_offerer)

    # Then
    assert len(mails_testing.outbox) == 1
    assert mails_testing.outbox[0].sent_data["To"] == "*****@*****.**"
Example #24
0
    def test_returns_created_user_offerer(self, app):
        # given
        blake = ProFactory(email="*****@*****.**", id=123)
        VirtualVenueTypeFactory()
        blakes_company = OffererFactory(siren="362521879",
                                        name="MyBletcheyCompany",
                                        id=234)
        self.find_user_query.side_effect = [blake]
        self.find_offerer_query.side_effect = [blakes_company]
        self.find_user_offerer_query.side_effect = [None]

        # when
        user_offerer = create_activated_user_offerer(
            self.csv_row,
            find_user=self.find_user_query,
            find_offerer=self.find_offerer_query,
            find_user_offerer=self.find_user_offerer_query,
        )

        # then
        assert user_offerer.userId == 123
        assert user_offerer.offererId == 234
Example #25
0
    def test_when_is_already_existing_offerer(self, app):
        # Given
        VirtualVenueTypeFactory()
        VenueTypeFactory(label="Librairie")
        offerer = OffererFactory(siren="636710003")
        VenueFactory(managingOfferer=offerer)
        VirtualVenueFactory(managingOfferer=offerer)
        csv_row = OrderedDict([
            ("", "104"),
            ("Company ID", "1099515212"),
            ("Email", "*****@*****.**"),
            ("First Name", "Anthony"),
            ("Last Name", "Champion"),
            ("Phone", "01 02 34 56 78"),
            ("Postal Code", "44016.0"),
            ("City", "NANTES CEDEX 1"),
            ("SIRET", "63671000326012"),
            ("SIREN", "636710003"),
            ("Département", "44"),
            ("Name", "Fictive"),
            ("Catégorie", "Librairie"),
            ("Street Address", "45 RUE DU JOYEUX LURON"),
            ("nom_structure", "SARL"),
            ("adresse", "45 RUE DU JOYEUX LURON, 44000"),
            ("code_postal", "44000"),
            ("commune", "NANTES"),
            ("geoloc", "[44.455621, -2.546101]"),
            ("nom_lieu", "Ma librairie"),
            ("siege_social", "45 RUE DU JOYEUX LURON, 44000"),
            ("lieu_deja_inscrit", "0"),
            ("structure_deja_inscrite", "0"),
        ])

        # When
        import_new_offerer_from_csv(csv_row)

        # Then
        assert Offerer.query.count() == 1
        assert Venue.query.count() == 3
Example #26
0
    def when_successful_and_existing_offerer_but_no_user_offerer_does_not_signin(
            self, app):
        # Given
        OffererFactory(siren="349974931")

        data = BASE_DATA_PRO.copy()

        # When
        response = TestClient(app.test_client()).post("/users/signup/pro",
                                                      json=data)

        # Then
        assert response.status_code == 204
        assert "Set-Cookie" not in response.headers
        user = User.query.filter_by(email="*****@*****.**").first()
        assert user is not None
        offerer = Offerer.query.filter_by(siren="349974931").first()
        assert offerer is not None
        user_offerer = UserOfferer.query.filter_by(user=user,
                                                   offerer=offerer).first()
        assert user_offerer is not None
        assert user_offerer.validationToken is not None
    def test_should_return_payments_filtered_by_venue(self, app):
        # Given
        offerer = OffererFactory()
        venue_1 = VenueFactory(managingOfferer=offerer)
        venue_2 = VenueFactory(managingOfferer=offerer)

        payment_1 = payments_factories.PaymentFactory(
            booking__stock__offer__venue=venue_1)
        payments_factories.PaymentStatusFactory(payment=payment_1,
                                                status=TransactionStatus.SENT)
        payment_2 = payments_factories.PaymentFactory(
            booking__stock__offer__venue=venue_2)
        payments_factories.PaymentStatusFactory(payment=payment_2,
                                                status=TransactionStatus.SENT)

        # When
        payments = find_all_offerer_payments(offerer.id, reimbursement_period,
                                             venue_1.id)

        # Then
        assert len(payments) == 1
        assert payment_1.booking.token in payments[0]
        assert venue_1.name in payments[0]
Example #28
0
    def test_use_Postal_code_when_no_SIRENE_code_postal(self, app):
        # given
        offerer = OffererFactory(siren="828768000")
        VenueTypeFactory(label="Librairie")
        csv_row = OrderedDict([
            ("Street Address", "46 AV DE LA ROUE"),
            ("adresse", "46 AV DE LA ROUE, 92240"),
            ("code_postal", ""),
            ("Postal Code", "92240"),
            ("commune", "MALAKOFF"),
            ("Département", "92"),
            ("SIRET", "82876800012119"),
            ("nom_lieu", "Not_found"),
            ("geoloc", "[45.847218, 12.360398]"),
            ("Catégorie", "Librairie"),
            ("Email", "*****@*****.**"),
        ])

        # when
        venue = create_venue_from_csv(csv_row, offerer)

        # then
        assert isinstance(venue, Venue)
        assert venue.postalCode == "92240"
Example #29
0
    def test_should_have_a_venue_type(self, app):
        # given
        offerer = OffererFactory(siren="828768000")
        VenueTypeFactory(label="Librairie")
        csv_row = OrderedDict([
            ("Street Address", "46 AV DE LA ROUE"),
            ("Email", "*****@*****.**"),
            ("adresse", "46 AV DE LA ROUE, 92240"),
            ("code_postal", "92240"),
            ("commune", "MALAKOFF"),
            ("Département", "92"),
            ("nom_lieu", ""),
            ("SIRET", "76800828012119.0"),
            ("geoloc", "[45.847218, 12.360398]"),
            ("Catégorie", "Librairie"),
            ("nom_structure", "Ma structure"),
        ])

        # when
        venue = create_venue_from_csv(csv_row, offerer)

        # then
        assert venue.venueType is not None
        assert venue.venueType.label == "Librairie"
    def test_should_return_payments_filtered_by_payment_date(self, app):
        # Given
        tomorrow_at_nine = datetime.combine(
            tomorrow, datetime.min.time()) + timedelta(hours=9)
        offerer = OffererFactory()
        venue_1 = VenueFactory(managingOfferer=offerer)
        payment_1 = payments_factories.PaymentFactory(
            booking__stock__offer__venue=venue_1)
        payments_factories.PaymentStatusFactory(date=tomorrow_at_nine,
                                                payment=payment_1,
                                                status=TransactionStatus.SENT)
        payment_2 = payments_factories.PaymentFactory(
            booking__stock__offer__venue=venue_1)
        payments_factories.PaymentStatusFactory(date=in_two_days,
                                                payment=payment_2,
                                                status=TransactionStatus.SENT)

        # When
        payments = find_all_offerer_payments(offerer.id, (today, tomorrow))

        # Then
        assert len(payments) == 1
        assert payment_1.booking.token in payments[0]
        assert venue_1.name in payments[0]