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 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_create_filter_matching_all_keywords_in_any_models_with_several_partial_keywords_at_mixed_venue_or_offerer_level( app): # given event_product = create_product_with_event_type() thing_product = create_product_with_thing_type() offerer1 = create_offerer(name="Marxisme et Compagnie") offerer2 = create_offerer(name='Test', siren='123456788') offerer3 = create_offerer(name='Test', siren='123456787') offerer4 = create_offerer(name='Test', siren='123456786') ok_venue1 = create_venue(offerer1, name='Librairie Mimosa', siret=offerer1.siren + '54321') ko_venue2 = create_venue(offerer2, name='Pif et Hercule', siret=offerer2.siren + '12345') ko_venue3 = create_venue(offerer3, name='Librairie la Rencontre', city='Saint Denis', siret=offerer3.siren + '54321') ko_venue4 = create_venue(offerer4, name='Bataclan', city='Paris', siret=offerer4.siren + '12345') ok_offer1 = create_offer_with_event_product(ok_venue1, event_product) ko_offer2 = create_offer_with_event_product(ko_venue2, event_product) ok_offer3 = create_offer_with_thing_product(ok_venue1, thing_product) ko_offer4 = create_offer_with_thing_product(ko_venue2, thing_product) ko_offer5 = create_offer_with_event_product(ko_venue3, event_product) ko_offer6 = create_offer_with_event_product(ko_venue4, event_product) ko_offer7 = create_offer_with_thing_product(ko_venue3, thing_product) ko_offer8 = create_offer_with_thing_product(ko_venue4, thing_product) PcObject.save(ok_offer1, ko_offer2, ok_offer3, ko_offer4, ko_offer5, ko_offer6, ko_offer7, ko_offer8) # when query = filter_offers_with_keywords_string(build_offer_search_base_query(), 'Libra Marx') # 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 assert ko_offer5.id not in found_offers_id assert ko_offer6.id not in found_offers_id assert ko_offer7.id not in found_offers_id assert ko_offer8.id not in found_offers_id
def test_create_filter_matching_all_keywords_in_any_models_with_several_partial_keywords_at_venue_public_name_level( app): # given event = create_product_with_event_type() thing = create_product_with_thing_type() ok_offerer1 = create_offerer(name="La Rencontre") offerer2 = create_offerer(siren='123456788') offerer3 = create_offerer(siren='123456787') offerer4 = create_offerer(siren='123456786') ok_venue1 = create_venue(ok_offerer1, siret=ok_offerer1.siren + '54321', publicName='Un lieu trop chouette de ouf') venue2 = create_venue(offerer2, siret=offerer2.siren + '12345') ok_venue3 = create_venue(offerer3, name='Librairie la Rencontre', city='Saint Denis', siret=offerer3.siren + '54321', publicName='chouette endroit de ouf') venue4 = create_venue(offerer4, name='Bataclan', city='Paris', siret=offerer4.siren + '12345') ok_offer1 = create_offer_with_event_product(ok_venue1, event) ko_offer2 = create_offer_with_event_product(venue2, event) ok_offer3 = create_offer_with_thing_product(ok_venue1, thing) ko_offer4 = create_offer_with_thing_product(venue2, thing) ok_offer5 = create_offer_with_event_product(ok_venue3, event) ko_offer6 = create_offer_with_event_product(venue4, event) ok_offer7 = create_offer_with_thing_product(ok_venue3, thing) ko_offer8 = create_offer_with_thing_product(venue4, thing) PcObject.save(ok_offer1, ko_offer2, ok_offer3, ko_offer4, ok_offer5, ko_offer6, ok_offer7, ko_offer8) # when query = filter_offers_with_keywords_string(build_offer_search_base_query(), 'chou ou') # 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 assert ok_offer5.id in found_offers_id assert ko_offer6.id not in found_offers_id assert ok_offer7.id in found_offers_id assert ko_offer8.id not in found_offers_id