-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
29 lines (25 loc) · 1.07 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
import pytest
import os
from typing import List
from fasthtml.common import Client, FastHTML, database
from tractor import connect_tractor
TEST_DATABASE = 'data/test-database.db'
SOURCE_DATABASE = 'data/tractor.db'
@pytest.fixture
def test_client() -> Client:
if os.path.exists(TEST_DATABASE): os.remove(TEST_DATABASE)
with open(SOURCE_DATABASE, 'rb') as source:
with open(TEST_DATABASE, 'wb') as target: target.write(source.read())
return Client(app=connect_tractor(app=FastHTML(), connection=database(TEST_DATABASE).conn))
@pytest.fixture
def test_db() -> Client:
if os.path.exists(TEST_DATABASE): os.remove(TEST_DATABASE)
with open(SOURCE_DATABASE, 'rb') as source:
with open(TEST_DATABASE, 'wb') as target: target.write(source.read())
return database(TEST_DATABASE)
@pytest.fixture
def test_table_names() -> List[str]:
# XX: skipping 'sqlite_stat1'
ts = ['albums', 'sqlite_sequence', 'artists', 'customers', 'employees', 'genres', 'invoices', 'invoice_items', 'media_types', 'playlists', 'playlist_track', 'tracks']
ts.sort()
return ts