Database Fixtures
Let’s learn how to implement and execute test suites with integration.
When we define the database configuration in a JSON file, we need a fixture that loads that same configuration. This is so we can connect to the database during our tests. Since we already have the function read_json_configuration
in our management script, all we need to do is wrap it.
Update the conftest file
Update the common conftest file
This is a fixture that isn’t specific to the PostgreSQL repository, so we’ll introduce it in the following code.
Press + to interact
from manage import read_json_configuration...@pytest.fixture(scope="session")def app_configuration():return read_json_configuration("testing")
As we can see in the code above, we hardcode the name of the configuration file for the sake of simplicity. Alternately, we can also create an environment variable with the application configuration in the management ...
Access this course and 1400+ top-rated courses and projects.