Projekt

Obecné

Profil

Stáhnout (2.29 KB) Statistiky
| Větev: | Tag: | Revize:
1
import os
2
import sqlite3
3
from sqlite3 import Connection
4

    
5
import pytest
6

    
7
from src.config.configuration import test_configuration
8
from src.config.connection_provider import ConnectionProvider
9
from src.dao.certificate_repository import CertificateRepository
10
from src.dao.private_key_repository import PrivateKeyRepository
11
from src.db.init_queries import SCHEMA_SQL, DEFAULT_VALUES_SQL
12
from src.services.certificate_service import CertificateService
13
from src.services.cryptography import CryptographyService
14
from src.services.key_service import KeyService
15

    
16

    
17
# scope="module" means that this fixture is run once per module
18
@pytest.fixture(scope="module")
19
def connection():
20
    return ConnectionProvider().connect(test_configuration())
21

    
22

    
23
# scope defaults to "function" which means that the fixture is run once per test (function)
24
@pytest.fixture
25
def certificate_repository(connection):
26
    return CertificateRepository(connection)
27

    
28

    
29
@pytest.fixture
30
def private_key_repository(connection):
31
    return PrivateKeyRepository(connection)
32

    
33

    
34
@pytest.fixture
35
def cryptography_service():
36
    return CryptographyService()
37

    
38

    
39
@pytest.fixture
40
def private_key_service(private_key_repository, cryptography_service):
41
    return KeyService(cryptography_service, private_key_repository)
42

    
43

    
44
@pytest.fixture
45
def certificate_service(certificate_repository, cryptography_service):
46
    return CertificateService(cryptography_service, certificate_repository)
47

    
48

    
49
@pytest.fixture
50
def connection_unique():
51
    return ConnectionProvider().connect(test_configuration())
52

    
53

    
54
# scope defaults to "function" which means that the fixture is run once per test (function)
55
@pytest.fixture
56
def certificate_repository_unique(connection_unique):
57
    return CertificateRepository(connection_unique)
58

    
59

    
60
@pytest.fixture
61
def private_key_repository_unique(connection_unique):
62
    return PrivateKeyRepository(connection_unique)
63

    
64

    
65
@pytest.fixture
66
def cryptography_service_unique():
67
    return CryptographyService()
68

    
69

    
70
@pytest.fixture
71
def private_key_service_unique(private_key_repository_unique, cryptography_service_unique):
72
    return KeyService(cryptography_service_unique, private_key_repository_unique)
73

    
74

    
75
@pytest.fixture
76
def certificate_service_unique(certificate_repository_unique, cryptography_service_unique):
77
    return CertificateService(cryptography_service_unique, certificate_repository_unique)
(3-3/4)