def test_create_loan_bug(app): "Test problem loan bug creation includes stuff" # The slave name doesn't actually matter for this test slavetype = "foobar" who = "*****@*****.**" loan_id = 123456789 def create_bug_comment(data): data['id'] = 12345 ok_("summary" in data, msg="creation includes bug summary") ok_(slavetype in data['summary'], msg="bug summary includes slavetype") ok_(who in data['summary'], msg="bug summary includes who") ok_("comment" in data, msg="creation includes initial comment") ok_(slavetype in data['comment'], msg="comment includes slavetype") ok_(who in data['comment'], msg="comment includes who") ok_(str(loan_id) in data['comment'], msg="the loan id must appear in the comment") return data with app.app_context(): with mock.patch("bzrest.client.BugzillaClient.create_bug") as mockcreatebug: mockcreatebug.side_effect = create_bug_comment bugzilla.create_loan_bug(loan_id=loan_id, slavetype=slavetype, bugzilla_username=who)
def bmo_file_loan_bug(self, loanid, slavetype, *args, **kwargs): try: session = current_app.db.session('relengapi') l = session.query(Loans).get(loanid) if l.bug_id: # Nothing to do, bug ID passed in return l.bug_id bmo_id = l.human.bugzilla bug_id = bugzilla.create_loan_bug(loan_id=loanid, slavetype=slavetype, bugzilla_username=bmo_id) if not bug_id: raise ValueError("Unexpected result from bmo, retry") l.bug_id = bug_id session.commit() return bug_id except Exception as exc: logger.exception(exc) self.retry(exc=exc)