Skip to content

Commit

Permalink
add web ui option to push to batched
Browse files Browse the repository at this point in the history
  • Loading branch information
crungehottman authored and bowlofeggs committed Aug 11, 2017
1 parent 17ccb7b commit d06a28a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
6 changes: 4 additions & 2 deletions bodhi/server/templates/update.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
$("#updatebuttons #edit").attr('href',
'${request.route_url("update_edit", id=update.alias)}');

$.each(['testing', 'stable', 'unpush', 'revoke'], function(i, action) {
$.each(['testing', 'stable', 'batched', 'unpush', 'revoke'], function(i, action) {
$("#updatebuttons #" + action).click(function() {
$("#updatebuttons a").addClass('disabled');
cabbage.spin(); // for real!
Expand Down Expand Up @@ -411,8 +411,10 @@ <h1>
<a id='testing' class="btn btn-sm btn-success"><span class="fa fa-fw fa-arrow-circle-right"></span> Push to Testing</a>
% endif
% if update.status.description not in ['stable', 'obsolete']:
<a id='stable' class="btn btn-sm btn-success"><span class="fa fa-fw fa-arrow-circle-right"></span> Push to Stable</a>
<a id='batched' class="btn btn-sm btn-success"><span class="fa fa-fw fa-arrow-circle-right"></span> Push to Batched</a>
% endif
% elif update.request.description == 'batched':
<a id='stable' class="btn btn-sm btn-success"><span class="fa fa-fw fa-arrow-circle-right"></span> Push to Stable</a>
% else:
<a id='revoke' class="btn btn-sm btn-danger"><span class="fa fa-fw fa-arrow-circle-left"></span> Revoke</a>
% endif
Expand Down
52 changes: 50 additions & 2 deletions bodhi/tests/server/services/test_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -3704,6 +3704,53 @@ def test_manually_push_to_stable_based_on_karma(self, publish, *args):
resp = self.app.post_json('/updates/', args)
publish.assert_called_with(topic='update.request.testing', msg=ANY)

# Marks it as batched
upd = Update.get(nvr, self.db)
upd.status = UpdateStatus.testing
upd.request = UpdateRequest.batched
upd.date_testing = datetime.now() - timedelta(days=1)
self.db.commit()

# Checks karma threshold is reached
# Makes sure stable karma is not None
# Ensures Request doesn't get set to stable automatically since autokarma is disabled
upd.comment(self.db, u'LGTM', author=u'ralph', karma=1)
upd = Update.get(nvr, self.db)
self.assertEquals(upd.karma, 1)
self.assertEquals(upd.stable_karma, 1)
self.assertEquals(upd.status, UpdateStatus.testing)
self.assertEquals(upd.request, UpdateRequest.batched)
self.assertEquals(upd.autokarma, False)

text = unicode(config.get('testing_approval_msg_based_on_karma'))
upd.comment(self.db, text, author=u'bodhi')

# Checks Push to Stable text in the html page for this update
id = 'bodhi-2.0.0-2.fc17'
resp = self.app.get('/updates/%s' % id,
headers={'Accept': 'text/html'})
self.assertIn('text/html', resp.headers['Content-Type'])
self.assertIn(id, resp)
self.assertIn('Push to Stable', resp)

@mock.patch(**mock_valid_requirements)
@mock.patch('bodhi.server.notifications.publish')
def test_manually_push_to_batched_based_on_karma(self, publish, *args):
"""
Test manually push to batched when autokarma is disabled
and karma threshold is reached. Ensure that the option/button to push to
stable is not present prior to entering the batched request state.
"""

# Disabled
# Sets stable karma to 1
nvr = u'bodhi-2.0.0-2.fc17'
args = self.get_update(nvr)
args['autokarma'] = False
args['stable_karma'] = 1
resp = self.app.post_json('/updates/', args)
publish.assert_called_with(topic='update.request.testing', msg=ANY)

# Marks it as testing
upd = Update.get(nvr, self.db)
upd.status = UpdateStatus.testing
Expand All @@ -3725,13 +3772,14 @@ def test_manually_push_to_stable_based_on_karma(self, publish, *args):
text = unicode(config.get('testing_approval_msg_based_on_karma'))
upd.comment(self.db, text, author=u'bodhi')

# Checks Push to Stable text in the html page for this update
# Checks Push to Batched text in the html page for this update
id = 'bodhi-2.0.0-2.fc17'
resp = self.app.get('/updates/%s' % id,
headers={'Accept': 'text/html'})
self.assertIn('text/html', resp.headers['Content-Type'])
self.assertIn(id, resp)
self.assertIn('Push to Stable', resp)
self.assertIn('Push to Batched', resp)
self.assertNotIn('Push to Stable', resp)

@mock.patch(**mock_valid_requirements)
@mock.patch('bodhi.server.notifications.publish')
Expand Down

0 comments on commit d06a28a

Please sign in to comment.