Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
c4b36d34
Commit
c4b36d34
authored
3 years ago
by
Tore.Brede
Browse files
Options
Downloads
Patches
Plain Diff
GREG-161: Adding a test
parent
279b7951
No related branches found
No related tags found
1 merge request
!228
GREG-161: Search birthdate and name
Pipeline
#109075
passed
3 years ago
Stage: venv update
Stage: tests and linting
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gregui/tests/api/views/test_search.py
+49
-1
49 additions, 1 deletion
gregui/tests/api/views/test_search.py
with
49 additions
and
1 deletion
gregui/tests/api/views/test_search.py
+
49
−
1
View file @
c4b36d34
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment