refactor: move code to lib
Browse files- lib/__init__.py +0 -0
- app_runner.py β lib/app_runner.py +0 -0
- audio.py β lib/audio.py +0 -0
- log_parser.py β lib/log_parser.py +0 -0
- page_runner.py β lib/page_runner.py +0 -0
- pages.py β lib/pages.py +2 -2
- report.py β lib/report.py +2 -2
- utils.py β lib/utils.py +0 -0
- main.py +1 -9
- scripts/test_pages.py +2 -4
- tests/conftest.py +4 -9
- tests/test_accuracy.py +3 -3
- tests/test_delay.py +3 -3
- tests/test_logfile.py +0 -4
lib/__init__.py
ADDED
|
File without changes
|
app_runner.py β lib/app_runner.py
RENAMED
|
File without changes
|
audio.py β lib/audio.py
RENAMED
|
File without changes
|
log_parser.py β lib/log_parser.py
RENAMED
|
File without changes
|
page_runner.py β lib/page_runner.py
RENAMED
|
File without changes
|
pages.py β lib/pages.py
RENAMED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
from datetime import datetime
|
| 2 |
from time import sleep
|
| 3 |
-
from typing import List
|
| 4 |
from playwright.sync_api import Page
|
| 5 |
|
| 6 |
-
from log_parser import WebItem
|
| 7 |
|
| 8 |
|
| 9 |
class TranslatorPage:
|
|
|
|
| 1 |
from datetime import datetime
|
| 2 |
from time import sleep
|
| 3 |
+
from typing import List
|
| 4 |
from playwright.sync_api import Page
|
| 5 |
|
| 6 |
+
from lib.log_parser import WebItem
|
| 7 |
|
| 8 |
|
| 9 |
class TranslatorPage:
|
report.py β lib/report.py
RENAMED
|
@@ -2,8 +2,8 @@ from typing import List
|
|
| 2 |
from dataclasses import dataclass, astuple
|
| 3 |
|
| 4 |
from tabulate import tabulate
|
| 5 |
-
from log_parser import LogTag, LogItem, WebItem
|
| 6 |
-
from utils import save_csv, run_textdistance, highlight_diff
|
| 7 |
|
| 8 |
@dataclass
|
| 9 |
class Row:
|
|
|
|
| 2 |
from dataclasses import dataclass, astuple
|
| 3 |
|
| 4 |
from tabulate import tabulate
|
| 5 |
+
from lib.log_parser import LogTag, LogItem, WebItem
|
| 6 |
+
from lib.utils import save_csv, run_textdistance, highlight_diff
|
| 7 |
|
| 8 |
@dataclass
|
| 9 |
class Row:
|
utils.py β lib/utils.py
RENAMED
|
File without changes
|
main.py
CHANGED
|
@@ -1,13 +1,5 @@
|
|
| 1 |
-
from report import LogReport
|
| 2 |
-
from audio import play_audio
|
| 3 |
import time
|
| 4 |
-
import
|
| 5 |
-
import subprocess
|
| 6 |
-
from playwright.sync_api import sync_playwright
|
| 7 |
-
from utils import cmd
|
| 8 |
-
from environment import APP_PATH, DEBUG_PORT
|
| 9 |
-
from page_runner import PageRunner
|
| 10 |
-
from audio import play_audio_until_end
|
| 11 |
from tests.test_data import test_audios
|
| 12 |
|
| 13 |
if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
| 1 |
import time
|
| 2 |
+
from lib.audio import play_audio_until_end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from tests.test_data import test_audios
|
| 4 |
|
| 5 |
if __name__ == '__main__':
|
scripts/test_pages.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
| 1 |
-
import re
|
| 2 |
import time
|
| 3 |
-
from
|
| 4 |
-
from
|
| 5 |
-
from audio import play_audio, get_length
|
| 6 |
|
| 7 |
|
| 8 |
def test_has_title(page: Page, context):
|
|
|
|
|
|
|
| 1 |
import time
|
| 2 |
+
from playwright.sync_api import Page
|
| 3 |
+
from lib.audio import play_audio, get_length
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
def test_has_title(page: Page, context):
|
tests/conftest.py
CHANGED
|
@@ -1,16 +1,11 @@
|
|
| 1 |
-
import subprocess
|
| 2 |
-
import time
|
| 3 |
-
|
| 4 |
-
from numpy.core.numeric import True_
|
| 5 |
from pytest import fixture
|
| 6 |
-
from playwright.sync_api import Page, expect
|
| 7 |
from playwright.sync_api import sync_playwright
|
| 8 |
|
| 9 |
from environment import *
|
| 10 |
-
from app_runner import AppRunner
|
| 11 |
-
from page_runner import PageRunner
|
| 12 |
-
from report import AccuracyReport, DelayReport, LogReport
|
| 13 |
-
from utils import get_time_str
|
| 14 |
|
| 15 |
@fixture(scope="session")
|
| 16 |
def log_file():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from pytest import fixture
|
|
|
|
| 2 |
from playwright.sync_api import sync_playwright
|
| 3 |
|
| 4 |
from environment import *
|
| 5 |
+
from lib.app_runner import AppRunner
|
| 6 |
+
from lib.page_runner import PageRunner
|
| 7 |
+
from lib.report import AccuracyReport, DelayReport, LogReport
|
| 8 |
+
from lib.utils import get_time_str
|
| 9 |
|
| 10 |
@fixture(scope="session")
|
| 11 |
def log_file():
|
tests/test_accuracy.py
CHANGED
|
@@ -2,10 +2,10 @@ import time
|
|
| 2 |
from pathlib import Path
|
| 3 |
import pytest
|
| 4 |
|
| 5 |
-
from audio import play_audio_until_end, get_length
|
| 6 |
-
from pages import TranslatorPage
|
| 7 |
from tests.test_data import test_audios, audio_texts
|
| 8 |
-
from report import AccuracyReport, AccuracyItem
|
| 9 |
|
| 10 |
@pytest.mark.parametrize("audio", test_audios.get("zh"))
|
| 11 |
def test_accuracy_zh2en(app, page: TranslatorPage, accuracy_report: AccuracyReport, audio:Path):
|
|
|
|
| 2 |
from pathlib import Path
|
| 3 |
import pytest
|
| 4 |
|
| 5 |
+
from lib.audio import play_audio_until_end, get_length
|
| 6 |
+
from lib.pages import TranslatorPage
|
| 7 |
from tests.test_data import test_audios, audio_texts
|
| 8 |
+
from lib.report import AccuracyReport, AccuracyItem
|
| 9 |
|
| 10 |
@pytest.mark.parametrize("audio", test_audios.get("zh"))
|
| 11 |
def test_accuracy_zh2en(app, page: TranslatorPage, accuracy_report: AccuracyReport, audio:Path):
|
tests/test_delay.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
from pathlib import Path
|
| 2 |
import pytest
|
| 3 |
|
| 4 |
-
from audio import get_length, play_audio
|
| 5 |
-
from pages import TranslatorPage
|
| 6 |
-
from report import DelayReport, DelayItem, LogReport
|
| 7 |
from tests.test_data import test_audios
|
| 8 |
|
| 9 |
@pytest.mark.parametrize("audio", test_audios.get("zh"))
|
|
|
|
| 1 |
from pathlib import Path
|
| 2 |
import pytest
|
| 3 |
|
| 4 |
+
from lib.audio import get_length, play_audio
|
| 5 |
+
from lib.pages import TranslatorPage
|
| 6 |
+
from lib.report import DelayReport, DelayItem, LogReport
|
| 7 |
from tests.test_data import test_audios
|
| 8 |
|
| 9 |
@pytest.mark.parametrize("audio", test_audios.get("zh"))
|
tests/test_logfile.py
CHANGED
|
@@ -1,10 +1,6 @@
|
|
| 1 |
from pathlib import Path
|
| 2 |
import pytest
|
| 3 |
|
| 4 |
-
from report import LogReport, DelayItem
|
| 5 |
-
from environment import REPORTS_DIR
|
| 6 |
-
from utils import get_time_str
|
| 7 |
-
|
| 8 |
test_files = [
|
| 9 |
# Path("/Users/jeqin/work/code/Translator/translator.log"),
|
| 10 |
Path("/Users/jeqin/Downloads/translator.log"),
|
|
|
|
| 1 |
from pathlib import Path
|
| 2 |
import pytest
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
test_files = [
|
| 5 |
# Path("/Users/jeqin/work/code/Translator/translator.log"),
|
| 6 |
Path("/Users/jeqin/Downloads/translator.log"),
|