Skip to content

Feat: use PostgreSQL for the database backend #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Empty file.
Empty file.
309 changes: 309 additions & 0 deletions pems/core/management/commands/ensure_db.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ preserve_blank_lines = true
use_gitignore = true

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "pems.settings"
DJANGO_SETTINGS_MODULE = "tests.pytest.settings"

[tool.setuptools.packages.find]
include = ["pems*"]
Expand Down
Empty file.
Empty file.
35 changes: 35 additions & 0 deletions tests/pytest/pems/core/management/commands/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import psycopg
import pytest


@pytest.fixture
def mock_psycopg_cursor(mocker):
cursor = mocker.MagicMock(spec=psycopg.Cursor)
cursor.fetchone.return_value = None
cursor.close = mocker.MagicMock()
return cursor


@pytest.fixture
def mock_admin_connection(mocker, mock_psycopg_cursor):
connection = mocker.MagicMock(spec=psycopg.Connection)
connection.cursor.return_value = mock_psycopg_cursor
connection.closed = False

def mock_close():
connection.closed = True

connection.close = mock_close
return connection


@pytest.fixture
def mock_os_environ(mocker):
env_dict = {}
mocker.patch("os.environ", env_dict)
return env_dict


@pytest.fixture
def mock_psycopg_connect(mocker):
return mocker.patch("psycopg.connect")
Loading