commit f8581e413dcfe4cb957e09151ef072a3c2b12805
Author: Stanislav Král <stanislav.kral3@gmail.com>
Date:   Wed Apr 14 17:17:34 2021 +0200

    Fixed failing tests after performing a merge.

diff --git a/tests/integration_tests/dao/certificate_repository_test.py b/tests/integration_tests/dao/certificate_repository_test.py
index f03a3f9..5226854 100644
--- a/tests/integration_tests/dao/certificate_repository_test.py
+++ b/tests/integration_tests/dao/certificate_repository_test.py
@@ -4,9 +4,9 @@ from src.model.certificate import Certificate
 from src.model.private_key import PrivateKey
 
 
-def test_set_certificate_revoked(certificate_repository, private_key_repository):
+def test_set_certificate_revoked(certificate_repository, private_key_repository_unique):
     private_key = PrivateKey(private_key_id=-1, private_key="test_pk", password="test_password")
-    private_key_id = private_key_repository.create(private_key)
+    private_key_id = private_key_repository_unique.create(private_key)
 
     assert type(private_key_id) is int
 
@@ -45,9 +45,9 @@ def test_set_certificate_revoked(certificate_repository, private_key_repository)
     assert certificate.revocation_reason == REV_REASON_UNSPECIFIED
 
 
-def test_clear_certificate_revocation(certificate_repository, private_key_repository):
+def test_clear_certificate_revocation(certificate_repository, private_key_repository_unique):
     private_key = PrivateKey(private_key_id=-1, private_key="test_pk", password="test_password")
-    private_key_id = private_key_repository.create(private_key=private_key)
+    private_key_id = private_key_repository_unique.create(private_key=private_key)
 
     assert type(private_key_id) is int
 
@@ -84,9 +84,9 @@ def test_clear_certificate_revocation(certificate_repository, private_key_reposi
     assert certificate.revocation_reason == ""
 
 
-def test_get_all_revoked_by(certificate_repository, private_key_repository):
+def test_get_all_revoked_by(certificate_repository, private_key_repository_unique):
     private_key = PrivateKey(private_key_id=-1, private_key="test_pk", password="test_password")
-    private_key_id = private_key_repository.create(private_key=private_key)
+    private_key_id = private_key_repository_unique.create(private_key=private_key)
 
     assert type(private_key_id) is int
 
@@ -139,9 +139,9 @@ def test_get_all_revoked_by(certificate_repository, private_key_repository):
     assert certificates[0].certificate_id == child_1_id and certificates[1].certificate_id == child_3_id
 
 
-def test_get_all_issued_by(certificate_repository, private_key_repository):
+def test_get_all_issued_by(certificate_repository, private_key_repository_unique):
     private_key = PrivateKey(private_key_id=-1, private_key="test_pk", password="test_password")
-    private_key_id = private_key_repository.create(private_key=private_key)
+    private_key_id = private_key_repository_unique.create(private_key=private_key)
 
     assert type(private_key_id) is int
 
diff --git a/tests/integration_tests/dao/conftest.py b/tests/integration_tests/dao/conftest.py
index 1ac0610..476ffcd 100644
--- a/tests/integration_tests/dao/conftest.py
+++ b/tests/integration_tests/dao/conftest.py
@@ -2,6 +2,8 @@ import pytest
 import sqlite3
 from sqlite3 import Connection, Cursor
 
+from src.config.configuration import test_configuration
+from src.config.connection_provider import ConnectionProvider
 from src.dao.certificate_repository import CertificateRepository
 from src.dao.private_key_repository import PrivateKeyRepository
 from src.db.init_queries import SCHEMA_SQL, DEFAULT_VALUES_SQL
@@ -10,50 +12,29 @@ from src.db.init_queries import SCHEMA_SQL, DEFAULT_VALUES_SQL
 # scope="module" means that this fixture is run once per module
 @pytest.fixture(scope="module")
 def connection():
-    print("Creating a new SQLITE connection to the test DB")
-    connection: Connection = sqlite3.connect(':memory:')
-
-    # yield the created connection
-    yield connection
+    return ConnectionProvider().connect(test_configuration())
 
 
 @pytest.fixture(scope="module")
 def cursor(connection):
-    cursor = connection.cursor()
-
-    # execute db initialisation script
-    cursor.executescript(SCHEMA_SQL)
+    return connection.cursor()
 
-    # insert default values
-    cursor.executescript(DEFAULT_VALUES_SQL)
-
-    return cursor
 
 @pytest.fixture
 def connection_unique():
-    print("Creating a new SQLITE connection to the test DB")
-    connection: Connection = sqlite3.connect(':memory:')
-
-    # yield the created connection
-    yield connection
+    return ConnectionProvider().connect(test_configuration())
 
 
 @pytest.fixture
 def cursor_unique(connection):
-    cursor = connection.cursor()
+    return connection.cursor()
 
-    # execute db initialisation script
-    cursor.executescript(SCHEMA_SQL)
-
-    # insert default values
-    cursor.executescript(DEFAULT_VALUES_SQL)
-
-    return cursor
 
 @pytest.fixture
-def certificate_repository(connection, cursor):
-    return CertificateRepository(connection, cursor)
+def certificate_repository(connection):
+    return CertificateRepository(connection)
+
 
 @pytest.fixture
-def private_key_repository(connection_unique, cursor_unique):
-    return PrivateKeyRepository(connection_unique, cursor_unique)
+def private_key_repository_unique(connection_unique, cursor_unique):
+    return PrivateKeyRepository(connection_unique)
diff --git a/tests/integration_tests/dao/private_key_repository_test.py b/tests/integration_tests/dao/private_key_repository_test.py
index 206e060..0d65399 100644
--- a/tests/integration_tests/dao/private_key_repository_test.py
+++ b/tests/integration_tests/dao/private_key_repository_test.py
@@ -4,7 +4,7 @@ from src.model.certificate import Certificate
 from src.model.private_key import PrivateKey
 
 
-def test_create(private_key_repository):
+def test_create(private_key_repository_unique):
     private_key_1 = PrivateKey(private_key_id=-1, private_key="test_private_key_1", password="test_password_1")
     private_key_2 = PrivateKey(private_key_id=-1, private_key="test_private_key_2")
 
@@ -16,14 +16,14 @@ def test_create(private_key_repository):
     assert private_key_2.private_key == "test_private_key_2"
     assert private_key_2.password is None
 
-    private_key_1_id = private_key_repository.create(private_key=private_key_1)
-    private_key_2_id = private_key_repository.create(private_key=private_key_2)
+    private_key_1_id = private_key_repository_unique.create(private_key=private_key_1)
+    private_key_2_id = private_key_repository_unique.create(private_key=private_key_2)
 
     assert type(private_key_1_id) is int
     assert type(private_key_2_id) is int
 
-    private_key_1 = private_key_repository.read(private_key_id=private_key_1_id)
-    private_key_2 = private_key_repository.read(private_key_id=private_key_2_id)
+    private_key_1 = private_key_repository_unique.read(private_key_id=private_key_1_id)
+    private_key_2 = private_key_repository_unique.read(private_key_id=private_key_2_id)
 
     assert private_key_1.private_key_id == private_key_1_id
     assert private_key_1.private_key == "test_private_key_1"
@@ -34,42 +34,42 @@ def test_create(private_key_repository):
     assert private_key_2.password is None
 
 
-def test_read(private_key_repository):
+def test_read(private_key_repository_unique):
     private_key = PrivateKey(private_key_id=-1, private_key="test_private_key", password="test_password")
 
-    private_key_id = private_key_repository.create(private_key=private_key)
+    private_key_id = private_key_repository_unique.create(private_key=private_key)
 
     assert type(private_key_id) is int
 
-    private_key = private_key_repository.read(private_key_id=private_key_id)
+    private_key = private_key_repository_unique.read(private_key_id=private_key_id)
 
     assert private_key.private_key_id == private_key_id
     assert private_key.private_key == "test_private_key"
     assert private_key.password == "test_password"
 
 
-def test_read_invalid_id(private_key_repository):
+def test_read_invalid_id(private_key_repository_unique):
     none_id = 100
-    private_key = private_key_repository.read(private_key_id=none_id)
+    private_key = private_key_repository_unique.read(private_key_id=none_id)
 
     assert private_key is None
 
 
-def test_read_all(private_key_repository):
-    private_keys = private_key_repository.read_all()
+def test_read_all(private_key_repository_unique):
+    private_keys = private_key_repository_unique.read_all()
 
     assert len(private_keys) == 0
 
     private_key_1 = PrivateKey(private_key_id=-1, private_key="test_private_key_1", password="test_password_1")
     private_key_2 = PrivateKey(private_key_id=-1, private_key="test_private_key_2")
 
-    private_key_1_id = private_key_repository.create(private_key=private_key_1)
-    private_key_2_id = private_key_repository.create(private_key=private_key_2)
+    private_key_1_id = private_key_repository_unique.create(private_key=private_key_1)
+    private_key_2_id = private_key_repository_unique.create(private_key=private_key_2)
 
     assert type(private_key_1_id) is int
     assert type(private_key_2_id) is int
 
-    private_keys = private_key_repository.read_all()
+    private_keys = private_key_repository_unique.read_all()
 
     assert len(private_keys) == 2
 
@@ -82,14 +82,14 @@ def test_read_all(private_key_repository):
     assert private_keys[1].password is None
 
 
-def test_update(private_key_repository):
+def test_update(private_key_repository_unique):
     private_key = PrivateKey(private_key_id=-1, private_key="test_private_key")
 
-    private_key_id = private_key_repository.create(private_key=private_key)
+    private_key_id = private_key_repository_unique.create(private_key=private_key)
 
     assert type(private_key_id) is int
 
-    private_key = private_key_repository.read(private_key_id=private_key_id)
+    private_key = private_key_repository_unique.read(private_key_id=private_key_id)
 
     assert private_key.private_key_id == private_key_id
     assert private_key.private_key == "test_private_key"
@@ -97,25 +97,25 @@ def test_update(private_key_repository):
 
     private_key.password = "test_password"
 
-    check_updated = private_key_repository.update(private_key_id=private_key_id, private_key=private_key)
+    check_updated = private_key_repository_unique.update(private_key_id=private_key_id, private_key=private_key)
 
     assert check_updated is True
 
-    private_key = private_key_repository.read(private_key_id=private_key_id)
+    private_key = private_key_repository_unique.read(private_key_id=private_key_id)
 
     assert private_key.private_key_id == private_key_id
     assert private_key.private_key == "test_private_key"
     assert private_key.password == "test_password"
 
 
-def test_update_invalid_id(private_key_repository):
+def test_update_invalid_id(private_key_repository_unique):
     private_key = PrivateKey(private_key_id=-1, private_key="test_private_key")
 
-    private_key_id = private_key_repository.create(private_key=private_key)
+    private_key_id = private_key_repository_unique.create(private_key=private_key)
 
     assert type(private_key_id) is int
 
-    private_key = private_key_repository.read(private_key_id=private_key_id)
+    private_key = private_key_repository_unique.read(private_key_id=private_key_id)
 
     assert private_key.private_key_id == private_key_id
     assert private_key.private_key == "test_private_key"
@@ -124,21 +124,21 @@ def test_update_invalid_id(private_key_repository):
     private_key.password = "test_password"
 
     none_id = 100
-    check_updated = private_key_repository.update(private_key_id=none_id, private_key=private_key)
+    check_updated = private_key_repository_unique.update(private_key_id=none_id, private_key=private_key)
 
     assert check_updated is False
 
-def test_delete(private_key_repository):
+def test_delete(private_key_repository_unique):
     private_key_1 = PrivateKey(private_key_id=-1, private_key="test_private_key_1", password="test_password_1")
     private_key_2 = PrivateKey(private_key_id=-1, private_key="test_private_key_2")
 
-    private_key_1_id = private_key_repository.create(private_key=private_key_1)
-    private_key_2_id = private_key_repository.create(private_key=private_key_2)
+    private_key_1_id = private_key_repository_unique.create(private_key=private_key_1)
+    private_key_2_id = private_key_repository_unique.create(private_key=private_key_2)
 
     assert type(private_key_1_id) is int
     assert type(private_key_2_id) is int
 
-    private_keys = private_key_repository.read_all()
+    private_keys = private_key_repository_unique.read_all()
 
     assert len(private_keys) == 2
 
@@ -150,9 +150,9 @@ def test_delete(private_key_repository):
     assert private_keys[1].private_key == "test_private_key_2"
     assert private_keys[1].password is None
 
-    check_deleted = private_key_repository.delete(private_key_id=private_key_1_id)
+    check_deleted = private_key_repository_unique.delete(private_key_id=private_key_1_id)
 
-    private_keys = private_key_repository.read_all()
+    private_keys = private_key_repository_unique.read_all()
 
     assert len(private_keys) == 1
 
