summaryrefslogtreecommitdiff
path: root/tests/conftest.py
blob: 0028475f6b0d3ac5000c8e9affc5cd264d40b2c3 (plain)
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
import os

import pytest

from db.db_manager import DbManager


@pytest.fixture(scope="module")
def database(request):
    database = DbManager(
        db=os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "test.db"))

    def fin():
        database.close()

    request.addfinalizer(fin)

    return database


@pytest.fixture(scope="module")
def test_file():
    test_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             "test.ogg")

    return test_file


@pytest.fixture(scope="class")
def app(request):
    db = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                      "testapp.db")
    library_db = DbManager(
        db=os.path.join(os.path.dirname(os.path.realpath(__file__)),
                        "test.db"))

    def fin():
        library_db.close()

    request.addfinalizer(fin)

    request.cls.db = db
    request.cls.library_db = library_db