File size: 1,342 Bytes
ade4f6a
 
 
 
fa3606d
 
 
 
ade4f6a
 
 
 
 
 
 
6b3e951
30fe677
ade4f6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
52
53
54
from pytest import fixture
from playwright.sync_api import sync_playwright

from environment import *
from lib.app_runner import AppRunner
from lib.page_runner import PageRunner
from lib.report import AccuracyReport, DelayReport, LogReport
from lib.utils import get_time_str

@fixture(scope="session")
def log_file():
    if RUN_TYPE == RunType.electron:
        log_file = APP_LOG
    elif RUN_TYPE == RunType.code:
        log_file = CODE_LOG
    elif RUN_TYPE == RunType.dev:
        log_file = DEV_LOG
    else:
        raise TypeError(f"invalid run_type: {RUN_TYPE}")
    return log_file

@fixture(scope="session")
def app():
    app = AppRunner(RUN_TYPE)
    app.start()
    yield app
    app.stop()

@fixture(scope="module")
def page():
    with sync_playwright() as p:
        page = PageRunner(RUN_TYPE).start(p)
        yield page

@fixture(scope="module")
def accuracy_report(request):
    report = AccuracyReport()
    yield report
    report.to_csv(REPORTS_DIR/f"accuracy_report_{get_time_str()}.csv")

@fixture(scope="module")
def delay_report(request):
    report = DelayReport()
    yield report
    report.to_csv(REPORTS_DIR/f"delay_report_{get_time_str()}.csv")

@fixture(scope="session")
def log_report(request):
    report = LogReport()
    yield report
    report.to_csv(REPORTS_DIR/f"log_report_{get_time_str()}.csv")