~asbalderson/jenkins-launchpad-plugin/templating

« back to all changes in this revision

Viewing changes to jlp/launchpadutils.py

  • Committer: Alexander Balderson
  • Date: 2019-04-23 21:16:10 UTC
  • Revision ID: alexander.balderson@canonical.com-20190423211610-juw58uh8j586tbnc
Add documentation and clean up unit tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
370
370
 
371
371
 
372
372
def report_to_launchpad(mp, message, revision, status=None, vote=None):
 
373
    """Set the status and send a message to Launchpad for an merge proposal.
 
374
 
 
375
    :param mp: handle to merge proposal
 
376
    :param message: text message to post as a message
 
377
    :param revision: revision number for the proposal
 
378
    :param status: Launchpad status to set the propsal to
 
379
    :param vote: how the message should vote on the proposal
 
380
    """
373
381
    if status:
374
382
        mp.setStatus(status=status, revid=revision)
375
383
    if vote:
376
 
        mp.createComment(review_type=get_config_option('launchpad_review_type'),
 
384
        mp.createComment(
 
385
            review_type=get_config_option('launchpad_review_type'),
377
386
            vote=vote,
378
387
            subject=get_vote_subject(mp),
379
388
            content=message)
380
389
    else:
381
 
        mp.createComment(review_type=get_config_option('launchpad_review_type'),
 
390
        mp.createComment(
 
391
            review_type=get_config_option('launchpad_review_type'),
382
392
            subject=get_vote_subject(mp),
383
393
            content=message)
384
394
 
385
395
 
386
396
def get_template_args(result, revision, build_url, merge_url):
 
397
    """Collect a set of information for rendering templates
 
398
 
 
399
    :param result: Result of the tests, either PASSED or FAILED
 
400
    :param revison: The revision number of the merge
 
401
    :param build_url: URL to the build triggered in jenkins
 
402
    :param merge_url: URL to the merge proposal
 
403
    """
387
404
    jenkins = get_json_jenkins()
388
405
    args = {}
389
406
    args['result'] = result