How to use todoman - 10 common examples

To help you get started, we’ve selected a few todoman examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pimutils / todoman / tests / test_widgets.py View on Github external
def test_extended_edit_goto_sol():
    extended_edit = ExtendedEdit(None)

    extended_edit.set_edit_text(BASE_STRING)
    extended_edit.edit_pos = 9
    extended_edit.keypress(10, 'ctrl a')
    assert extended_edit.edit_pos == 0
    assert extended_edit.get_edit_text() == BASE_STRING

    extended_edit.set_edit_text(BASE_STRING)
    extended_edit.edit_pos = 23
    extended_edit.keypress(10, 'ctrl a')
    assert extended_edit.edit_pos == 21
    assert extended_edit.get_edit_text() == BASE_STRING
github pimutils / todoman / tests / test_widgets.py View on Github external
def test_extended_edit_delete_word():
    extended_edit = ExtendedEdit(None)

    extended_edit.set_edit_text(BASE_STRING)
    extended_edit.edit_pos = 9
    extended_edit.keypress(10, 'ctrl w')
    assert extended_edit.edit_pos == 4
    assert extended_edit.get_edit_text() == 'The fox bla bla\n@ät'

    extended_edit.set_edit_text('The-lazy-fox-bla-bla\n@ät')
    extended_edit.edit_pos = 8
    extended_edit.keypress(10, 'ctrl w')
    assert extended_edit.edit_pos == 4
    assert extended_edit.get_edit_text() == 'The--fox-bla-bla\n@ät'

    extended_edit.set_edit_text(BASE_STRING)
    extended_edit.edit_pos = 6
    extended_edit.keypress(10, 'ctrl w')
github pimutils / todoman / tests / test_widgets.py View on Github external
def test_extended_edit_input():
    """
    Very basic test to make sure we don't break basic editing

    We don't need to do more testing because that's done upstream. We basically
    want to test that we properly forward unhandled keypresses.
    """
    extended_edit = ExtendedEdit(mock.MagicMock())
    extended_edit.keypress((10,), 'h')
    extended_edit.keypress((10,), 'i')

    assert extended_edit.get_edit_text() == 'hi'
github pimutils / todoman / tests / test_widgets.py View on Github external
def test_extended_edit_delete_next_char():
    extended_edit = ExtendedEdit(None)

    extended_edit.set_edit_text(BASE_STRING)
    extended_edit.edit_pos = 9
    extended_edit.keypress(10, 'ctrl d')
    assert extended_edit.edit_pos == 9
    assert extended_edit.get_edit_text() == 'The lazy ox bla bla\n@ät'

    extended_edit.set_edit_text(BASE_STRING)
    extended_edit.edit_pos = 0
    extended_edit.keypress(10, 'ctrl d')
    assert extended_edit.edit_pos == 0
    assert extended_edit.get_edit_text() == 'he lazy fox bla bla\n@ät'

    extended_edit.set_edit_text(BASE_STRING)
    extended_edit.edit_pos = 24
    extended_edit.keypress(10, 'ctrl d')
github pimutils / todoman / tests / test_cli.py View on Github external
def run_test(sort_key):
        sort_key = ','.join(sort_key)
        result = runner.invoke(cli, ['list', '--sort', sort_key])
        assert not result.exception
        assert result.exit_code == 0
        assert len(result.output.strip().splitlines()) == len(tasks)
github pimutils / todoman / tests / test_ui.py View on Github external
def test_ctrl_c_clears(default_formatter, todo_factory):
    todo = todo_factory()
    editor = TodoEditor(todo, [todo.list], default_formatter)

    # Simulate that ctrl+c gets pressed, since we can't *really* do that
    # trivially inside unit tests.
    with mock.patch(
        'urwid.main_loop.MainLoop.run', side_effect=KeyboardInterrupt
    ), mock.patch(
        'urwid.main_loop.MainLoop.stop',
    ) as mocked_stop:
        editor.edit()

    assert mocked_stop.call_count == 1
github pimutils / todoman / tests / test_cli.py View on Github external
def test_sorting_fields(tmpdir, runner, default_database):
    tasks = []
    for i in range(1, 10):
        days = datetime.timedelta(days=i)

        todo = Todo(new=True)
        todo.list = next(default_database.lists())
        todo.due = datetime.datetime.now() + days
        todo.created_at = datetime.datetime.now() - days
        todo.summary = 'harhar{}'.format(i)
        tasks.append(todo)

        default_database.save(todo)

    fields = (
        'id',
        'uid',
        'summary',
        'due',
        'priority',
        'created_at',
        'completed_at',
github pimutils / todoman / tests / test_backend.py View on Github external
def test_supported_fields_are_serializeable():
    supported_fields = set(Todo.ALL_SUPPORTED_FIELDS)
    serialized_fields = set(VtodoWritter.FIELD_MAP.keys())

    assert supported_fields == serialized_fields
github pimutils / todoman / tests / test_filtering.py View on Github external
def test_due_aware(tmpdir, runner, create, now_for_tz):
    db = Database([tmpdir.join('default')], tmpdir.join('cache.sqlite'))
    list_ = next(db.lists())

    for tz in ['CET', 'HST']:
        for i in [1, 23, 25, 48]:
            todo = Todo(new=True)
            todo.due = now_for_tz(tz) + timedelta(hours=i)
            todo.summary = '{}'.format(i)

            todo.list = list_
            db.save(todo)

    todos = list(db.todos(due=24))

    assert len(todos) == 4
    assert todos[0].summary == "23"
    assert todos[1].summary == "23"
    assert todos[2].summary == "1"
    assert todos[3].summary == "1"
github pimutils / todoman / tests / test_model.py View on Github external
def test_retain_unknown_fields(tmpdir, create, default_database):
    """
    Test that we retain unknown fields after a load/save cycle.
    """
    create(
        'test.ics', 'UID:AVERYUNIQUEID\n'
        'SUMMARY:RAWR\n'
        'X-RAWR-TYPE:Reptar\n'
    )

    db = Database([tmpdir.join('default')], tmpdir.join('cache.sqlite'))
    todo = db.todo(1, read_only=False)

    todo.description = 'Rawr means "I love you" in dinosaur.'
    default_database.save(todo)

    path = tmpdir.join('default').join('test.ics')
    with path.open() as f:
        vtodo = f.read()
    lines = vtodo.splitlines()

    assert 'SUMMARY:RAWR' in lines
    assert 'DESCRIPTION:Rawr means "I love you" in dinosaur.' in lines
    assert 'X-RAWR-TYPE:Reptar' in lines