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

GREG-5: Moving test database setup

parent 6aff7f7e
No related branches found
No related tags found
1 merge request!12GREG-5: Adding verified filter for persons
Pipeline #88339 passed
...@@ -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}))
......
...@@ -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()
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