Пример #1
0
def test_stats(repository: Repository) -> None:
    _insert_todo(repository, "This is a Todo!")
    _insert_todo(repository, "This is a ANOTHER Todo!")
    id_3, _ = _insert_todo(repository, "This is a yet ANOTHER Todo!")
    repository.deactivate(id_3)

    stats = repository.stats()
    assert stats == Stats(active=2, inactive=1)
Пример #2
0
def test_mark_incomplete_existing_todo(repository: Repository) -> None:
    id_1, text_1 = _insert_todo(repository, "This is a Todo!")
    id_2, text_2 = _insert_todo(repository, "This is a ANOTHER Todo!")

    repository.deactivate(id_2)
    result = repository.activate(id_2)
    assert result

    todos = repository.list()
    assert todos == tuple(
        sorted((Todo(id=id_1, text=text_1,
                     active=True), Todo(id=id_2, text=text_2, active=True))))
Пример #3
0
def test_mark_complete_not_existing_todo(repository: Repository) -> None:
    id_, text = _insert_todo(repository, "This is a Todo!")

    result = repository.deactivate(_random_id())
    assert not result

    todo = repository.get(id_)
    assert todo == Todo(id=id_, text=text, active=True)