Skip to content
Snippets Groups Projects
Commit c4b36d34 authored by Tore.Brede's avatar Tore.Brede
Browse files

GREG-161: Adding a test

parent 279b7951
No related branches found
No related tags found
1 merge request!228GREG-161: Search birthdate and name
Pipeline #109075 passed
...@@ -28,18 +28,32 @@ def test_date_of_birth_search(client, log_in, user_sponsor, create_person): ...@@ -28,18 +28,32 @@ def test_date_of_birth_search(client, log_in, user_sponsor, create_person):
email="foo@bar.com", email="foo@bar.com",
date_of_birth="2005-06-20", date_of_birth="2005-06-20",
) )
person2 = create_person(
first_name="test",
last_name="tester",
email="test@example.org",
date_of_birth="2005-10-20",
)
# A person with no date of birth set
person3 = create_person(
first_name="test2",
last_name="tester2",
email="test2@example.org",
)
url = reverse("gregui-v1:person-search") + "?q=2005-06-20" url = reverse("gregui-v1:person-search") + "?q=2005-06-20"
log_in(user_sponsor) log_in(user_sponsor)
response = client.get(url) response = client.get(url)
assert response.status_code == status.HTTP_200_OK
assert len(response.data) == 1 assert len(response.data) == 1
person_ids = list(map(lambda x: x["pid"], response.data)) person_ids = list(map(lambda x: x["pid"], response.data))
assert person.id in person_ids assert person.id in person_ids
assert response.status_code == status.HTTP_200_OK assert person2.id not in person_ids
assert person3.id not in person_ids
@pytest.mark.django_db @pytest.mark.django_db
...@@ -81,3 +95,37 @@ def test_multiple_words_search(client, log_in, user_sponsor, create_person): ...@@ -81,3 +95,37 @@ def test_multiple_words_search(client, log_in, user_sponsor, create_person):
assert person3.id in person_ids assert person3.id in person_ids
assert person4.id not in person_ids assert person4.id not in person_ids
assert response.status_code == status.HTTP_200_OK assert response.status_code == status.HTTP_200_OK
@pytest.mark.django_db
def test_no_match(client, log_in, user_sponsor, create_person):
create_person(
first_name="foo",
last_name="bar",
email="example@company.com",
)
create_person(
first_name="test",
last_name="test2",
email="foo@bar.com",
date_of_birth="2006-06-20",
)
create_person(
first_name="Bob",
last_name="Smith",
email="bob@smith.com",
date_of_birth="2005-06-20",
)
create_person(
first_name="Frank",
last_name="Paulsen",
email="frank@paulsen.com",
)
url = reverse("gregui-v1:person-search") + "?q=æøå"
log_in(user_sponsor)
response = client.get(url)
assert response.status_code == status.HTTP_200_OK
assert len(response.data) == 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment