Skip to content

Commit

Permalink
Fix update error when 'bugs' not provided.
Browse files Browse the repository at this point in the history
fixes #2520

Signed-off-by: Vismay Golwala <[email protected]>
(cherry picked from commit 1e1d49f)
  • Loading branch information
Vismay Golwala authored and bowlofeggs committed Aug 22, 2018
1 parent 5846567 commit 258f5ae
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bodhi/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,10 @@ def edit(user, password, url, **kwargs):
kwargs['edited'] = title

# Convert list of 'Bug' instances in DB to comma separated bug_ids for parsing.
former_update = resp['updates'][0]
former_update = resp['updates'][0].copy()
if not kwargs['bugs']:
kwargs['bugs'] = ",".join([str(bug['bug_id']) for bug in former_update['bugs']])
former_update.pop('bugs', None)

# Replace empty fields with former values from database.
for field in kwargs:
Expand Down
40 changes: 40 additions & 0 deletions bodhi/tests/client/test___init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,46 @@ def test_bodhi_client_exception(self, send_request):
self.assertEqual(result.exit_code, 0)
self.assertIn("This is a BodhiClientException message", result.output)

@mock.patch.dict(client_test_data.EXAMPLE_QUERY_MUNCH['updates'][0], {'bugs': []})
@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_edit_bugless_update_without_bugs_param(self, send_request, query):
"""Test editing an update with no bugs, without passing '--bugs' to it."""
runner = testing.CliRunner()

result = runner.invoke(
client.edit, ['FEDORA-2017-cc8582d738', '--user', 'bowlofeggs',
'--password', 's3kr3t'])

self.assertEqual(result.exit_code, 0)
bindings_client = query.mock_calls[0][1][0]
query.assert_called_with(
bindings_client, updateid=u'FEDORA-2017-cc8582d738')
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': u'nodejs-grunt-wrap-0.3.0-2.fc25',
'autokarma': False, 'edited': u'nodejs-grunt-wrap-0.3.0-2.fc25',
'suggest': u'unspecified', 'notes': u'New package.',
'notes_file': None, 'request': None, 'severity': u'low',
'bugs': '', 'requirements': u'', 'unstable_karma': -3, 'type': 'bugfix'
}
),
mock.call(
bindings_client,
u'updates/FEDORA-EPEL-2016-3081a94111/get-test-results',
verb='GET'
)
]
self.assertEqual(send_request.mock_calls, calls)


class TestEditBuilrootOverrides(unittest.TestCase):
"""
Expand Down

0 comments on commit 258f5ae

Please sign in to comment.