Skip to content

Commit

Permalink
Do not show the waive button if waiverdb.access_token is undefined.
Browse files Browse the repository at this point in the history
fixes #2169

Signed-off-by: Randy Barlow <[email protected]>
  • Loading branch information
bowlofeggs committed Feb 23, 2018
1 parent 2b3b19e commit 97fafd8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions bodhi/server/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,7 @@ def can_waive_test_results(context, update):
"""
return (config.get('test_gating.required') and
not update.test_gating_passed and
config.get('waiverdb.access_token') and
update.status.description != 'stable')


Expand Down
23 changes: 19 additions & 4 deletions bodhi/tests/server/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,27 @@ def test_failed(self):

class TestCanWaiveTestResults(base.BaseTestCase):
"""Test the can_waive_test_results() function."""
@mock.patch.dict('bodhi.server.util.config', {'test_gating.required': True})

@mock.patch.dict('bodhi.server.util.config',
{'test_gating.required': True, 'waiverdb.access_token': None})
def test_access_token_undefined(self):
"""If Bodhi is not configured with an access token, the result should be False."""
u = Update.query.all()[0]
u.test_gating_status = TestGatingStatus.failed
u.status = models.UpdateStatus.testing

self.assertFalse(util.can_waive_test_results(None, u))

@mock.patch.dict('bodhi.server.util.config',
{'test_gating.required': True, 'waiverdb.access_token': 'secret'})
def test_can_waive_test_results(self):
u = Update.query.all()[0]
u.test_gating_status = TestGatingStatus.failed
u.status = models.UpdateStatus.testing
self.assertTrue(util.can_waive_test_results(None, u))

@mock.patch.dict('bodhi.server.util.config', {'test_gating.required': False})
@mock.patch.dict('bodhi.server.util.config',
{'test_gating.required': False, 'waiverdb.access_token': 'secret'})
def test_gating_required_false(self):
"""
Assert that it should return false if test_gating is not enabled, even if
Expand All @@ -292,7 +305,8 @@ def test_gating_required_false(self):
u.status = models.UpdateStatus.testing
self.assertFalse(util.can_waive_test_results(None, u))

@mock.patch.dict('bodhi.server.util.config', {'test_gating.required': True})
@mock.patch.dict('bodhi.server.util.config',
{'test_gating.required': True, 'waiverdb.access_token': 'secret'})
def test_all_tests_passed(self):
"""
Assert that it should return false if all tests passed, even if
Expand All @@ -303,7 +317,8 @@ def test_all_tests_passed(self):
u.status = models.UpdateStatus.testing
self.assertFalse(util.can_waive_test_results(None, u))

@mock.patch.dict('bodhi.server.util.config', {'test_gating.required': True})
@mock.patch.dict('bodhi.server.util.config',
{'test_gating.required': True, 'waiverdb.access_token': 'secret'})
def test_update_is_stable(self):
"""
Assert that it should return false if the update is stable, even if
Expand Down

0 comments on commit 97fafd8

Please sign in to comment.