def test_contact_module_search_multishop(rf): with override_settings(SHUUP_MANAGE_CONTACTS_PER_SHOP=True, SHUUP_ENABLE_MULTIPLE_SHOPS=True): staff_user = create_random_user(is_staff=True) shop1 = get_shop(identifier="shop-1", enabled=True) shop2 = get_shop(identifier="shop-2", enabled=True) shop1.staff_members.add(staff_user) shop2.staff_members.add(staff_user) cm = ContactModule() contact = create_random_person(locale="en_US", minimum_name_comp_len=5) contact.add_to_shop(shop2) request = apply_request_middleware(rf.get("/"), user=staff_user, shop=shop2) # find the shop assert not empty_iterable( cm.get_search_results(request, query=contact.email)) assert not empty_iterable( cm.get_search_results(request, query=contact.first_name)) # no shop found request = apply_request_middleware(rf.get("/"), user=staff_user, shop=shop1) assert empty_iterable( cm.get_search_results(request, query=contact.email))
def test_contact_module_search(rf): cm = ContactModule() # This test has a chance to fail if the random person is from a strange locale # and the database does not like it. Therefore, use `en_US` here... contact = create_random_person(locale="en_US", minimum_name_comp_len=5) request = rf.get("/") assert not empty_iterable(cm.get_search_results(request, query=contact.email)) assert not empty_iterable(cm.get_search_results(request, query=contact.first_name)) assert empty_iterable(cm.get_search_results(request, query=contact.email[0]))
def test_contact_module_search(rf, admin_user): shop = get_default_shop() cm = ContactModule() # This test has a chance to fail if the random person is from a strange locale # and the database does not like it. Therefore, use `en_US` here... contact = create_random_person(locale="en_US", minimum_name_comp_len=5) company = create_random_company(shop) request = apply_request_middleware(rf.get("/"), user=admin_user) assert not empty_iterable(cm.get_search_results(request, query=contact.email)) assert not empty_iterable(cm.get_search_results(request, query=contact.first_name)) assert not empty_iterable(cm.get_search_results(request, query=company.name)) assert empty_iterable(cm.get_search_results(request, query="/"))
def test_contact_module_search_multishop(rf): with override_settings(SHUUP_MANAGE_CONTACTS_PER_SHOP=True, SHUUP_ENABLE_MULTIPLE_SHOPS=True): staff_user = create_random_user(is_staff=True) shop1 = get_shop(identifier="shop-1", enabled=True) shop2 = get_shop(identifier="shop-2", enabled=True) shop1.staff_members.add(staff_user) shop2.staff_members.add(staff_user) cm = ContactModule() contact = create_random_person(locale="en_US", minimum_name_comp_len=5) contact.add_to_shop(shop2) request = apply_request_middleware(rf.get("/"), user=staff_user, shop=shop2) # find the shop assert not empty_iterable(cm.get_search_results(request, query=contact.email)) assert not empty_iterable(cm.get_search_results(request, query=contact.first_name)) # no shop found request = apply_request_middleware(rf.get("/"), user=staff_user, shop=shop1) assert empty_iterable(cm.get_search_results(request, query=contact.email))