summaryrefslogtreecommitdiff
path: root/saharaclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-10-21 14:20:28 +0000
committerGerrit Code Review <review@openstack.org>2015-10-21 14:20:28 +0000
commit3939691bb4df53f6cfe66435537153e931e67426 (patch)
treef5af580165616914a068655b4d173d0cb24de808 /saharaclient
parent63717036e73c74ea7ea2e812e797c08c978137b4 (diff)
parent778d8b30b648f638f1999a0eeea14fc6d4c67f1d (diff)
downloadpython-saharaclient-3939691bb4df53f6cfe66435537153e931e67426.tar.gz
Merge "Changing public/protected options handling"
Diffstat (limited to 'saharaclient')
-rw-r--r--saharaclient/osc/v1/data_sources.py29
-rw-r--r--saharaclient/tests/unit/osc/v1/test_data_sources.py15
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})