تاقیکرنا بەشان ب ئێکڤە
د تاقیکرنا یەکگرتی دا چەند بەش ب ئێکڤە کار دکەن. فەرمانەکی بکار بینە و پاشی فایلێ بخوینەڤە دا بزانی داتا ب ڕاستی هاتییە هەلگرتن.
د ڤێ لاپەڕێ دا
ڕەفتارێ دیار بکە
کارەکی زێدە بکە، بەرنامێ دابخە و دووبارە ڤەکە. ئەگەر کار د لیستێ دا ما، هەلگرتن کار دکەت.
سنووری تاقی بکە
فەرمانێ ب فایلەکا کاتی بکار بینە. دەرچوون و کۆدێ دەرکەفتنێ بخوینە.
import json
from pathlib import Path
import subprocess
import sys
PROJECT = Path(__file__).resolve().parents[1]
def command(path, *arguments):
return subprocess.run(
[sys.executable, "-m", "taskflow", "--data", str(path), *arguments],
cwd=PROJECT,
capture_output=True,
text=True,
timeout=10,
)
def test_task_survives_restart(tmp_path):
path = tmp_path / "tasks.json"
added = command(path, "add", "Review patch")
assert added.returncode == 0, added.stderr
listed = command(path, "list", "--json")
assert listed.returncode == 0, listed.stderr
assert json.loads(listed.stdout) == [
{"id": 1, "title": "Review patch", "done": False}
]ڕێکا هەڵەیێ
هاتنەکا نەدروست بدە و بپشکنە کا داتایا بەری نوکە هێشتا ماوە.
def test_unknown_id_preserves_file(tmp_path):
path = tmp_path / "tasks.json"
assert command(path, "add", "Keep me").returncode == 0
before = path.read_bytes()
result = command(path, "done", "999")
assert result.returncode == 2
assert result.stderr.strip()
assert path.read_bytes() == beforeتاقیکرنان بکار بینە
ژ فولدەرا پڕۆژەی pytest بکار بینە. پشتی گوهۆڕینەکێ هەمان پشکنینان دووبارە بکە.
.build-env/bin/python -m pip install pytest
.build-env/bin/python -m pytest -q tests/test_roundtrip.py