Exemple #1
0
def test_add_wrong_json_format(mock_wrong_json_format):
    todoer = rptodo.Todoer(mock_wrong_json_format)
    assert todoer.add(test_data1["description"], test_data1["priority"]) == (
        test_data1["todo"],
        SUCCESS,
    )
    read = todoer._db_handler.read_todos()
    assert len(read.todo_list) == 1
Exemple #2
0
def get_todoer() -> rptodo.Todoer:
    if config.CONFIG_FILE_PATH.exists():
        db_path = database.get_database_path(config.CONFIG_FILE_PATH)
    else:
        typer.secho(
            'Config file not found. Please, run "rptodo init"',
            fg=typer.colors.RED,
        )
        raise typer.Exit(1)
    if db_path.exists():
        return rptodo.Todoer(db_path)
    else:
        typer.secho(
            'Database not found. Please, run "rptodo init"',
            fg=typer.colors.RED,
        )
        raise typer.Exit(1)
Exemple #3
0
def test_add_wrong_json_file(mock_wrong_json_file):
    todoer = rptodo.Todoer(mock_wrong_json_file)
    response = todoer.add(["test task"], 1)
    assert response.error == DB_READ_ERROR
    read = todoer._db_handler.read_todos()
    assert len(read.todo_list) == 0
Exemple #4
0
def test_add(mock_json_file, description, priority, expected):
    todoer = rptodo.Todoer(mock_json_file)
    assert todoer.add(description, priority) == expected
    read = todoer._db_handler.read_todos()
    assert len(read.todo_list) == 2
Exemple #5
0
def test_set_done(mock_json_file, todo_id, expected):
    todoer = rptodo.Todoer(mock_json_file)
    assert todoer.set_done(todo_id) == expected
Exemple #6
0
def test_remove_all(mock_json_file):
    todoer = rptodo.Todoer(mock_json_file)
    assert todoer.remove_all() == ({}, SUCCESS)
Exemple #7
0
def test_remove(mock_json_file, todo_id, expected):
    todoer = rptodo.Todoer(mock_json_file)
    assert todoer.remove(todo_id) == expected