@pytest.mark.django_db
def test_multiselect_inactive_users_and_contacts(rf, regular_user):
 view = MultiselectAjaxView.as_view()
 assert ('joe' in regular_user.username)
 results = _get_search_results(rf, view, 'auth.User', 'joe')
 assert (len(results) == 1)
 assert (results[0].get('id') == regular_user.id)
 assert (results[0].get('name') == regular_user.username)
 contact = PersonContact.objects.create(first_name='Joe', last_name='Somebody')
 results = _get_search_results(rf, view, 'shuup.PersonContact', 'joe')
 assert (len(results) == 1)
 assert (results[0].get('id') == contact.id)
 assert (results[0].get('name') == contact.name)
 contact.is_active = False
 contact.save()
 results = _get_search_results(rf, view, 'shuup.PersonContact', 'joe')
 assert (len(results) == 0)

@ pytest . mark . django_db def test_multiselect_inactive_users_and_contacts ( rf , regular_user ) : view = MultiselectAjaxView . as_view ( ) assert ( 'joe' in regular_user . username ) results = _get_search_results ( rf , view , 'auth.User' , 'joe' ) assert ( len ( results ) == 1 ) assert ( results [ 0 ] . get ( 'id' ) == regular_user . id ) assert ( results [ 0 ] . get ( 'name' ) == regular_user . username ) contact = PersonContact . objects . create ( first_name = 'Joe' , last_name = 'Somebody' ) results = _get_search_results ( rf , view , 'shuup.PersonContact' , 'joe' ) assert ( len ( results ) == 1 ) assert ( results [ 0 ] . get ( 'id' ) == contact . id ) assert ( results [ 0 ] . get ( 'name' ) == contact . name ) contact . is_active = False contact . save ( ) results = _get_search_results ( rf , view , 'shuup.PersonContact' , 'joe' ) assert ( len ( results ) == 0 )
make sure inactive users and contacts are filtered from search results .