How to use the todoman.cli.cli function in todoman

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_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_config.py View on Github external
def test_explicit_nonexistant(runner):
    result = CliRunner().invoke(
        cli,
        env={
            'TODOMAN_CONFIG': '/nonexistant',
        },
        catch_exceptions=True,
    )
    assert result.exception
    assert "Configuration file /nonexistant does not exist" in result.output
github pimutils / todoman / tests / test_cli.py View on Github external
def test_list(tmpdir, runner, create):
    result = runner.invoke(cli, ['list'], catch_exceptions=False)
    assert not result.exception
    assert not result.output.strip()

    create('test.ics', 'SUMMARY:harhar\n')
    result = runner.invoke(cli, ['list'])
    assert not result.exception
    assert 'harhar' in result.output
github pimutils / todoman / tests / test_config.py View on Github external
def test_missing_cache_dir(config, runner, tmpdir):
    cache_dir = tmpdir.join('does').join('not').join('exist')
    cache_file = cache_dir.join('cache.sqlite')

    path = tmpdir.join('config')
    path.write('cache_path = {}\n'.format(cache_file), 'a')
    path.write(
        '[main]\n'
        'path = {}/*\n'
        'cache_path = {}\n'.format(str(tmpdir), cache_file)
    )

    result = runner.invoke(cli)
    assert not result.exception
    assert cache_dir.isdir()
    assert cache_file.isfile()
github pimutils / todoman / tests / test_filtering.py View on Github external
def test_priority(tmpdir, runner, create):
    result = runner.invoke(cli, ['list'], catch_exceptions=False)
    assert not result.exception
    assert not result.output.strip()

    create('one.ics', 'SUMMARY:haha\n' 'PRIORITY:4\n')
    create('two.ics', 'SUMMARY:hoho\n' 'PRIORITY:9\n')
    create('three.ics', 'SUMMARY:hehe\n' 'PRIORITY:5\n')
    create('four.ics', 'SUMMARY:huhu\n')

    result_high = runner.invoke(cli, ['list', '--priority=high'])
    assert not result_high.exception
    assert 'haha' in result_high.output
    assert 'hoho' not in result_high.output
    assert 'huhu' not in result_high.output
    assert 'hehe' not in result_high.output

    result_medium = runner.invoke(cli, ['list', '--priority=medium'])
github pimutils / todoman / tests / test_porcelain.py View on Github external
def test_list_all(tmpdir, runner, create):
    create(
        'test.ics', 'SUMMARY:Do stuff\n'
        'STATUS:COMPLETED\n'
        'DUE;VALUE=DATE-TIME;TZID=CET:20160102T000000\n'
        'PERCENT-COMPLETE:26\n'
        'LOCATION:Wherever\n'
    )
    result = runner.invoke(cli, ['--porcelain', 'list', '--status', 'ANY'])

    expected = [{
        'completed': True,
        'due': 1451689200,
        'id': 1,
        'list': 'default',
        'location': 'Wherever',
        'percent': 26,
        'priority': 0,
        'summary': 'Do stuff',
    }]

    assert not result.exception
    assert result.output.strip() == json.dumps(
        expected, indent=4, sort_keys=True
    )
github pimutils / todoman / tests / test_porcelain.py View on Github external
def test_show(tmpdir, runner, create):
    create(
        'test.ics', 'SUMMARY:harhar\n'
        'DESCRIPTION:Lots of text. Yum!\n'
        'PRIORITY:5\n'
    )
    result = runner.invoke(cli, ['--porcelain', 'show', '1'])

    expected = {
        'completed': False,
        'due': None,
        'id': 1,
        'list': 'default',
        'location': '',
        'percent': 0,
        'priority': 5,
        'summary': 'harhar',
    }

    assert not result.exception
    assert result.output.strip() == json.dumps(
        expected, indent=4, sort_keys=True
    )
github pimutils / todoman / tests / test_cli.py View on Github external
todo_factory(summary='nostart')
    todo_factory(summary='unstarted', start=datetime.datetime(2017, 3, 24))

    result = runner.invoke(
        cli,
        ['list', '--startable'],
        catch_exceptions=False,
    )

    assert not result.exception
    assert 'started' in result.output
    assert 'nostart' in result.output
    assert 'unstarted' not in result.output

    result = runner.invoke(
        cli,
        ['list'],
        catch_exceptions=False,
    )

    assert not result.exception
    assert 'started' in result.output
    assert 'nostart' in result.output
    assert 'unstarted' in result.output

    path = tmpdir.join('config')
    path.write('startable = yes\n', 'a')

    result = runner.invoke(cli, ['list'], catch_exceptions=False)

    assert not result.exception
    assert 'started' in result.output
github pimutils / todoman / tests / test_filtering.py View on Github external
def test_grep(tmpdir, runner, create):
    result = runner.invoke(cli, ['list'], catch_exceptions=False)
    assert not result.exception
    assert not result.output.strip()

    create(
        'one.ics',
        'SUMMARY:fun\n'
        'DESCRIPTION: Have fun!\n',
    )
    create(
        'two.ics',
        'SUMMARY:work\n'
        'DESCRIPTION: The stuff for work\n',
    )
    create(
        'three.ics',
        'SUMMARY:buy sandwiches\n'
github pimutils / todoman / tests / test_main.py View on Github external
def test_main(tmpdir, runner):
    root = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')
    env = os.environ.copy()
    env['PYTHONPATH'] = root

    cli_result = runner.invoke(cli, ['--version'])

    pipe = Popen(
        [sys.executable, '-m', 'todoman', '--version'],
        stdout=PIPE,
        env=env,
    )
    main_output = pipe.communicate()[0]

    assert cli_result.output == main_output.decode()