1 |
163f57d0
|
David Friesecký
|
import pytest
|
2 |
|
|
import sqlite3
|
3 |
|
|
from sqlite3 import Connection, Cursor
|
4 |
|
|
|
5 |
f8581e41
|
Stanislav Král
|
from src.config.configuration import test_configuration
|
6 |
|
|
from src.config.connection_provider import ConnectionProvider
|
7 |
163f57d0
|
David Friesecký
|
from src.dao.certificate_repository import CertificateRepository
|
8 |
|
|
from src.dao.private_key_repository import PrivateKeyRepository
|
9 |
|
|
from src.db.init_queries import SCHEMA_SQL, DEFAULT_VALUES_SQL
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
# scope="module" means that this fixture is run once per module
|
13 |
|
|
@pytest.fixture(scope="module")
|
14 |
|
|
def connection():
|
15 |
f8581e41
|
Stanislav Král
|
return ConnectionProvider().connect(test_configuration())
|
16 |
163f57d0
|
David Friesecký
|
|
17 |
|
|
|
18 |
6654bf8b
|
David Friesecký
|
@pytest.fixture(scope="module")
|
19 |
163f57d0
|
David Friesecký
|
def cursor(connection):
|
20 |
f8581e41
|
Stanislav Král
|
return connection.cursor()
|
21 |
163f57d0
|
David Friesecký
|
|
22 |
|
|
|
23 |
6654bf8b
|
David Friesecký
|
@pytest.fixture
|
24 |
|
|
def connection_unique():
|
25 |
f8581e41
|
Stanislav Král
|
return ConnectionProvider().connect(test_configuration())
|
26 |
6654bf8b
|
David Friesecký
|
|
27 |
|
|
|
28 |
|
|
@pytest.fixture
|
29 |
|
|
def cursor_unique(connection):
|
30 |
f8581e41
|
Stanislav Král
|
return connection.cursor()
|
31 |
6654bf8b
|
David Friesecký
|
|
32 |
|
|
|
33 |
163f57d0
|
David Friesecký
|
@pytest.fixture
|
34 |
f8581e41
|
Stanislav Král
|
def certificate_repository(connection):
|
35 |
|
|
return CertificateRepository(connection)
|
36 |
|
|
|
37 |
163f57d0
|
David Friesecký
|
|
38 |
|
|
@pytest.fixture
|
39 |
f8581e41
|
Stanislav Král
|
def private_key_repository_unique(connection_unique, cursor_unique):
|
40 |
|
|
return PrivateKeyRepository(connection_unique)
|