From 16cde7522074f53cfd2000b4e1addae36578bfdf Mon Sep 17 00:00:00 2001 From: slava Date: Mon, 13 Apr 2026 18:34:23 +0700 Subject: [PATCH] Fix for windows --- tests/mock_server/gen_fetch_transactions.py | 16 ++++++++++++---- tests/mock_server/gen_transactions.ps1 | 17 ++++++++++++++++- .../pixel7_dushanbe_ft_01_embedded_minus_1.json | 10 ---------- .../pixel7_dushanbe_ft_02_minus_1_2131.json | 10 ---------- .../pixel7_dushanbe_ft_03_minus_1_2125.json | 10 ---------- .../pixel7_dushanbe_ft_04_minus_1_1836.json | 10 ---------- .../pixel7_dushanbe_ft_05_minus_1_1819.json | 10 ---------- .../pool/pixel7_dushanbe_ft_06_plus_1_2052.json | 10 ---------- .../pool/pixel7_ozon_ft_01_evgeny_plus_100.json | 10 ---------- .../pool/pixel7_ozon_ft_02_vlad_minus_100.json | 10 ---------- .../pool/pixel7_ozon_ft_03_vlad_minus_300.json | 10 ---------- .../pool/pixel7_ozon_ft_04_vlad_plus_100.json | 10 ---------- .../pool/pixel7_ozon_ft_05_vlad_plus_100_b.json | 10 ---------- .../pixel7_ozon_ft_06_evgeny_plus_100_b.json | 10 ---------- .../pool/tecno_ozon_ft_01_galina_plus_100.json | 10 ---------- .../pool/tecno_ozon_ft_02_galina_plus_300.json | 10 ---------- .../pool/tecno_ozon_ft_03_vlad_minus_100_a.json | 10 ---------- .../pool/tecno_ozon_ft_04_vlad_minus_100_b.json | 10 ---------- .../tecno_ozon_ft_05_galina_minus_100_a.json | 10 ---------- .../tecno_ozon_ft_06_galina_minus_100_b.json | 10 ---------- .../pool/tecno_ozon_ft_07_vlad_plus_550.json | 10 ---------- 21 files changed, 28 insertions(+), 195 deletions(-) delete mode 100644 tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_01_embedded_minus_1.json delete mode 100644 tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_02_minus_1_2131.json delete mode 100644 tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_03_minus_1_2125.json delete mode 100644 tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_04_minus_1_1836.json delete mode 100644 tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_05_minus_1_1819.json delete mode 100644 tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_06_plus_1_2052.json delete mode 100644 tests/mock_server/scenarios/pool/pixel7_ozon_ft_01_evgeny_plus_100.json delete mode 100644 tests/mock_server/scenarios/pool/pixel7_ozon_ft_02_vlad_minus_100.json delete mode 100644 tests/mock_server/scenarios/pool/pixel7_ozon_ft_03_vlad_minus_300.json delete mode 100644 tests/mock_server/scenarios/pool/pixel7_ozon_ft_04_vlad_plus_100.json delete mode 100644 tests/mock_server/scenarios/pool/pixel7_ozon_ft_05_vlad_plus_100_b.json delete mode 100644 tests/mock_server/scenarios/pool/pixel7_ozon_ft_06_evgeny_plus_100_b.json delete mode 100644 tests/mock_server/scenarios/pool/tecno_ozon_ft_01_galina_plus_100.json delete mode 100644 tests/mock_server/scenarios/pool/tecno_ozon_ft_02_galina_plus_300.json delete mode 100644 tests/mock_server/scenarios/pool/tecno_ozon_ft_03_vlad_minus_100_a.json delete mode 100644 tests/mock_server/scenarios/pool/tecno_ozon_ft_04_vlad_minus_100_b.json delete mode 100644 tests/mock_server/scenarios/pool/tecno_ozon_ft_05_galina_minus_100_a.json delete mode 100644 tests/mock_server/scenarios/pool/tecno_ozon_ft_06_galina_minus_100_b.json delete mode 100644 tests/mock_server/scenarios/pool/tecno_ozon_ft_07_vlad_plus_550.json diff --git a/tests/mock_server/gen_fetch_transactions.py b/tests/mock_server/gen_fetch_transactions.py index 5259d06..55ddf90 100755 --- a/tests/mock_server/gen_fetch_transactions.py +++ b/tests/mock_server/gen_fetch_transactions.py @@ -32,7 +32,15 @@ from datetime import datetime, timedelta, timezone from pathlib import Path HERE = Path(__file__).parent +PROJECT_ROOT = (HERE / ".." / "..").resolve() POOL_DIR = HERE / "scenarios" / "pool" + +if sys.platform == "win32": + ADB = str(PROJECT_ROOT / "tools" / "adb" / "windows" / "adb.exe") +elif sys.platform == "darwin": + ADB = str(PROJECT_ROOT / "tools" / "adb" / "macos" / "adb") +else: + ADB = "adb" BOUNDS_RE = re.compile(r"\[(\d+),(\d+)\]\[(\d+),(\d+)\]") # ---------------------------------------------------------------- config/db @@ -88,7 +96,7 @@ def query_active_materials(db_path: Path): # ---------------------------------------------------------------- ADB helpers def adb(serial, *args): - cmd = ["adb"] + cmd = [ADB] if serial: cmd += ["-s", serial] cmd += list(args) @@ -135,7 +143,7 @@ def get_device_tz(serial) -> timezone: def get_adb_serials(): - r = subprocess.run(["adb", "devices"], check=True, capture_output=True) + r = subprocess.run([ADB, "devices"], check=True, capture_output=True) serials = [] for line in r.stdout.decode().splitlines()[1:]: parts = line.split() @@ -157,7 +165,7 @@ def back(serial): def parse_ozon_rows(xml): rows = [] for m in re.finditer( - r']*?text="([^"]*(?:Пополнени|Переводы)[^"]*)"' + r']*?text="([^"]*)"' r'[^>]*?bounds="(\[\d+,\d+\]\[\d+,\d+\])"', xml): text, bounds = m.group(1), m.group(2) bm = BOUNDS_RE.match(bounds) @@ -177,7 +185,7 @@ def parse_ozon_rows(xml): def is_ozon_list(xml): - return "Операции" in xml and ("Пополнени" in xml or "Переводы" in xml) + return "Операции" in xml def extract_ozon_detail_time(xml): diff --git a/tests/mock_server/gen_transactions.ps1 b/tests/mock_server/gen_transactions.ps1 index acffc1e..635b19d 100644 --- a/tests/mock_server/gen_transactions.ps1 +++ b/tests/mock_server/gen_transactions.ps1 @@ -13,4 +13,19 @@ foreach ($_c in $_configCandidates) { if (-not $_configPath) { Write-Host "ERROR: config.ini not found" -ForegroundColor Red; exit 1 } $_configArg = @("--config", $_configPath) Write-Host "Config: $_configPath" -ForegroundColor Gray -& "C:\Users\User\AppData\Local\Programs\Python\Python312-arm64\python.exe" "$PSScriptRoot\gen_fetch_transactions.py" @_configArg @args \ No newline at end of file +$_pythonExe = $null +foreach ($_cmd in (Get-Command python, python3, py -ErrorAction SilentlyContinue)) { + if ($_cmd.Source -notlike "*WindowsApps*") { $_pythonExe = $_cmd.Source; break } +} +if (-not $_pythonExe) { + $_pythonExe = (Get-ChildItem "$env:LOCALAPPDATA\Programs\Python\*\python.exe", + "C:\Users\*\AppData\Local\Programs\Python\*\python.exe", + "C:\Program Files\Python*\python.exe", + "C:\Python*\python.exe" -ErrorAction SilentlyContinue | + Select-Object -First 1).FullName +} +if (-not $_pythonExe) { + Write-Host "ERROR: python not found. Install Python or add it to PATH." -ForegroundColor Red; exit 1 +} +Write-Host "Python: $_pythonExe" -ForegroundColor Gray +& $_pythonExe "$PSScriptRoot\gen_fetch_transactions.py" @_configArg @args \ No newline at end of file diff --git a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_01_embedded_minus_1.json b/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_01_embedded_minus_1.json deleted file mode 100644 index 0566385..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_01_embedded_minus_1.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "dushanbe_city_bank", - "material_id": "61d967d1-8d3e-4d05-ba01-8c8ab327b945", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": -100, - "created_at": "2026-04-10T09:39:15Z" - }, - "_tag": "pixel7_dushanbe_01_embedded_minus_1" -} diff --git a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_02_minus_1_2131.json b/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_02_minus_1_2131.json deleted file mode 100644 index 26e54d0..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_02_minus_1_2131.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "dushanbe_city_bank", - "material_id": "61d967d1-8d3e-4d05-ba01-8c8ab327b945", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": -100, - "created_at": "2026-04-05T14:31:21Z" - }, - "_tag": "pixel7_dushanbe_02_minus_1_2131" -} diff --git a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_03_minus_1_2125.json b/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_03_minus_1_2125.json deleted file mode 100644 index f74ba7e..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_03_minus_1_2125.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "dushanbe_city_bank", - "material_id": "61d967d1-8d3e-4d05-ba01-8c8ab327b945", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": -100, - "created_at": "2026-04-05T14:25:48Z" - }, - "_tag": "pixel7_dushanbe_03_minus_1_2125" -} diff --git a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_04_minus_1_1836.json b/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_04_minus_1_1836.json deleted file mode 100644 index 112d97b..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_04_minus_1_1836.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "dushanbe_city_bank", - "material_id": "61d967d1-8d3e-4d05-ba01-8c8ab327b945", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": -100, - "created_at": "2026-04-05T11:36:06Z" - }, - "_tag": "pixel7_dushanbe_04_minus_1_1836" -} diff --git a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_05_minus_1_1819.json b/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_05_minus_1_1819.json deleted file mode 100644 index 7ec7da9..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_05_minus_1_1819.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "dushanbe_city_bank", - "material_id": "61d967d1-8d3e-4d05-ba01-8c8ab327b945", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": -100, - "created_at": "2026-04-05T11:19:43Z" - }, - "_tag": "pixel7_dushanbe_05_minus_1_1819" -} diff --git a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_06_plus_1_2052.json b/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_06_plus_1_2052.json deleted file mode 100644 index 62a1bdf..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_dushanbe_ft_06_plus_1_2052.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "dushanbe_city_bank", - "material_id": "61d967d1-8d3e-4d05-ba01-8c8ab327b945", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": 100, - "created_at": "2026-04-03T13:52:06Z" - }, - "_tag": "pixel7_dushanbe_06_plus_1_2052" -} diff --git a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_01_evgeny_plus_100.json b/tests/mock_server/scenarios/pool/pixel7_ozon_ft_01_evgeny_plus_100.json deleted file mode 100644 index 8391848..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_01_evgeny_plus_100.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "30bc106c-6935-4f4b-85f3-f1a06adc5c13", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": 10000, - "created_at": "2026-04-11T10:39:00Z" - }, - "_tag": "pixel7_ozon_01_evgeny_plus_100" -} diff --git a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_02_vlad_minus_100.json b/tests/mock_server/scenarios/pool/pixel7_ozon_ft_02_vlad_minus_100.json deleted file mode 100644 index 40612bb..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_02_vlad_minus_100.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "30bc106c-6935-4f4b-85f3-f1a06adc5c13", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": -10000, - "created_at": "2026-04-10T09:40:00Z" - }, - "_tag": "pixel7_ozon_02_vlad_minus_100" -} diff --git a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_03_vlad_minus_300.json b/tests/mock_server/scenarios/pool/pixel7_ozon_ft_03_vlad_minus_300.json deleted file mode 100644 index f753eef..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_03_vlad_minus_300.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "30bc106c-6935-4f4b-85f3-f1a06adc5c13", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": -30000, - "created_at": "2026-04-08T08:34:00Z" - }, - "_tag": "pixel7_ozon_03_vlad_minus_300" -} diff --git a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_04_vlad_plus_100.json b/tests/mock_server/scenarios/pool/pixel7_ozon_ft_04_vlad_plus_100.json deleted file mode 100644 index 6619834..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_04_vlad_plus_100.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "30bc106c-6935-4f4b-85f3-f1a06adc5c13", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": 10000, - "created_at": "2026-04-08T08:14:00Z" - }, - "_tag": "pixel7_ozon_04_vlad_plus_100" -} diff --git a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_05_vlad_plus_100_b.json b/tests/mock_server/scenarios/pool/pixel7_ozon_ft_05_vlad_plus_100_b.json deleted file mode 100644 index cb38b8b..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_05_vlad_plus_100_b.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "30bc106c-6935-4f4b-85f3-f1a06adc5c13", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": 10000, - "created_at": "2026-04-08T08:02:00Z" - }, - "_tag": "pixel7_ozon_05_vlad_plus_100_b" -} diff --git a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_06_evgeny_plus_100_b.json b/tests/mock_server/scenarios/pool/pixel7_ozon_ft_06_evgeny_plus_100_b.json deleted file mode 100644 index ca93087..0000000 --- a/tests/mock_server/scenarios/pool/pixel7_ozon_ft_06_evgeny_plus_100_b.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "30bc106c-6935-4f4b-85f3-f1a06adc5c13", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": 10000, - "created_at": "2026-04-06T13:54:00Z" - }, - "_tag": "pixel7_ozon_06_evgeny_plus_100_b" -} diff --git a/tests/mock_server/scenarios/pool/tecno_ozon_ft_01_galina_plus_100.json b/tests/mock_server/scenarios/pool/tecno_ozon_ft_01_galina_plus_100.json deleted file mode 100644 index 26988ec..0000000 --- a/tests/mock_server/scenarios/pool/tecno_ozon_ft_01_galina_plus_100.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "49001bb5-3b24-478d-b913-c2242aea0732", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": 10000, - "created_at": "2026-04-10T09:40:00Z" - }, - "_tag": "tecno_ozon_01_galina_plus_100" -} diff --git a/tests/mock_server/scenarios/pool/tecno_ozon_ft_02_galina_plus_300.json b/tests/mock_server/scenarios/pool/tecno_ozon_ft_02_galina_plus_300.json deleted file mode 100644 index 31c0474..0000000 --- a/tests/mock_server/scenarios/pool/tecno_ozon_ft_02_galina_plus_300.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "49001bb5-3b24-478d-b913-c2242aea0732", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": 30000, - "created_at": "2026-04-08T08:34:00Z" - }, - "_tag": "tecno_ozon_02_galina_plus_300" -} diff --git a/tests/mock_server/scenarios/pool/tecno_ozon_ft_03_vlad_minus_100_a.json b/tests/mock_server/scenarios/pool/tecno_ozon_ft_03_vlad_minus_100_a.json deleted file mode 100644 index 71857e0..0000000 --- a/tests/mock_server/scenarios/pool/tecno_ozon_ft_03_vlad_minus_100_a.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "49001bb5-3b24-478d-b913-c2242aea0732", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": -10000, - "created_at": "2026-04-08T08:32:00Z" - }, - "_tag": "tecno_ozon_03_vlad_minus_100_a" -} diff --git a/tests/mock_server/scenarios/pool/tecno_ozon_ft_04_vlad_minus_100_b.json b/tests/mock_server/scenarios/pool/tecno_ozon_ft_04_vlad_minus_100_b.json deleted file mode 100644 index f9fb7cb..0000000 --- a/tests/mock_server/scenarios/pool/tecno_ozon_ft_04_vlad_minus_100_b.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "49001bb5-3b24-478d-b913-c2242aea0732", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": -10000, - "created_at": "2026-04-08T08:23:00Z" - }, - "_tag": "tecno_ozon_04_vlad_minus_100_b" -} diff --git a/tests/mock_server/scenarios/pool/tecno_ozon_ft_05_galina_minus_100_a.json b/tests/mock_server/scenarios/pool/tecno_ozon_ft_05_galina_minus_100_a.json deleted file mode 100644 index 5455a40..0000000 --- a/tests/mock_server/scenarios/pool/tecno_ozon_ft_05_galina_minus_100_a.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "49001bb5-3b24-478d-b913-c2242aea0732", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": -10000, - "created_at": "2026-04-08T08:14:00Z" - }, - "_tag": "tecno_ozon_05_galina_minus_100_a" -} diff --git a/tests/mock_server/scenarios/pool/tecno_ozon_ft_06_galina_minus_100_b.json b/tests/mock_server/scenarios/pool/tecno_ozon_ft_06_galina_minus_100_b.json deleted file mode 100644 index 37b938b..0000000 --- a/tests/mock_server/scenarios/pool/tecno_ozon_ft_06_galina_minus_100_b.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "49001bb5-3b24-478d-b913-c2242aea0732", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": -10000, - "created_at": "2026-04-08T08:02:00Z" - }, - "_tag": "tecno_ozon_06_galina_minus_100_b" -} diff --git a/tests/mock_server/scenarios/pool/tecno_ozon_ft_07_vlad_plus_550.json b/tests/mock_server/scenarios/pool/tecno_ozon_ft_07_vlad_plus_550.json deleted file mode 100644 index 4d08d38..0000000 --- a/tests/mock_server/scenarios/pool/tecno_ozon_ft_07_vlad_plus_550.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bank_name": "ozon", - "material_id": "49001bb5-3b24-478d-b913-c2242aea0732", - "type": "FETCH_TRANSACTIONS", - "body": { - "amount": 55000, - "created_at": "2026-03-20T14:36:00Z" - }, - "_tag": "tecno_ozon_07_vlad_plus_550" -}