From d06a28a06cd5b4afccda0046f1f5e94914d0312d Mon Sep 17 00:00:00 2001 From: Caleigh Runge-Hottman Date: Tue, 8 Aug 2017 18:06:57 -0600 Subject: [PATCH] add web ui option to push to batched --- bodhi/server/templates/update.html | 6 ++- bodhi/tests/server/services/test_updates.py | 52 ++++++++++++++++++++- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/bodhi/server/templates/update.html b/bodhi/server/templates/update.html index ec0a03f030..dcbef2779f 100644 --- a/bodhi/server/templates/update.html +++ b/bodhi/server/templates/update.html @@ -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! @@ -411,8 +411,10 @@

Push to Testing % endif % if update.status.description not in ['stable', 'obsolete']: - Push to Stable + Push to Batched % endif + % elif update.request.description == 'batched': + Push to Stable % else: Revoke % endif diff --git a/bodhi/tests/server/services/test_updates.py b/bodhi/tests/server/services/test_updates.py index 8719c11e5b..83a52243c4 100644 --- a/bodhi/tests/server/services/test_updates.py +++ b/bodhi/tests/server/services/test_updates.py @@ -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 @@ -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')