From 1ba73e8086a09cab09943559b8a011f69ae04636 Mon Sep 17 00:00:00 2001 From: Xiangyang Chu Date: Tue, 8 Dec 2015 13:04:16 +0800 Subject: [PATCH] Add help message for 'active' filter. JIRA: PDC-1219 --- pdc_client/plugins/component.py | 6 +++++- tests/component/data/release_component/empty.txt | 0 tests/component/tests.py | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/component/data/release_component/empty.txt diff --git a/pdc_client/plugins/component.py b/pdc_client/plugins/component.py index 930c44c..f40b247 100644 --- a/pdc_client/plugins/component.py +++ b/pdc_client/plugins/component.py @@ -147,7 +147,11 @@ def register(self): list_parser = self.add_action('list', help='list all release components') self.add_include_inactive_release_argument(list_parser) - filters = ('active brew_package bugzilla_component global_component name release srpm_name ' + list_parser.add_argument('--active', dest='filter_active', choices=['True', 'False', + 'true', 'false', + 't', 'f', '1', '0'], + help='show active(True) or inactive(False) release component(s).') + filters = ('brew_package bugzilla_component global_component name release srpm_name ' 'type'.split()) for arg in filters: list_parser.add_argument('--' + arg.replace('_', '-'), dest='filter_' + arg) diff --git a/tests/component/data/release_component/empty.txt b/tests/component/data/release_component/empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/component/tests.py b/tests/component/tests.py index c561044..4407c5a 100644 --- a/tests/component/tests.py +++ b/tests/component/tests.py @@ -232,6 +232,20 @@ def test_list_multi_page(self, api): [('GET', {'page': 1, 'release': 'Test Release'}), ('GET', {'page': 2, 'release': 'Test Release'})]) + def test_list_active(self, api): + api.add_endpoint('release-components', 'GET', []) + with self.expect_output('release_component/empty.txt'): + self.runner.run(['release-component', 'list', '--active', 'True']) + self.assertEqual(api.calls['release-components'], + [('GET', {'page': 1, 'active': 'True'})]) + + def test_list_inactive(self, api): + api.add_endpoint('release-components', 'GET', []) + with self.expect_output('release_component/empty.txt'): + self.runner.run(['release-component', 'list', '--active', 'False']) + self.assertEqual(api.calls['release-components'], + [('GET', {'page': 1, 'active': 'False'})]) + def test_detail(self, api): api.add_endpoint('release-components', 'GET', [self.detail]) api.add_endpoint('release-component-contacts',