From ee4984275d5e17b72de97198e347ef415aa90a96 Mon Sep 17 00:00:00 2001 From: AnubhaAgrawal Date: Sun, 18 Jun 2017 05:40:26 -0400 Subject: [PATCH 1/7] Add cli for description --- todoman/cli.py | 6 +++++- todoman/model.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/todoman/cli.py b/todoman/cli.py index 135d69f1..25e70965 100644 --- a/todoman/cli.py +++ b/todoman/cli.py @@ -143,6 +143,7 @@ def _todo_property_options(command): click.option( '--priority', default='', callback=_validate_priority_param, help=('The priority for this todo'))(command) + click.option('--description', help=('The description of todo.'))(command) click.option('--location', help=('The location where ' 'this todo takes place.'))(command) click.option( @@ -156,7 +157,8 @@ def _todo_property_options(command): @functools.wraps(command) def command_wrap(*a, **kw): kw['todo_properties'] = {key: kw.pop(key) for key in - ('due', 'start', 'location', 'priority')} + ('due', 'start', 'location', 'priority', + 'description')} return command(*a, **kw) return command_wrap @@ -466,6 +468,8 @@ def move(ctx, list, ids): @cli.command() @pass_ctx @click.argument('lists', nargs=-1, callback=_validate_lists_param) +@click.option('--description', + help='Only show tasks with description containg TEXT') @click.option('--location', help='Only show tasks with location containg TEXT') @click.option('--category', help='Only show tasks with category containg TEXT') @click.option('--grep', help='Only show tasks with message containg TEXT') diff --git a/todoman/model.py b/todoman/model.py index 0819e2a9..d3700412 100644 --- a/todoman/model.py +++ b/todoman/model.py @@ -603,7 +603,8 @@ def add_vtodo(self, todo, file_path, id=None): return rv - def todos(self, lists=(), priority=None, location='', category='', grep='', + def todos(self, lists=(), priority=None, location='', + description='', category='', grep='', sort=(), reverse=True, due=None, start=None, startable=False, status=('NEEDS-ACTION', 'IN-PROCESS',)): """ @@ -652,6 +653,9 @@ def todos(self, lists=(), priority=None, location='', category='', grep='', if priority: extra_where.append('AND PRIORITY > 0 AND PRIORITY <= ?') params.append('{}'.format(priority)) + if description: + extra_where.append('AND description LIKE ?') + params.append('%{}%'.format(description)) if location: extra_where.append('AND location LIKE ?') params.append('%{}%'.format(location)) From 3bfbf4c076f4eb012390263a03afe519bc027d37 Mon Sep 17 00:00:00 2001 From: AnubhaAgrawal Date: Sun, 18 Jun 2017 22:29:48 -0400 Subject: [PATCH 2/7] Add test cases --- tests/test_cli.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index c707edfc..fe7b2219 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -911,3 +911,22 @@ def test_duplicate_list(tmpdir, runner): assert result.exit_code == exceptions.AlreadyExists.EXIT_CODE assert result.output.strip() == \ 'More than one list has the same identity: personal.' + + +def test_show_description(tmpdir, runner, create): + create( + 'test.ics', + 'SUMMARY:harhar\n' + 'DESCRIPTION:Parnidi\n' + ) + + result = runner.invoke(cli, ['show', '1']) + assert 'Parnidi' in result.output + + +def test_description(runner): + result = runner.invoke(cli, [ + 'new', '-l', 'default', '--description', 'Takshila', 'Event Test' + ]) + + assert 'Takshila' in result.output From af5580d72b117a31e08f04c0707dca147f5d0921 Mon Sep 17 00:00:00 2001 From: AnubhaAgrawal Date: Sun, 18 Jun 2017 23:11:13 -0400 Subject: [PATCH 3/7] Add test_edit_description --- tests/test_cli.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index fe7b2219..6af92ccd 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -930,3 +930,12 @@ def test_description(runner): ]) assert 'Takshila' in result.output + + +def test_edit_description(runner, todos, todo_factory): + todo_factory(summary='harhar\n', description='Parnidi') + + result = runner.invoke(cli, ['edit', '1', '--description', 'Parnidi']) + + assert not result.exception + assert 'Parnidi' in result.output From 09fcd2177af47abaabf3ab67973e0918ad73f38b Mon Sep 17 00:00:00 2001 From: AnubhaAgrawal Date: Mon, 19 Jun 2017 00:11:46 -0400 Subject: [PATCH 4/7] Requested canges --- tests/test_cli.py | 6 +++--- todoman/model.py | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 6af92ccd..4ff51259 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -933,9 +933,9 @@ def test_description(runner): def test_edit_description(runner, todos, todo_factory): - todo_factory(summary='harhar\n', description='Parnidi') + todo_factory(summary='harhar', description='Parnidi') - result = runner.invoke(cli, ['edit', '1', '--description', 'Parnidi']) + result = runner.invoke(cli, ['edit', '1', '--description', 'Kimple']) assert not result.exception - assert 'Parnidi' in result.output + assert 'Kimple' in result.output diff --git a/todoman/model.py b/todoman/model.py index d3700412..4d72ec64 100644 --- a/todoman/model.py +++ b/todoman/model.py @@ -653,9 +653,6 @@ def todos(self, lists=(), priority=None, location='', if priority: extra_where.append('AND PRIORITY > 0 AND PRIORITY <= ?') params.append('{}'.format(priority)) - if description: - extra_where.append('AND description LIKE ?') - params.append('%{}%'.format(description)) if location: extra_where.append('AND location LIKE ?') params.append('%{}%'.format(location)) From 1a604da4a7fb430e13043206324da976da2117ad Mon Sep 17 00:00:00 2001 From: AnubhaAgrawal Date: Thu, 22 Jun 2017 12:47:20 -0400 Subject: [PATCH 5/7] Now I add test --- tests/test_cli.py | 12 +++++++++++- todoman/model.py | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 4ff51259..fd38eb68 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -21,7 +21,6 @@ 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' @@ -939,3 +938,14 @@ def test_edit_description(runner, todos, todo_factory): assert not result.exception assert 'Kimple' in result.output + + +def test_filter_description(runner, create): + create( + 'test.ics', + 'SUMMARY:harhar\n' + 'DESCRIPTION:Shubik' + ) + result = runner.invoke(cli, ['list']) + + assert 'Shubik' in result.output diff --git a/todoman/model.py b/todoman/model.py index 4d72ec64..ef579b4e 100644 --- a/todoman/model.py +++ b/todoman/model.py @@ -618,6 +618,8 @@ def todos(self, lists=(), priority=None, location='', -created_at :param list lists: Only return todos for these lists. + :param str description: Only return todos with a description + containing this string. :param str location: Only return todos with a location containing this string. :param str category: Only return todos with a category containing this @@ -653,6 +655,9 @@ def todos(self, lists=(), priority=None, location='', if priority: extra_where.append('AND PRIORITY > 0 AND PRIORITY <= ?') params.append('{}'.format(priority)) + if description: + extra_where.append('AND description LIKE ?') + params.append('%{}%'.format(description)) if location: extra_where.append('AND location LIKE ?') params.append('%{}%'.format(location)) From 30fe5cace8e3bc44947016607a9407b9c531f2d2 Mon Sep 17 00:00:00 2001 From: AnubhaAgrawal Date: Fri, 23 Jun 2017 00:49:31 -0400 Subject: [PATCH 6/7] Add changes --- tests/test_cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index fd38eb68..23cf3a6e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -940,7 +940,8 @@ def test_edit_description(runner, todos, todo_factory): assert 'Kimple' in result.output -def test_filter_description(runner, create): +def test_filter_description(runner, create, todos, todo_factory): + todo_factory(summary='harhar', description='Takshila') create( 'test.ics', 'SUMMARY:harhar\n' From b7a4a534b9c46eecb7100fdf8134bea855fd6268 Mon Sep 17 00:00:00 2001 From: AnubhaAgrawal Date: Fri, 23 Jun 2017 21:31:37 -0400 Subject: [PATCH 7/7] change Summary --- tests/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 23cf3a6e..5b268a9f 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -944,7 +944,7 @@ def test_filter_description(runner, create, todos, todo_factory): todo_factory(summary='harhar', description='Takshila') create( 'test.ics', - 'SUMMARY:harhar\n' + 'SUMMARY:manika\n' 'DESCRIPTION:Shubik' ) result = runner.invoke(cli, ['list'])