diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-10-21 14:20:28 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-10-21 14:20:28 +0000 |
commit | 3939691bb4df53f6cfe66435537153e931e67426 (patch) | |
tree | f5af580165616914a068655b4d173d0cb24de808 | |
parent | 63717036e73c74ea7ea2e812e797c08c978137b4 (diff) | |
parent | 778d8b30b648f638f1999a0eeea14fc6d4c67f1d (diff) | |
download | python-saharaclient-3939691bb4df53f6cfe66435537153e931e67426.tar.gz |
Merge "Changing public/protected options handling"
-rw-r--r-- | saharaclient/osc/v1/data_sources.py | 29 | ||||
-rw-r--r-- | saharaclient/tests/unit/osc/v1/test_data_sources.py | 15 |
2 files changed, 23 insertions, 21 deletions
diff --git a/saharaclient/osc/v1/data_sources.py b/saharaclient/osc/v1/data_sources.py index b5532e5..8ae3b95 100644 --- a/saharaclient/osc/v1/data_sources.py +++ b/saharaclient/osc/v1/data_sources.py @@ -246,13 +246,13 @@ class UpdateDataSource(show.ShowOne): public.add_argument( '--public', action='store_true', - default=None, + dest='is_public', help='Make the data source public (Visible from other tenants)', ) public.add_argument( '--private', - action='store_true', - default=None, + action='store_false', + dest='is_public', help='Make the data source private (Visible only from this ' 'tenant)', ) @@ -260,41 +260,30 @@ class UpdateDataSource(show.ShowOne): protected.add_argument( '--protected', action='store_true', - default=None, + dest='is_protected', help='Make the data source protected', ) protected.add_argument( '--unprotected', - action='store_true', - default=None, + action='store_false', + dest='is_protected', help='Make the data source unprotected', ) + parser.set_defaults(is_public=None, is_protected=None) return parser def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) client = self.app.client_manager.data_processing - is_public = None - if parsed_args.public: - is_public = True - elif parsed_args.private: - is_public = False - - is_protected = None - if parsed_args.protected: - is_protected = True - elif parsed_args.unprotected: - is_protected = False - update_fields = utils.create_dict_from_kwargs( name=parsed_args.name, description=parsed_args.description, data_source_type=parsed_args.type, url=parsed_args.url, credential_user=parsed_args.username, credential_pass=parsed_args.password, - is_public=is_public, - is_protected=is_protected) + is_public=parsed_args.is_public, + is_protected=parsed_args.is_protected) ds_id = utils.get_resource( client.data_sources, parsed_args.data_source).id diff --git a/saharaclient/tests/unit/osc/v1/test_data_sources.py b/saharaclient/tests/unit/osc/v1/test_data_sources.py index b031a0b..fe3f07a 100644 --- a/saharaclient/tests/unit/osc/v1/test_data_sources.py +++ b/saharaclient/tests/unit/osc/v1/test_data_sources.py @@ -260,7 +260,7 @@ class TestUpdateDataSource(TestDataSources): ('url', 'swift://container.sahara/object'), ('username', 'user'), ('password', 'pass'), ('description', 'Data Source for tests'), - ('public', True), ('protected', True)] + ('is_public', True), ('is_protected', True)] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -283,3 +283,16 @@ class TestUpdateDataSource(TestDataSources): expected_data = ('Data Source for tests', 'id', True, True, 'source', 'swift', 'swift://container.sahara/object') self.assertEqual(expected_data, data) + + def test_data_sources_update_privat_unprotected(self): + arglist = ['source', '--private', '--unprotected'] + verifylist = [('data_source', 'source'), ('is_public', False), + ('is_protected', False)] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + # Check that data source was created with correct arguments + self.ds_mock.update.assert_called_once_with( + 'id', {'is_public': False, 'is_protected': False}) |