Skip to content

Commit

Permalink
addbuilds and removebuilds
Browse files Browse the repository at this point in the history
Signed-off-by: Troy Dawson <[email protected]>
  • Loading branch information
tdawson authored and cverna committed Apr 8, 2019
1 parent ed80187 commit ff738cf
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bodhi/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ def _validate_edit_update(ctx, param, value):
@updates.command()
@click.option('--type', help='Update type',
type=click.Choice(['security', 'bugfix', 'enhancement', 'newpackage']))
@click.option('--addbuilds', help='Add Comma-separated list of build nvr')
@click.option('--removebuilds', help='Remove Comma-separated list of build nvr')
@add_options(new_edit_options)
@click.argument('update', callback=_validate_edit_update)
@openid_option
Expand Down Expand Up @@ -483,6 +485,15 @@ def edit(user, password, url, debug, openid_api, **kwargs):

kwargs['builds'] = [b['nvr'] for b in former_update['builds']]
kwargs['edited'] = former_update['alias']
if kwargs['addbuilds']:
for build in kwargs['addbuilds'].split(','):
if build not in kwargs['builds']:
kwargs['builds'].append(build)
if kwargs['removebuilds']:
for build in kwargs['removebuilds'].split(','):
kwargs['builds'].remove(build)
del kwargs['addbuilds']
del kwargs['removebuilds']

# Replace empty fields with former values from database.
for field in kwargs:
Expand Down
48 changes: 48 additions & 0 deletions bodhi/tests/client/test___init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,54 @@ def test_notes_file(self, send_request, query):
self.assertEqual(send_request.mock_calls, calls)
self.assertEqual(bindings_client.base_url, 'http://localhost:6543/')

@mock.patch('bodhi.client.bindings.BodhiClient.csrf',
mock.MagicMock(return_value='a_csrf_token'))
@mock.patch('bodhi.client.bindings.BodhiClient.query',
return_value=client_test_data.EXAMPLE_QUERY_MUNCH, autospec=True)
@mock.patch('bodhi.client.bindings.BodhiClient.send_request',
return_value=client_test_data.EXAMPLE_UPDATE_MUNCH, autospec=True)
def test_addbuilds_removebuilds(self, send_request, query):
"""
Assert that a addbuilds and removebuilds are properly handled in a successful updates
edit request.
"""
runner = testing.CliRunner()

result = runner.invoke(
client.edit, ['FEDORA-2017-c95b33872d', '--user', 'bowlofeggs',
'--password', 's3kr3t', '--notes', 'add and remove builds',
'--addbuilds', 'tar-1.29-4.fc25,nedit-5.7-1.fc25',
'--removebuilds', 'nodejs-grunt-wrap-0.3.0-2.fc25',
'--url', 'http://localhost:6543'])

self.assertEqual(result.exit_code, 0)
bindings_client = query.mock_calls[0][1][0]
query.assert_called_with(
bindings_client, updateid=u'FEDORA-2017-c95b33872d')
bindings_client = send_request.mock_calls[0][1][0]
calls = [
mock.call(
bindings_client, 'updates/', auth=True, verb='POST',
data={
'close_bugs': False, 'stable_karma': 3, 'csrf_token': 'a_csrf_token',
'staging': False,
'builds': ['tar-1.29-4.fc25', 'nedit-5.7-1.fc25'],
'autokarma': False, 'edited': 'FEDORA-2017-c95b33872d',
'suggest': u'unspecified', 'notes': u'add and remove builds',
'notes_file': None, 'request': None, 'severity': u'low',
'bugs': '1420605', 'requirements': u'', 'unstable_karma': -3,
'type': 'newpackage'
}
),
mock.call(
bindings_client,
u'updates/FEDORA-EPEL-2016-3081a94111/get-test-results',
verb='GET'
)
]
self.assertEqual(send_request.mock_calls, calls)
self.assertEqual(bindings_client.base_url, 'http://localhost:6543/')

def test_notes_and_notes_file(self):
"""
Assert providing both --notes-file and --notes parameters to an otherwise successful
Expand Down
8 changes: 8 additions & 0 deletions docs/user/man_pages/bodhi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ The ``updates`` command allows users to interact with bodhi updates.
Edit an existing bodhi update, given an update id or an update title. The
``edit`` subcommand supports the following options:

``--addbuilds <builds>``

Add a comma separated list of build nvr to this update.

``--removebuilds <builds>``

Remove a comma separated list of build nvr from this update.

``--type [security | bugfix | enhancement | newpackage]``

The type of the new update.
Expand Down

0 comments on commit ff738cf

Please sign in to comment.