def test_file_has_creation_datetime_in_group_header(self, app): # Given offerer = create_offerer() user = create_user() venue = create_venue(offerer) stock = create_stock_from_offer(create_offer_with_thing_product(venue)) booking = create_booking(user, stock) payment1 = create_payment(booking, offerer, Decimal(10), iban='CF13QSDFGH456789', bic='QSDFGH8Z555') payment2 = create_payment(booking, offerer, Decimal(20), iban='CF13QSDFGH456789', bic='QSDFGH8Z555') payments = [payment1, payment2] # When xml = generate_message_file(payments, 'BD12AZERTY123456', 'AZERTY9Q666', MESSAGE_ID, '0000') # Then assert find_node('//ns:GrpHdr/ns:CreDtTm', xml) == '2018-10-15T09:21:34', \ 'The creation datetime should look like YYYY-MM-DDTHH:MM:SS"'
def test_titelive_stock_provider_create_nothing_if_siret_is_not_in_titelive_database(app): # given offerer = create_offerer(siren='987654321') venue = create_venue(offerer, name='Librairie Titelive', siret='12345678912345') PcObject.save(venue) tite_live_things_provider = get_provider_by_local_class('TiteLiveThings') venue_provider = VenueProvider() venue_provider.venue = venue venue_provider.provider = tite_live_things_provider venue_provider.isActive = True venue_provider.venueIdAtOfferProvider = '12345678912345' PcObject.save(venue_provider) product = create_product_with_thing_type(id_at_providers='0002730757438') offer = create_offer_with_thing_product(venue=venue, product=product) PcObject.save(product, offer) # When / Then provider_test(app, TiteLiveStocks, venue_provider, checkedObjects=0, createdObjects=0, updatedObjects=0, erroredObjects=0, checkedThumbs=0, createdThumbs=0, updatedThumbs=0, erroredThumbs=0, Stock=0 )
def test_create_filter_matching_all_keywords_in_any_models_with_several_keywords_at_just_event_or_just_thing_level( app): # given ok_event1 = create_product_with_event_type( event_name='Rencontre avec Jacques Martin') event2 = create_product_with_event_type( event_name='Concert de contrebasse') ok_thing1 = create_product_with_thing_type( thing_name='Rencontre avec vous savez qui', description='Il s\'agit de Jacques') thing2 = create_product_with_thing_type( thing_name='Rencontre avec Belle du Seigneur') offerer = create_offerer() venue = create_venue(offerer) ok_offer1 = create_offer_with_event_product(venue, ok_event1) ko_offer2 = create_offer_with_event_product(venue, event2) ok_offer3 = create_offer_with_thing_product(venue, ok_thing1) ko_offer4 = create_offer_with_thing_product(venue, thing2) PcObject.save(ok_offer1, ko_offer2, ok_offer3, ko_offer4) # when query = filter_offers_with_keywords_string(build_offer_search_base_query(), 'Rencontre Jacques') # then found_offers = query.all() found_offers_id = [found_offer.id for found_offer in found_offers] assert ok_offer1.id in found_offers_id assert ko_offer2.id not in found_offers_id assert ok_offer3.id in found_offers_id assert ko_offer4.id not in found_offers_id
def when_booking_is_cancelled(self, app): # Given user = create_user(email='*****@*****.**') admin_user = create_user(email='*****@*****.**') offerer = create_offerer() venue = create_venue(offerer) stock = create_stock_with_thing_offer(offerer, venue, offer=None, price=0) booking = create_booking(user, stock, venue=venue, is_cancelled=True) PcObject.save(admin_user, booking) url = '/bookings/token/{}?email={}&offer_id={}'.format( booking.token, '*****@*****.**', humanize(stock.offerId)) # When response = TestClient(app.test_client()).get(url) # Then assert response.status_code == 410 assert response.json['booking'] == [ 'Cette réservation a été annulée' ]
def when_deactivating_offer_and_makes_recommendations_outdated( self, app): # Given seven_days_from_now = datetime.utcnow() + timedelta(days=7) user = create_user() offerer = create_offerer() user_offerer = create_user_offerer(user, offerer) venue = create_venue(offerer) offer = create_offer_with_thing_product( venue, booking_email='*****@*****.**') recommendation = create_recommendation( offer, user, valid_until_date=seven_days_from_now) PcObject.save(offer, user, user_offerer, recommendation) recommendation_id = recommendation.id json = { 'isActive': False, } # When response = TestClient(app.test_client()).with_auth( user.email).patch(f'{API_URL}/offers/{humanize(offer.id)}', json=json) # Then assert response.status_code == 200 assert Recommendation.query.get( recommendation_id).validUntilDate < datetime.utcnow()
def when_user_has_rights_and_regular_offer(self, app): # Given user = create_user(public_name='John Doe', email='*****@*****.**') admin_user = create_user(email='*****@*****.**') offerer = create_offerer() user_offerer = create_user_offerer(admin_user, offerer) venue = create_venue(offerer) offer = create_offer_with_event_product( venue, event_name='Event Name', event_type=EventType.CINEMA) event_occurrence = create_event_occurrence(offer) stock = create_stock_from_event_occurrence(event_occurrence, price=0) booking = create_booking(user, stock, venue=venue) PcObject.save(user_offerer, booking) expected_json = { 'bookingId': humanize(booking.id), 'date': serialize(booking.stock.beginningDatetime), 'email': '*****@*****.**', 'isUsed': False, 'offerName': 'Event Name', 'userName': '******', 'venueDepartementCode': '93' } # When response = TestClient( app.test_client()).with_auth('*****@*****.**').get( '/bookings/token/{}'.format(booking.token)) # Then assert response.status_code == 200 response_json = response.json assert response_json == expected_json
def when_user_has_rights_and_email_with_special_characters_not_url_encoded( self, app): # Given user = create_user(email='*****@*****.**') user_admin = create_user(email='*****@*****.**') offerer = create_offerer() user_offerer = create_user_offerer(user_admin, offerer, is_admin=True) venue = create_venue(offerer) offer = create_offer_with_event_product(venue, event_name='Event Name') event_occurrence = create_event_occurrence(offer) stock = create_stock_from_event_occurrence(event_occurrence, price=0) booking = create_booking(user, stock, venue=venue) PcObject.save(user_offerer, booking) url = '/bookings/token/{}?email={}'.format(booking.token, user.email) # When response = TestClient( app.test_client()).with_auth('*****@*****.**').get(url) # Then assert response.status_code == 404
def expect_bookings_to_be_cancelled(self, app): # given user = create_user(email='*****@*****.**') other_user = create_user(email='*****@*****.**') offerer = create_offerer() user_offerer = create_user_offerer(user, offerer) venue = create_venue(offerer) stock = create_stock_with_event_offer(offerer, venue, price=0) booking1 = create_booking(other_user, stock=stock, is_cancelled=False) booking2 = create_booking(other_user, stock=stock, is_cancelled=False) PcObject.save(user, stock, user_offerer, booking1, booking2) # when response = TestClient(app.test_client()).with_auth( '*****@*****.**').delete('/stocks/' + humanize(stock.id)) # then assert response.status_code == 200 bookings = Booking.query.filter_by(isCancelled=True).all() assert booking1 in bookings assert booking2 in bookings
def when_stock_is_on_an_offer_from_provider(self, app): # given tite_live_provider = Provider \ .query \ .filter(Provider.localClass == 'TiteLiveThings') \ .first() user = create_user(email='*****@*****.**') offerer = create_offerer() user_offerer = create_user_offerer(user, offerer) venue = create_venue(offerer) offer = create_offer_with_thing_product( venue, last_provider_id=tite_live_provider.id) stock = create_stock(offer=offer) PcObject.save(user, stock, user_offerer) # when response = TestClient(app.test_client()).with_auth('*****@*****.**') \ .delete('/stocks/' + humanize(stock.id)) # then assert response.status_code == 400 assert response.json["global"] == [ "Les offres importées ne sont pas modifiables" ]
def test_returns_true_when_all_information_are_present_and_well_formed(self, app): # given provider = Provider() provider.name = 'Open Agenda' provider.localClass = 'OpenAgenda' provider.isActive = True provider.enabledForPro = True offerer = create_offerer() user = create_user() user_offerer = create_user_offerer(user, offerer, is_admin=True) venue = create_venue(offerer, name='Librairie Titelive', siret='77567146400110') PcObject.save(provider, user_offerer, venue) payload = { 'providerId': humanize(provider.id), 'venueId': humanize(venue.id), 'venueIdAtOfferProvider': '567890' } # when try: validate_new_venue_provider_information(payload) except ApiErrors: # then assert False
def test_raise_errors_if_venue_provider_already_exists(self, app): # given provider = Provider() provider.name = 'Open Agenda' provider.localClass = 'OpenAgenda' provider.isActive = True provider.enabledForPro = True offerer = create_offerer() user = create_user() user_offerer = create_user_offerer(user, offerer, is_admin=True) venue = create_venue(offerer, name='Librairie Titelive', siret='77567146400110') venue_provider = create_venue_provider(venue, provider, venue_id_at_offer_provider="775671464") PcObject.save(provider, user_offerer, venue, venue_provider) payload = { 'providerId': humanize(provider.id), 'venueId': humanize(venue.id), 'venueIdAtOfferProvider': '775671464' } # when with pytest.raises(ApiErrors) as errors: validate_new_venue_provider_information(payload) # then assert errors.value.status_code == 400 assert errors.value.errors['venueProvider'] == ["Votre lieu est déjà lié à cette source"]
def test_read_message_name_in_message_file_returns_the_content_of_message_id_tag( app): # given offerer = create_offerer() user = create_user() venue = create_venue(offerer) stock = create_stock_from_offer(create_offer_with_thing_product(venue)) booking = create_booking(user, stock) payment1 = create_payment(booking, offerer, Decimal(10), iban='CF13QSDFGH456789', bic='QSDFGH8Z555') payment2 = create_payment(booking, offerer, Decimal(20), iban='CF13QSDFGH456789', bic='QSDFGH8Z555') payments = [payment1, payment2] xml_file = generate_message_file(payments, 'BD12AZERTY123456', 'AZERTY9Q666', MESSAGE_ID, '0000') # when message_id = read_message_name_in_message_file(xml_file) # then assert message_id == MESSAGE_ID
def test_file_has_ultimate_debtor_in_transaction_info(self, app): # Given offerer = create_offerer() user = create_user() venue = create_venue(offerer) stock = create_stock_from_offer(create_offer_with_thing_product(venue)) booking = create_booking(user, stock) payment1 = create_payment(booking, offerer, Decimal(10), iban='CF13QSDFGH456789', bic='QSDFGH8Z555') payment2 = create_payment(booking, offerer, Decimal(20), iban='CF13QSDFGH456789', bic='QSDFGH8Z555') payments = [payment1, payment2] # When xml = generate_message_file(payments, 'BD12AZERTY123456', 'AZERTY9Q666', MESSAGE_ID, '0000') # Then assert find_node('//ns:PmtInf/ns:CdtTrfTxInf/ns:UltmtDbtr/ns:Nm', xml) == 'pass Culture', \ 'The ultimate debtor name should be "pass Culture"'
def test_file_has_initiating_party_in_group_header(self, app): # Given offerer = create_offerer() user = create_user() venue = create_venue(offerer) stock = create_stock_from_offer(create_offer_with_thing_product(venue)) booking = create_booking(user, stock) payment1 = create_payment(booking, offerer, Decimal(10), iban='CF13QSDFGH456789', bic='QSDFGH8Z555') payment2 = create_payment(booking, offerer, Decimal(20), iban='CF13QSDFGH456789', bic='QSDFGH8Z555') payments = [payment1, payment2] # When xml = generate_message_file(payments, 'BD12AZERTY123456', 'AZERTY9Q666', MESSAGE_ID, '0000') # Then assert find_node('//ns:GrpHdr/ns:InitgPty/ns:Nm', xml) == 'pass Culture', \ 'The initiating party should be "pass Culture"'
def expect_offerer_to_be_validated(self, app): # Given offerer_token = secrets.token_urlsafe(20) offerer = create_offerer('349974931', '12 boulevard de Pesaro', 'Nanterre', '92000', 'Crédit Coopératif', validation_token=offerer_token) user = create_user() user_offerer = create_user_offerer(user, offerer, is_admin=True) PcObject.save(offerer, user_offerer) offerer_id = offerer.id del (offerer) token = Offerer.query \ .filter_by(id=offerer_id) \ .first().validationToken # When response = TestClient(app.test_client()).get( '/validate?modelNames=Offerer&token=' + token, headers={'origin': 'http://localhost:3000'}) # Then assert response.status_code == 202 offerer = Offerer.query \ .filter_by(id=offerer_id) \ .first() assert offerer.isValidated
def test_nOffers_with_one_venue_provider(app): # given provider = Provider() provider.name = 'Open Agenda' provider.localClass = 'OpenAgenda' provider.isActive = True provider.enabledForPro = True PcObject.save(provider) offerer = create_offerer() venue = create_venue(offerer) venue_provider = create_venue_provider(venue, provider) offer_1 = create_offer_with_thing_product(venue, last_provider_id=provider.id, id_at_providers='offer1') offer_2 = create_offer_with_event_product(venue, last_provider_id=provider.id, id_at_providers='offer2') offer_3 = create_offer_with_event_product(venue, last_provider_id=provider.id, id_at_providers='offer3') offer_4 = create_offer_with_thing_product(venue, last_provider_id=provider.id, id_at_providers='offer4') PcObject.save(offer_1, offer_2, offer_3, offer_4, venue_provider) # when n_offers = venue_provider.nOffers # then assert n_offers == 4
def when_user_is_logged_in_and_has_two_favorite_offers(self, app): # Given user = create_user() offerer = create_offerer() venue = create_venue(offerer, postal_code='29100', siret='12345678912341') offer1 = create_offer_with_thing_product(venue, thumb_count=0) mediation1 = create_mediation(offer1, is_active=True) favorite1 = create_favorite(mediation1, offer1, user) offer2 = create_offer_with_thing_product(venue, thumb_count=0) mediation2 = create_mediation(offer2, is_active=True) favorite2 = create_favorite(mediation2, offer2, user) PcObject.save(user, favorite1, favorite2) # When response = TestClient(app.test_client()).with_auth(user.email) \ .get(API_URL + '/favorites') # Then assert response.status_code == 200 assert len(response.json) == 2 first_favorite = response.json[0] assert 'offer' in first_favorite assert 'venue' in first_favorite['offer'] assert 'validationToken' not in first_favorite['offer']['venue']
def test_offerer_not_isVirtual_and_has_no_siret_and_has_address_and_postal_code_and_city_and_departement_code( app): # Given offerer = create_offerer('123456789', '1 rue Test', 'Test city', '93000', 'Test offerer') PcObject.save(offerer) venue = create_venue(offerer, siret=None, comment="fake comment", name='Venue_name', booking_email='*****@*****.**', address='3 rue valois', postal_code='75000', city='Paris', departement_code='75', is_virtual=False) # When try: PcObject.save(venue) except ApiErrors: # Then assert pytest.fail( "Should not fail with no siret, not virtual but address, postal code, city and departement code are given" )
def when_user_not_logged_in_and_wrong_email(self, app): # Given user = create_user(email='*****@*****.**') admin_user = create_user(email='*****@*****.**') offerer = create_offerer() venue = create_venue(offerer) offer = create_offer_with_event_product(venue, event_name='Event Name') event_occurrence = create_event_occurrence(offer) stock = create_stock_from_event_occurrence(event_occurrence, price=0) booking = create_booking(user, stock, venue=venue) PcObject.save(admin_user, booking) # When url = '/bookings/token/{}?email={}'.format(booking.token, '*****@*****.**') response = TestClient( app.test_client()).with_auth('*****@*****.**').get(url) # Then assert response.status_code == 404 assert response.json['global'] == [ "Cette contremarque n'a pas été trouvée" ]
def test_offerer_cannot_create_a_second_virtual_venue(app): # Given offerer = create_offerer('123456789', '1 rue Test', 'Test city', '93000', 'Test offerer') PcObject.save(offerer) venue = create_venue(offerer, name='Venue_name', booking_email='*****@*****.**', address=None, postal_code=None, city=None, departement_code=None, is_virtual=True, siret=None) PcObject.save(venue) new_venue = create_venue(offerer, name='Venue_name', booking_email='*****@*****.**', address=None, postal_code=None, city=None, departement_code=None, is_virtual=True, siret=None) # When with pytest.raises(TooManyVirtualVenuesException): PcObject.save(new_venue)
def when_booking_is_on_stock_with_beginning_datetime_in_more_than_72_hours( self, app): # Given in_73_hours = datetime.utcnow() + timedelta(hours=73) in_74_hours = datetime.utcnow() + timedelta(hours=74) in_72_hours = datetime.utcnow() + timedelta(hours=72) user = create_user(email='*****@*****.**') admin_user = create_user(email='*****@*****.**') offerer = create_offerer() venue = create_venue(offerer) stock = create_stock_with_event_offer( offerer, venue, price=0, beginning_datetime=in_73_hours, end_datetime=in_74_hours, booking_limit_datetime=in_72_hours) booking = create_booking(user, stock, venue=venue) PcObject.save(admin_user, booking) url = '/bookings/token/{}?email={}&offer_id={}'.format( booking.token, '*****@*****.**', humanize(stock.offerId)) # When response = TestClient(app.test_client()).get(url) # Then assert response.status_code == 403 assert response.json['beginningDatetime'] == [ 'Vous ne pouvez pas valider cette contremarque plus de 72h avant le début de l\'évènement' ]
def test_offerer_cannot_update_a_second_venue_to_be_virtual(app): # Given siren = '132547698' offerer = create_offerer(siren, '1 rue Test', 'Test city', '93000', 'Test offerer') PcObject.save(offerer) venue = create_venue(offerer, address=None, postal_code=None, city=None, departement_code=None, is_virtual=True, siret=None) PcObject.save(venue) new_venue = create_venue(offerer, is_virtual=False, siret=siren + '98765') PcObject.save(new_venue) # When new_venue.isVirtual = True new_venue.postalCode = None new_venue.address = None new_venue.city = None new_venue.departementCode = None new_venue.siret = None # Then with pytest.raises(TooManyVirtualVenuesException): PcObject.save(new_venue)
def when_trying_to_patch_an_offer_than_cannot_be_updated(self, app): # given tite_live_provider = Provider \ .query \ .filter(Provider.localClass == 'TiteLiveThings') \ .first() user = create_user() offerer = create_offerer() user_offerer = create_user_offerer(user, offerer) venue = create_venue(offerer) offer = create_offer_with_thing_product( venue, booking_email='*****@*****.**', last_provider_id=tite_live_provider.id) PcObject.save(offer, user, user_offerer) json = { 'bookingEmail': '*****@*****.**', } # When response = TestClient(app.test_client()).with_auth( user.email).patch(f'{API_URL}/offers/{humanize(offer.id)}', json=json) # then assert response.status_code == 400 assert Offer.query.get(offer.id).bookingEmail == '*****@*****.**' assert response.json['global'] == [ "Les offres importées ne sont pas modifiables" ]
def test_return_only_not_soft_deleted_stock(self, app): # Given offerer = create_offerer() venue = create_venue(offerer) offer = create_offer_with_event_product(venue) event_occurrence = create_event_occurrence(offer) stock1 = create_stock_from_event_occurrence(event_occurrence) stock2 = create_stock_from_event_occurrence(event_occurrence) stock3 = create_stock_from_event_occurrence(event_occurrence) stock4 = create_stock_from_event_occurrence(event_occurrence) stock1.isSoftDeleted = True PcObject.save(stock1, stock2, stock3, stock4) # When request = handle_rest_get_list(Stock) # Then assert '"id":"{}"'.format(humanize(stock1.id)) not in str( request[0].response) assert '"id":"{}"'.format(humanize(stock2.id)) in str( request[0].response) assert '"id":"{}"'.format(humanize(stock3.id)) in str( request[0].response) assert '"id":"{}"'.format(humanize(stock4.id)) in str( request[0].response)
def when_user_updating_thing_offer_is_linked_to_same_owning_offerer( self, app): # Given user = create_user(email='*****@*****.**') owning_offerer = create_offerer() user_offerer = create_user_offerer(user, owning_offerer) venue = create_venue(owning_offerer) product = create_product_with_thing_type( thing_name='Old Name', owning_offerer=owning_offerer) offer = create_offer_with_thing_product(venue, product) PcObject.save(offer, user_offerer) offer_id = offer.id product_id = product.id json = {'name': 'New Name'} # When response = TestClient(app.test_client()).with_auth( user.email).patch(f'{API_URL}/offers/{humanize(offer_id)}', json=json) # Then assert response.status_code == 200 assert Offer.query.get(offer_id).name == 'New Name' assert Product.query.get(product_id).name == 'New Name'
def when_user_has_booked_some_offers(self, app): # Given user = create_user(public_name='Test', departement_code='93', email='*****@*****.**') offerer = create_offerer('999199987', '2 Test adress', 'Test city', '93000', 'Test offerer') venue = create_venue(offerer) thing_offer = create_offer_with_thing_product(venue=None) stock = create_stock_with_thing_offer(offerer, venue, thing_offer, price=5) recommendation = create_recommendation(thing_offer, user) deposit_1_date = datetime.utcnow() - timedelta(minutes=2) deposit_1 = create_deposit(user, amount=10) deposit_2_date = datetime.utcnow() - timedelta(minutes=2) deposit_2 = create_deposit(user, amount=10) booking = create_booking(user, stock, venue, recommendation, quantity=1) PcObject.save(user, venue, deposit_1, deposit_2, booking) # when response = TestClient(app.test_client()).with_auth('*****@*****.**').get('/users/current') # Then assert response.json['wallet_balance'] == 15 assert response.json['expenses'] == { 'all': {'max': 500, 'actual': 5.0}, 'physical': {'max': 200, 'actual': 5.0}, 'digital': {'max': 200, 'actual': 0} }
def test_create_filter_matching_all_keywords_in_any_models_with_several_partial_keywords_at_event_or_thing_or_venue_or_offerer_level( app): # given ok_event1 = create_product_with_event_type( event_name='Rencontre avec Jacques Martin') event2 = create_product_with_event_type( event_name='Concert de contrebasse') thing1 = create_product_with_thing_type(thing_name='Jacques la fripouille') thing2 = create_product_with_thing_type(thing_name='Belle du Seigneur') offerer = create_offerer() venue1 = create_venue(offerer, name='Bataclan', city='Paris', siret=offerer.siren + '12345') venue2 = create_venue(offerer, name='Librairie la Rencontre', city='Saint Denis', siret=offerer.siren + '54321') ok_offer1 = create_offer_with_event_product(venue1, ok_event1) ko_offer2 = create_offer_with_event_product(venue1, event2) ok_offer3 = create_offer_with_thing_product(venue2, thing1) ko_offer4 = create_offer_with_thing_product(venue2, thing2) PcObject.save(ok_offer1, ko_offer2, ok_offer3, ko_offer4) # when query = filter_offers_with_keywords_string(build_offer_search_base_query(), 'Jacq Rencon') # then found_offers = query.all() found_offers_id = [found_offer.id for found_offer in found_offers] assert ok_offer1.id in found_offers_id assert ko_offer2.id not in found_offers_id assert ok_offer3.id in found_offers_id assert ko_offer4.id not in found_offers_id
def test_returns_only_payment_total_by_department(self, app): # Given offerer = create_offerer(siren='111111111') venue = create_venue(offerer, postal_code='78490', siret='11111111100002') offer = create_offer_with_thing_product(venue) stock = create_stock(price=10, offer=offer) user_in_35 = create_user(email='*****@*****.**', departement_code='35') user_in_78 = create_user(email='*****@*****.**', departement_code='78') create_deposit(user_in_35, amount=500) create_deposit(user_in_78, amount=500) booking_in_35 = create_booking(user_in_35, stock=stock, venue=venue) booking_in_78 = create_booking(user_in_78, stock=stock, venue=venue) payment1 = create_payment(booking_in_35, offerer, amount=20) payment2 = create_payment(booking_in_78, offerer, amount=10) PcObject.save(user_in_35, venue, payment1, payment2) # When total_amount_to_pay = get_total_amount_to_pay('35') # Then assert total_amount_to_pay == 20
def when_mediation_is_not_found(self, app): # Given user = create_user(email='*****@*****.**') offerer = create_offerer() venue = create_venue(offerer, postal_code='29100', siret='12345678912341') offer = create_offer_with_thing_product(venue, thumb_count=0) mediation = create_mediation(offer, is_active=True) recommendation = create_recommendation(offer=offer, user=user, mediation=mediation, is_clicked=False) PcObject.save(recommendation, user) json = { 'offerId': humanize(offer.id), 'mediationId': 'ABCD', } # When response = TestClient(app.test_client()).with_auth( user.email).post(f'{API_URL}/favorites', json=json) # Then assert response.status_code == 404
def test_file_has_custom_message_id_in_group_header(self, app): # Given offerer = create_offerer() user = create_user() venue = create_venue(offerer) stock = create_stock_from_offer(create_offer_with_thing_product(venue)) booking = create_booking(user, stock) payment1 = create_payment(booking, offerer, Decimal(10), iban='CF13QSDFGH456789', bic='QSDFGH8Z555') payment2 = create_payment(booking, offerer, Decimal(20), iban='CF13QSDFGH456789', bic='QSDFGH8Z555') payments = [payment1, payment2] # When xml = generate_message_file(payments, 'BD12AZERTY123456', 'AZERTY9Q666', MESSAGE_ID, '0000') # Then assert find_node('//ns:GrpHdr/ns:MsgId', xml) == MESSAGE_ID, \ 'The message id should look like "passCulture-SCT-YYYYMMDD-HHMMSS"'