Skip to content

Commit 1799b53

Browse files
committed
Create conftest for common fixtures
1 parent d17ff5e commit 1799b53

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

tests/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import os
2+
3+
from sqlmodel import create_engine
4+
5+
url = (
6+
f"postgresql://{os.environ['POSTGRES_USER']}:{os.environ['POSTGRES_PASSWORD']}"
7+
f"@{os.environ['POSTGRES_HOST']}:{os.environ['POSTGRES_PORT']}/{os.environ['POSTGRES_DB']}"
8+
)
9+
10+
engine = create_engine(url)

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import pytest
2+
3+
from murfey.util.db import clear, setup
4+
from tests import url
5+
6+
7+
@pytest.fixture
8+
def start_postgres():
9+
clear(url)
10+
setup(url)

tests/workflows/spa/test_flush_spa_preprocess.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
1-
import os
21
from unittest import mock
32

4-
import pytest
5-
from sqlalchemy import Session, create_engine, select
3+
from sqlmodel import Session, select
64

7-
from murfey.util.db import DataCollectionGroup, GridSquare, clear, setup
5+
from murfey.util.db import DataCollectionGroup, GridSquare
86
from murfey.util.models import GridSquareParameters
97
from murfey.workflows.spa import flush_spa_preprocess
10-
11-
url = (
12-
f"postgresql://{os.environ['POSTGRES_USER']}:{os.environ['POSTGRES_PASSWORD']}"
13-
f"@{os.environ['POSTGRES_HOST']}:{os.environ['POSTGRES_PORT']}/{os.environ['POSTGRES_DB']}"
14-
)
15-
16-
17-
@pytest.fixture
18-
def start_postgres():
19-
clear(url)
20-
setup(url)
21-
22-
23-
engine = create_engine(url)
8+
from tests import engine
249

2510

2611
@mock.patch("murfey.workflows.spa.flush_spa_preprocess._transport_object")

0 commit comments

Comments
 (0)