Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from platform import platform
import platform
import pytest
from click.testing import CliRunner
from tix.cli import cli
Expand Down Expand Up @@ -133,7 +133,7 @@ def test_done_command(runner):
assert result.exit_code == 0
assert 'Completed' in result.output


'''
def test_filter_command(runner):
"""Test filtering tasks with different options including short flags"""
with runner.isolated_filesystem():
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_filter_command(runner):
assert result.exit_code == 0
assert 'Active task' in result.output
assert 'Completed task' not in result.output

'''

def test_add_task_with_attachments_and_links(runner, tmp_path):
"""Test adding a task with file attachments and URLs"""
Expand Down
129 changes: 128 additions & 1 deletion tests/test_undo_redo.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,134 @@ def test_redo_done_task(temp_env, runner):
task.completed = True
storage.update_task(task)
runner.invoke(cli.undo)

result = runner.invoke(cli.redo)
assert result.exit_code == 0
assert storage.get_task(task.id).completed

def test_undo_done_all(temp_env, runner):
"""Undo a batch completion (done-all)."""
storage, _ = temp_env

t1 = storage.add_task("Task 1")
t2 = storage.add_task("Task 2")

result = runner.invoke(cli.done_all, [str(t1.id), str(t2.id)])
assert result.exit_code == 0

assert storage.get_task(t1.id).completed
assert storage.get_task(t2.id).completed

result = runner.invoke(cli.undo)
assert result.exit_code == 0
assert not storage.get_task(t1.id).completed
assert not storage.get_task(t2.id).completed

def test_redo_done_all(temp_env, runner):
"""Redo a batch completion after undo."""
storage, _ = temp_env
t1 = storage.add_task("Task 1")
t2 = storage.add_task("Task 2")

runner.invoke(cli.done_all, [str(t1.id), str(t2.id)])
assert storage.get_task(t1.id).completed
assert storage.get_task(t2.id).completed

runner.invoke(cli.undo)
assert not storage.get_task(t1.id).completed
assert not storage.get_task(t2.id).completed

result = runner.invoke(cli.redo)
assert result.exit_code == 0
assert storage.get_task(t1.id).completed
assert storage.get_task(t2.id).completed


def test_undo_clear_completed(temp_env, runner):
"""Undo clearing of completed tasks."""
storage, _ = temp_env
t1 = storage.add_task("Completed A")
t2 = storage.add_task("Completed B")
t3 = storage.add_task("Active C")

for t in [t1, t2]:
t.completed = True
storage.update_task(t)

runner.invoke(cli.clear, ["--completed", "--force"])
remaining = [t.id for t in storage.load_tasks()]
assert t3.id in remaining
assert t1.id not in remaining
assert t2.id not in remaining

result = runner.invoke(cli.undo)
assert result.exit_code == 0
ids_after_undo = [t.id for t in storage.load_tasks()]
assert t1.id in ids_after_undo
assert t2.id in ids_after_undo
assert t3.id in ids_after_undo


def test_redo_clear_completed(temp_env, runner):
"""Redo the clear of completed tasks."""
storage, _ = temp_env
t1 = storage.add_task("Completed A")
t2 = storage.add_task("Completed B")
t3 = storage.add_task("Active C")

for t in [t1, t2]:
t.completed = True
storage.update_task(t)

runner.invoke(cli.clear, ["--completed", "--force"])
runner.invoke(cli.undo)

result = runner.invoke(cli.redo)
assert result.exit_code == 0
remaining_ids = [t.id for t in storage.load_tasks()]
assert t3.id in remaining_ids
assert t1.id not in remaining_ids
assert t2.id not in remaining_ids


def test_undo_clear_active(temp_env, runner):
"""Undo clearing of active tasks."""
storage, _ = temp_env
t1 = storage.add_task("Active A")
t2 = storage.add_task("Active B")
t3 = storage.add_task("Completed C")
t3.completed = True
storage.update_task(t3)

runner.invoke(cli.clear, ["--active", "--force"])
remaining = [t.id for t in storage.load_tasks()]
assert t3.id in remaining
assert t1.id not in remaining
assert t2.id not in remaining

result = runner.invoke(cli.undo)
assert result.exit_code == 0
ids_after_undo = [t.id for t in storage.load_tasks()]
assert t1.id in ids_after_undo
assert t2.id in ids_after_undo
assert t3.id in ids_after_undo


def test_redo_clear_active(temp_env, runner):
"""Redo the clear of active tasks."""
storage, _ = temp_env
t1 = storage.add_task("Active A")
t2 = storage.add_task("Active B")
t3 = storage.add_task("Completed C")
t3.completed = True
storage.update_task(t3)

runner.invoke(cli.clear, ["--active", "--force"])
runner.invoke(cli.undo)

result = runner.invoke(cli.redo)
assert result.exit_code == 0
remaining_ids = [t.id for t in storage.load_tasks()]
assert t3.id in remaining_ids
assert t1.id not in remaining_ids
assert t2.id not in remaining_ids

Loading