Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(test): 补全云下载夹具并隔离诊断测试时钟

longmeidao21cb5168dc6e
diff --git a/tests/test_downloads_jav_browser.py b/tests/test_downloads_jav_browser.py
index 0d28403a4..7e119e71a 100644
--- a/tests/test_downloads_jav_browser.py
+++ b/tests/test_downloads_jav_browser.py
@@ -288,6 +288,10 @@ class BrowserTests(unittest.TestCase):
import io
import zipfile
from peach import error_reporting, support_bundle
+ from peach.settings_file import PeachConfig
+ clock = patch("peach.jav_browser_diagnostics.time", Mock(monotonic=lambda: 100.0))
+ clock.start()
+ self.addCleanup(clock.stop)
path = "/api/jav-browser/errors"
self.assertEqual(self.client.post(path, json={"events": [self.diagnostic()]}).status_code, 401)
self.assertEqual(self.client.post(path, headers=self.script_headers, content=b"x" * 17000).status_code, 413)
@@ -303,7 +307,8 @@ class BrowserTests(unittest.TestCase):
("userscript", "timeout", "ABC-123", 60000))
for private in ("private-message", "private-token", PAGE, self.token, "cloud-secret"):
self.assertNotIn(private, text)
- with zipfile.ZipFile(io.BytesIO(support_bundle.bundle_bytes())) as archive:
+ config = PeachConfig(self.root, self.root / "config.toml")
+ with zipfile.ZipFile(io.BytesIO(support_bundle.bundle_bytes(config=config))) as archive:
content = archive.read(next(name for name in archive.namelist() if name.endswith(log.name))).decode()
self.assertIn('"stage": "userscript"', content)
for change in ({"kind": []}, {"site": "https://private.example"}, {"code": "not a code"},
diff --git a/tests/test_web_downloads.py b/tests/test_web_downloads.py
index 9f79157dd..e7e8cbac2 100644
--- a/tests/test_web_downloads.py
+++ b/tests/test_web_downloads.py
@@ -326,6 +326,7 @@ class SettingsBlockTests(_App):
self.assertEqual(payload["report"]["suggested_target"], {"path": "/115open/云下载", "exists": False})
def test_saving_checks_the_folder_the_user_filled_in_and_keeps_it(self):
+ self.service.landing.declared_roots = self.roots()
self.suggest("/115open/云下载", True)
payload = web_downloads.save_settings(self.service, {
"clouddrive_address": "127.0.0.1:19798", "token": "cd2-secret",
@@ -386,6 +387,7 @@ class SettingsBlockTests(_App):
self.assertEqual((report["suggested_target"], report["suggested_pikpak_root"]), (None, ""))
def test_the_check_takes_the_push_prefixes_and_the_blanks_on_the_form(self):
+ self.service.landing.declared_roots = self.roots()
web_downloads.save_settings(self.service, {"targets": {"115": "/115open/已保存"}}, self.roots())
prefixes = (CloudPrefix("/115open", "B:\\"),)
self.service.landing.push_discovery.config = PushDiscoveryConfig(prefixes=prefixes)