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
1e4285d3
Commit
1e4285d3
authored
3 years ago
by
Tore.Brede
Browse files
Options
Downloads
Patches
Plain Diff
GREG-5: Moving test database setup
parent
6aff7f7e
No related branches found
No related tags found
1 merge request
!12
GREG-5: Adding verified filter for persons
Pipeline
#88339
passed
3 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
greg/tests/api/test_person.py
+0
-12
0 additions, 12 deletions
greg/tests/api/test_person.py
greg/tests/conftest.py
+15
-0
15 additions, 0 deletions
greg/tests/conftest.py
with
15 additions
and
12 deletions
greg/tests/api/test_person.py
+
0
−
12
View file @
1e4285d3
...
@@ -7,7 +7,6 @@ from rest_framework.status import HTTP_200_OK
...
@@ -7,7 +7,6 @@ from rest_framework.status import HTTP_200_OK
from
rest_framework.test
import
APIClient
from
rest_framework.test
import
APIClient
from
greg.models
import
Person
from
greg.models
import
Person
from
greg.tests.populate_database
import
DatabasePopulation
@pytest.fixture
@pytest.fixture
...
@@ -41,17 +40,6 @@ def person_bar() -> Person:
...
@@ -41,17 +40,6 @@ def person_bar() -> Person:
)
)
# The database is populated once when scope is session.
# If the scope is changed to function some additional
# logic is needed to make sure the old data is cleaned
# before the seeding is run again
@pytest.fixture
(
scope
=
"
session
"
)
def
setup_db_test_data
(
django_db_setup
,
django_db_blocker
):
with
django_db_blocker
.
unblock
():
database_seeder
=
DatabasePopulation
()
database_seeder
.
populate_database
()
@pytest.mark.django_db
@pytest.mark.django_db
def
test_get_person
(
client
,
person_foo
):
def
test_get_person
(
client
,
person_foo
):
resp
=
client
.
get
(
reverse
(
"
person-detail
"
,
kwargs
=
{
"
id
"
:
person_foo
.
id
}))
resp
=
client
.
get
(
reverse
(
"
person-detail
"
,
kwargs
=
{
"
id
"
:
person_foo
.
id
}))
...
...
This diff is collapsed.
Click to expand it.
greg/tests/conftest.py
+
15
−
0
View file @
1e4285d3
...
@@ -3,4 +3,19 @@ import logging
...
@@ -3,4 +3,19 @@ import logging
# faker spams the logs with localisation warnings
# faker spams the logs with localisation warnings
# see https://github.com/joke2k/faker/issues/753
# see https://github.com/joke2k/faker/issues/753
import
pytest
from
greg.tests.populate_database
import
DatabasePopulation
logging
.
getLogger
(
"
faker
"
).
setLevel
(
logging
.
ERROR
)
logging
.
getLogger
(
"
faker
"
).
setLevel
(
logging
.
ERROR
)
# The database is populated once when scope is session.
# If the scope is changed to function some additional
# logic is needed to make sure the old data is cleaned
# before the seeding is run again
@pytest.fixture
(
scope
=
"
session
"
)
def
setup_db_test_data
(
django_db_setup
,
django_db_blocker
):
with
django_db_blocker
.
unblock
():
database_seeder
=
DatabasePopulation
()
database_seeder
.
populate_database
()
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