Skip to content

Commit

Permalink
Bodhi now comments on non-autokarma updates after enough time.
Browse files Browse the repository at this point in the history
There was an issue where Bodhi was not commenting on updates that
had reached the necessary time in testing when the update had
autokarma disabled. This commit fixes the approve_testing.py script
so that it will add a reminder on these updates as well.

fixes fedora-infra#1094
  • Loading branch information
bowlofeggs committed Dec 9, 2016
1 parent 17df9d5 commit fa6dad4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
17 changes: 9 additions & 8 deletions bodhi/server/scripts/approve_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,24 @@ def main(argv=sys.argv):
if update.met_testing_requirements:
continue

# Approval message when testing based on karma threshold
if update.stable_karma not in (0, None) and update.karma >= update.stable_karma \
and not update.autokarma:
print('%s now reaches stable karma threshold' % update.title)
text = config.get('testing_approval_msg_based_on_karma')
update.comment(db, text, author='bodhi')
continue

# If autokarma updates have reached the testing threshold, say something! Keep in mind
# that we don't care about karma here, because autokarma updates get their request set
# to stable by the Update.comment() workflow when they hit the required threshold. Thus,
# this function only needs to consider the time requirements because these updates have
# not reached the karma threshold.
if update.autokarma and update.meets_testing_requirements:
if update.meets_testing_requirements:
print('%s now meets testing requirements' % update.title)
text = config.get('testing_approval_msg') % update.release.mandatory_days_in_testing
update.comment(db, text, author='bodhi')

# Approval message when testing based on karma threshold
if update.stable_karma not in (0, None) and update.karma >= update.stable_karma \
and not update.autokarma:
print('%s now reaches stable karma threshold' % update.title)
text = config.get('testing_approval_msg_based_on_karma')
update.comment(db, text, author='bodhi')


def _get_db_session(config_uri):
"""
Expand Down
26 changes: 26 additions & 0 deletions bodhi/tests/server/scripts/test_approve_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,32 @@ def test_non_autokarma_update_with_unmet_karma_requirement(self):
for c in self.db.query(models.Comment).order_by(models.Comment.timestamp).all()]
self.assertEqual(usernames, [u'guest', u'anonymous', u'hunter2'])

def test_non_autokarma_update_with_unmet_karma_requirement_after_time_met(self):
"""
A non-autokarma update without enough karma that reaches mandatory days in testing should
get a comment from Bodhi that the update can be pushed to stable.
See https://github.com/fedora-infra/bodhi/issues/1094
"""
update = self.db.query(models.Update).all()[0]
update.autokarma = False
update.request = None
update.stable_karma = 10
update.status = models.UpdateStatus.testing
update.date_testing = datetime.now() - timedelta(days=7)
update.comment(self.db, 'testing', author='hunter2', anonymous=False, karma=1)

with patch(
'bodhi.server.scripts.approve_testing._get_db_session', return_value=self.db):
approve_testing.main(['nosetests', 'some_config.ini'])

bodhi = self.db.query(models.User).filter_by(name=u'bodhi').one()
comment_q = self.db.query(models.Comment).filter_by(update_id=update.id, user_id=bodhi.id)
self.assertEqual(comment_q.count(), 1)
self.assertEqual(
comment_q[0].text,
config.get('testing_approval_msg') % update.release.mandatory_days_in_testing)

# Set the release's mandatory days in testing to 0 to set up the condition for this test.
@patch.dict(config, [('fedora.mandatory_days_in_testing', 0)])
def test_non_autokarma_update_without_mandatory_days_in_testing(self):
Expand Down

0 comments on commit fa6dad4

Please sign in to comment.