Adding job binary editing to library and CLI
Adding the ability to edit job binaries into the client library as well as the CLI. Change-Id: I5c3fc1dac61316a85bda9ae2710ec1255176deb0 Partial-Implements: bp edp-edit-job-binaries
This commit is contained in:
@@ -49,3 +49,7 @@ class JobBinariesManager(base.ResourceManager):
|
||||
if resp.status_code != 200:
|
||||
self._raise_api_exception(resp)
|
||||
return resp.content
|
||||
|
||||
def update(self, job_binary_id, data):
|
||||
return self._update(
|
||||
'/job-binaries/%s' % job_binary_id, data, 'job_binary')
|
||||
|
||||
@@ -723,6 +723,27 @@ def do_job_binary_delete(cs, args):
|
||||
# TODO(mattf): No indication of result
|
||||
|
||||
|
||||
@utils.arg('--name',
|
||||
help='Name of the job binary to update.')
|
||||
@utils.arg('--id',
|
||||
metavar='<job_binary_id>',
|
||||
help='Id of the job binary to update.')
|
||||
@utils.arg('--json',
|
||||
default=sys.stdin,
|
||||
type=argparse.FileType('r'),
|
||||
help='JSON representation of job binary update.')
|
||||
def do_job_binary_update(cs, args):
|
||||
"""Update a job binary."""
|
||||
update_data = json.loads(args.json.read())
|
||||
result = cs.job_binaries.update(
|
||||
args.id or
|
||||
_get_by_id_or_name(cs.job_binaries, name=args.name).id,
|
||||
update_data
|
||||
)
|
||||
|
||||
_show_job_binary(result)
|
||||
|
||||
|
||||
#
|
||||
# Jobs
|
||||
# ~~~~
|
||||
|
||||
@@ -29,6 +29,16 @@ class JobBinaryTest(base.BaseTestCase):
|
||||
}
|
||||
}
|
||||
|
||||
update_body = {
|
||||
'name': 'Updatedname',
|
||||
'url': 'Updatedurl',
|
||||
'description': 'Updateddescr',
|
||||
'extra': {
|
||||
'user': 'user',
|
||||
'password': 'Updated123'
|
||||
}
|
||||
}
|
||||
|
||||
def test_create_job_binary(self):
|
||||
url = self.URL + '/job-binaries'
|
||||
self.responses.post(url, status_code=202,
|
||||
@@ -78,3 +88,12 @@ class JobBinaryTest(base.BaseTestCase):
|
||||
|
||||
self.assertEqual(url, self.responses.last_request.url)
|
||||
self.assertEqual(b'data', resp)
|
||||
|
||||
def test_job_binary_update(self):
|
||||
url = self.URL + '/job-binaries/id'
|
||||
self.responses.put(url,
|
||||
status_code=202,
|
||||
json={'job_binary': self.update_body})
|
||||
|
||||
resp = self.client.job_binaries.update("id", self.update_body)
|
||||
self.assertEqual(self.update_body["name"], resp.name)
|
||||
|
||||
Reference in New Issue
Block a user