feat: add complete yiyezhqiu productivity suite
This commit is contained in:
commit
e422ca8b2a
155 files changed
+18959
No files matched your search
@@ -0,0 +1,97 @@
|
||||
import json
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_settings_controller_persists_only_non_secret_values(tmp_path: Path):
|
||||
from dx_productivity.ui.settings_controller import SettingsController
|
||||
|
||||
controller = SettingsController(settings_path=tmp_path / "settings.json")
|
||||
controller.save_settings("https://example.invalid/manifest.json", "stable", True)
|
||||
|
||||
data = json.loads((tmp_path / "settings.json").read_text(encoding="utf-8"))
|
||||
|
||||
assert data == {
|
||||
"source": "https://example.invalid/manifest.json",
|
||||
"channel": "stable",
|
||||
"auto_check": True,
|
||||
}
|
||||
|
||||
|
||||
def test_settings_controller_auto_check_is_due_after_24_hours(tmp_path: Path):
|
||||
from dx_productivity.ui.settings_controller import SettingsController
|
||||
|
||||
controller = SettingsController(settings_path=tmp_path / "settings.json")
|
||||
settings = {"source": "file:///manifest.json", "channel": "development", "auto_check": True}
|
||||
now = datetime(2026, 9, 11, tzinfo=timezone.utc)
|
||||
|
||||
assert controller.auto_check_due(settings, now=now)
|
||||
controller.save_settings("file:///manifest.json", "development", True)
|
||||
controller.record_check(now=now)
|
||||
settings = controller.load_settings()
|
||||
assert not controller.auto_check_due(settings, now=now + timedelta(hours=23))
|
||||
assert controller.auto_check_due(settings, now=now + timedelta(hours=25))
|
||||
|
||||
|
||||
def test_settings_controller_check_emits_result_for_local_manifest(qtbot, tmp_path: Path):
|
||||
import json
|
||||
from dx_productivity.ui.settings_controller import SettingsController
|
||||
|
||||
manifest = tmp_path / "manifest.json"
|
||||
manifest.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"product": "yiyezhqiu-refactored",
|
||||
"version": "1.1.0",
|
||||
"channel": "development",
|
||||
"min_supported_version": "1.0.0",
|
||||
"package_url": "file:///release.zip",
|
||||
"sha256": "a" * 64,
|
||||
"release_notes": "test",
|
||||
"published_at": "2026-09-11",
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
controller = SettingsController(current_version="1.0.0")
|
||||
|
||||
with qtbot.waitSignal(controller.check_finished, timeout=3000) as signal:
|
||||
controller.check_updates(manifest.as_uri(), "development")
|
||||
|
||||
assert signal.args[0].status == "available"
|
||||
assert controller._thread is None
|
||||
|
||||
|
||||
def test_settings_controller_stages_update_before_install_request(qtbot, tmp_path: Path):
|
||||
from dx_productivity.ui.settings_controller import SettingsController
|
||||
from dx_productivity.update.models import UpdateManifest
|
||||
|
||||
class FakeStager:
|
||||
def download_and_verify(self, manifest, destination):
|
||||
destination.mkdir(parents=True, exist_ok=True)
|
||||
staged = destination / "1.1.0.zip"
|
||||
staged.write_bytes(b"verified")
|
||||
return staged
|
||||
|
||||
manifest = UpdateManifest.from_mapping(
|
||||
{
|
||||
"product": "yiyezhqiu-refactored",
|
||||
"version": "1.1.0",
|
||||
"channel": "development",
|
||||
"min_supported_version": "1.0.0",
|
||||
"package_url": "file:///release.zip",
|
||||
"sha256": "a" * 64,
|
||||
"release_notes": "test",
|
||||
"published_at": "2026-09-11",
|
||||
}
|
||||
)
|
||||
controller = SettingsController(stager=FakeStager(), staging_path=tmp_path / "updates")
|
||||
|
||||
with qtbot.waitSignal(controller.stage_finished, timeout=3000) as signal:
|
||||
controller.stage_update(manifest)
|
||||
|
||||
result = signal.args[0]
|
||||
assert result.state == "ready"
|
||||
assert result.staged_zip == tmp_path / "updates" / "1.1.0.zip"
|
||||
assert controller._stage_thread is None
|
||||
assert controller.staged_path(manifest) == result.staged_zip
|
||||
Reference in new issue
Block a user