Some checks failed
Windows / verify (push) Has been cancelled
모델이 티어에 따라 2~17GB 를 차지하는데 %APPDATA% 에 박혀 있어서 C 드라이브가 좁은 사람은 손쓸 방법이 없었다. 처음 켤 때 한 번 묻고, 그 선택을 기억하고, 설정에서 바꿀 수 있게 한다. 닭과 달걀 문제가 하나 있다 — "어디에 둘지" 는 사용자가 정하는데 그 선택 자체는 고정된 곳에 적어둬야 다음 실행에 찾을 수 있다. 그래서 OS 표준 폴더에는 위치를 가리키는 쪽지(location.json) 한 장만 두고, 내용물은 전부 고른 폴더에 둔다. - storage.py 신설: 쪽지 읽기/쓰기, 경로 검증, 여유 공간, 데이터 이동 - config.py 의 CONFIG_PATH 를 config_path() 로 바꾼다. import 시점 상수라 위치를 바꿔도 옛 경로를 계속 가리켰다 - 위치가 정해지기 전에는 파일 로그를 열지 않는다. 열면 고르지도 않은 기본 폴더가 만들어지고 거기에 로그가 남는다 - 이전 버전 사용자에게는 묻지 않는다. 기본 위치에 쓰던 흔적이 있으면 그대로 쓴다 — 같은 자리를 다시 고르는 헛수고를 시킬 이유가 없다 - 고른 디스크가 빠져도 죽지 않고 기본 위치로 물러난다 - 위치를 바꿀 때 받아둔 모델을 옮길지 물어본다. 수 GB 라 창이 얼어붙지 않도록 별도 스레드에서 옮긴다 - windows_smoke 에 이 화면 렌더링 점검을 추가하고, 스크린샷을 호스트로 회수한다. 경로 표기와 디스크 조회는 OS 마다 다르게 도는 부분이다
62 lines
1.8 KiB
Python
62 lines
1.8 KiB
Python
"""저장 위치 대화상자 — 못 쓰는 폴더를 고르면 진행을 막는지."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
pytest.importorskip("PySide6")
|
|
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
|
|
|
from PySide6.QtWidgets import QApplication # noqa: E402
|
|
|
|
from livesub import storage # noqa: E402
|
|
from livesub.ui.data_location import DataLocationDialog # noqa: E402
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def qapp():
|
|
app = QApplication.instance() or QApplication([])
|
|
yield app
|
|
|
|
|
|
@pytest.fixture
|
|
def os_dir(tmp_path, monkeypatch):
|
|
base = tmp_path / "appdata" / "LiveSub"
|
|
monkeypatch.setattr(storage, "_os_config_dir", lambda: base)
|
|
return base
|
|
|
|
|
|
def test_first_run_dialog_starts_on_the_default_folder(qapp, os_dir):
|
|
dialog = DataLocationDialog(storage.default_data_dir(), first_run=True)
|
|
try:
|
|
assert dialog.selected() == os_dir
|
|
assert dialog.ok_button.isEnabled()
|
|
finally:
|
|
dialog.deleteLater()
|
|
|
|
|
|
def test_empty_path_blocks_confirmation(qapp, os_dir):
|
|
dialog = DataLocationDialog(storage.default_data_dir(), first_run=True)
|
|
try:
|
|
dialog.path_edit.setText(" ")
|
|
assert not dialog.ok_button.isEnabled()
|
|
dialog.path_edit.setText(str(os_dir.parent / "elsewhere"))
|
|
assert dialog.ok_button.isEnabled()
|
|
finally:
|
|
dialog.deleteLater()
|
|
|
|
|
|
def test_change_dialog_blocks_a_subfolder_of_the_current_one(qapp, tmp_path):
|
|
current = tmp_path / "current"
|
|
current.mkdir()
|
|
dialog = DataLocationDialog(current, first_run=False)
|
|
try:
|
|
dialog.path_edit.setText(str(current / "inside"))
|
|
assert not dialog.ok_button.isEnabled()
|
|
dialog.path_edit.setText(str(tmp_path / "other"))
|
|
assert dialog.ok_button.isEnabled()
|
|
finally:
|
|
dialog.deleteLater()
|