-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
51 lines (35 loc) · 1.1 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import os
import pytest
from src.ein.database import Database
from src.ein.graph import Graph
TEST_DB = "test.db"
TEST_SCHEMA = "test"
@pytest.fixture()
def db_setup():
"""Creates a workspace DB on use.
We don't want to return `sqlite3.Row` objects
because that's difficult to check values in, so
we return `Tuple` objects instead for hard comparisons.
"""
return Database(db_path=TEST_DB, row_factory=False)
@pytest.fixture()
def graph_setup(db_setup):
"""A `Graph` instance with no row factory."""
return Graph(db_path=TEST_DB)
@pytest.fixture()
def db_setup_row_factory():
"""Creates a workspace DB on use.
We want to return `sqlite3.Row` objects for
`Graph`, `Node`, and `Edge` tests.
"""
return Database(db_path=TEST_DB, row_factory=True)
@pytest.fixture()
def graph_setup_row_factory(db_setup_row_factory):
"""A `Graph` instance with a row factory."""
return Graph(db_path=TEST_DB)
@pytest.fixture(autouse=True)
def cleanup_run():
"""Removes workspaces on teardown."""
yield
if os.path.exists(TEST_DB):
os.remove(TEST_DB)