Skip to content

Commit

Permalink
Modify compose-tree-locations in client because API url changed.
Browse files Browse the repository at this point in the history
Because scheme is added to compose-tree-locations API url,
pdc client is changed correspondingly in info/update/delete.

JIRA: PDC-1445
  • Loading branch information
ycheng-aa committed Apr 13, 2016
1 parent d4ded91 commit 26ae244
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
7 changes: 4 additions & 3 deletions pdc_client/plugins/compose_tree_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _add_common_arguments(self, parser):
parser.add_argument('variant_uid', metavar='VARIANT_UID')
parser.add_argument('arch', metavar='ARCH')
parser.add_argument('location', metavar='LOCATION')
parser.add_argument('scheme', metavar='SCHEME')

def add_compose_tree_location_arguments(self, parser, required=False):
required_args = {
Expand Down Expand Up @@ -108,13 +109,13 @@ def compose_tree_location_list(self, args):

def compose_tree_location_info(self, args):
compose_tree_location_info =\
self.client['compose-tree-locations'][args.compose_id][args.variant_uid][args.arch][args.location]._()
self.client['compose-tree-locations'][args.compose_id][args.variant_uid][args.arch][args.location][args.scheme]._()
self._display_compose_tree_location_info(args, compose_tree_location_info)

def compose_tree_location_update(self, args):
data = extract_arguments(args)
compose_tree_location_info =\
self.client['compose-tree-locations'][args.compose_id][args.variant_uid][args.arch][args.location]._('PATCH', data)
self.client['compose-tree-locations'][args.compose_id][args.variant_uid][args.arch][args.location][args.scheme]._('PATCH', data)
self._display_compose_tree_location_info(args, compose_tree_location_info)

def compose_tree_location_create(self, args):
Expand All @@ -124,7 +125,7 @@ def compose_tree_location_create(self, args):

def compose_tree_location_delete(self, args):
data = extract_arguments(args)
self.client['compose-tree-locations'][args.compose_id][args.variant_uid][args.arch][args.location]\
self.client['compose-tree-locations'][args.compose_id][args.variant_uid][args.arch][args.location][args.scheme]\
._("DELETE", data)

PLUGIN_CLASSES = [ComposeTreeLocationsPlugin]
26 changes: 14 additions & 12 deletions tests/compose_tree_locations/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def _setup_detail(self, api):
"scheme": "http",
"synced_content": "debug",
"url": "http://example.com"}
api.add_endpoint('compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY',
api.add_endpoint('compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY/https',
'GET', obj)
# PATCH test result to passed
obj_update = deepcopy(obj)
obj_update["scheme"] = "https"
obj_update["url"] = "https://example1.com"
obj_update["synced_content"] = "source"
api.add_endpoint('compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY',
api.add_endpoint('compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY/https',
'PATCH', obj_update)

def test_list(self, api):
Expand All @@ -63,27 +63,28 @@ def test_info(self, api):
self._setup_detail(api)
with self.expect_output('detail.txt'):
self.runner.run(['compose-tree-locations', 'info', 'Awesome-product-7.0-0', 'Server',
'x86_64', 'NAY'])
'x86_64', 'NAY', 'https'])
self.assertEqual(
api.calls['compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY'],
api.calls['compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY/https'],
[('GET', {})])

def test_info_json(self, api):
self._setup_detail(api)
with self.expect_output('detail.json', parse_json=True):
self.runner.run(['--json', 'compose-tree-locations', 'info', 'Awesome-product-7.0-0', 'Server',
'x86_64', 'NAY'])
'x86_64', 'NAY', 'https'])
self.assertEqual(
api.calls['compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY'],
api.calls['compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY/https'],
[('GET', {})])

def test_update(self, api):
self._setup_detail(api)
with self.expect_output('detail_for_patch.txt'):
self.runner.run(['compose-tree-locations', 'update', 'Awesome-product-7.0-0', 'Server', 'x86_64', 'NAY',
'--scheme', 'https', '--synced-content', 'source', '--url', 'https://example1.com'])
self.assertEqual(api.calls, {'compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY':
[('PATCH', {'scheme': 'https',
'https', '--scheme', 'http', '--synced-content', 'source',
'--url', 'https://example1.com'])
self.assertEqual(api.calls, {'compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY/https':
[('PATCH', {'scheme': 'http',
'synced_content': ['source'],
'url': 'https://example1.com'})]})

Expand Down Expand Up @@ -128,9 +129,10 @@ def test_create_multi_synced_contents(self, api):
'url': 'http://example.com'})]})

def test_delete(self, api):
api.add_endpoint('compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY',
api.add_endpoint('compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY/https',
'DELETE', None)
with self.expect_output('empty.txt'):
self.runner.run(['compose-tree-locations', 'delete', 'Awesome-product-7.0-0', 'Server', 'x86_64', 'NAY'])
self.assertEqual(api.calls, {'compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY':
self.runner.run(['compose-tree-locations', 'delete', 'Awesome-product-7.0-0', 'Server', 'x86_64', 'NAY',
'https'])
self.assertEqual(api.calls, {'compose-tree-locations/Awesome-product-7.0-0/Server/x86_64/NAY/https':
[('DELETE', {})]})

0 comments on commit 26ae244

Please sign in to comment.