mirror of https://github.com/sipwise/repoapi.git
* keep track of reviews/commits sent to workfront so just one note will be sent per action * notes will be private * using workfront-post-note script Change-Id: Ibde45086ff4e3c922650f1f290d643a61c42e0ecchanges/35/7035/10
parent
58f9d526b0
commit
35d2c97d58
@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('repoapi', '0005_jenkinsbuildinfo_git_commit'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='WorkfrontNoteInfo',
|
||||
fields=[
|
||||
('id', models.AutoField(
|
||||
verbose_name='ID', serialize=False,
|
||||
auto_created=True, primary_key=True)),
|
||||
('workfront_id', models.CharField(max_length=50)),
|
||||
('gerrit_change', models.CharField(max_length=50)),
|
||||
],
|
||||
),
|
||||
migrations.AlterUniqueTogether(
|
||||
name='workfrontnoteinfo',
|
||||
unique_together=set([('workfront_id', 'gerrit_change')]),
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,173 @@
|
||||
# Copyright (C) 2016 The Sipwise Team - http://sipwise.com
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the Free
|
||||
# Software Foundation, either version 3 of the License, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.test import TestCase
|
||||
from django.conf import settings
|
||||
from repoapi.models import JenkinsBuildInfo, WorkfrontNoteInfo
|
||||
from mock import patch
|
||||
|
||||
|
||||
class WorkfrontNoteTestCase(TestCase):
|
||||
|
||||
def test_getID(self):
|
||||
res = WorkfrontNoteInfo.getIds("jojo TT#0891 whatever")
|
||||
self.assertItemsEqual(res, ['0891'])
|
||||
|
||||
def test_getID_multiple(self):
|
||||
res = WorkfrontNoteInfo.getIds("jojo TT#0891 whatever TT#0001")
|
||||
self.assertItemsEqual(res, ['0891', '0001'])
|
||||
|
||||
def test_getID_multiple_duplicate(self):
|
||||
res = WorkfrontNoteInfo.getIds("jojo TT#0891 whatever TT#0001 TT#0891")
|
||||
self.assertItemsEqual(res, ['0891', '0001'])
|
||||
|
||||
def test_getCommit(self):
|
||||
res = WorkfrontNoteInfo.getCommit("1234567 TT#67676 whatever")
|
||||
self.assertEquals(res, "1234567")
|
||||
|
||||
@patch('repoapi.utils.workfront_note_send')
|
||||
def test_note_gerrit(self, utils):
|
||||
JenkinsBuildInfo.objects.create(
|
||||
tag="edc90cd9-37f3-4613-9748-ed05a32031c2",
|
||||
projectname="kamailio",
|
||||
jobname="kamailio-gerrit",
|
||||
buildnumber=897,
|
||||
result="SUCCESS",
|
||||
job_url="https://jenkins.mgm.sipwise.com/job/kamailio-gerrit/",
|
||||
gerrit_patchset="1",
|
||||
gerrit_change="2054",
|
||||
gerrit_eventtype="patchset-created",
|
||||
param_tag="none",
|
||||
param_branch="master",
|
||||
param_release="none",
|
||||
param_distribution="wheezy",
|
||||
param_ppa="gerrit_MT10339_review2054")
|
||||
|
||||
gri = WorkfrontNoteInfo.objects.filter(
|
||||
workfront_id="0001",
|
||||
gerrit_change="2054")
|
||||
self.assertEquals(gri.count(), 0)
|
||||
|
||||
JenkinsBuildInfo.objects.create(
|
||||
tag="edc90cd9-37f3-4613-9748-ed05a32031c2",
|
||||
projectname="kamailio",
|
||||
jobname="kamailio-get-code",
|
||||
buildnumber=897,
|
||||
result="SUCCESS",
|
||||
job_url="https://jenkins.mgm.sipwise.com/job/kamailio-get-code/",
|
||||
gerrit_patchset="1",
|
||||
gerrit_change="2054",
|
||||
gerrit_eventtype="patchset-created",
|
||||
param_tag="none",
|
||||
param_branch="master",
|
||||
param_release="none",
|
||||
param_distribution="wheezy",
|
||||
param_ppa="gerrit_MT10339_review2054",
|
||||
git_commit_msg="7fg4567 TT#0001 whatever")
|
||||
|
||||
gri = WorkfrontNoteInfo.objects.filter(
|
||||
workfront_id="0001",
|
||||
gerrit_change="2054")
|
||||
self.assertEquals(gri.count(), 1)
|
||||
msg = "review created %s" % settings.GERRIT_URL.format("2054")
|
||||
utils.assert_called_once_with("0001", msg)
|
||||
|
||||
@patch('repoapi.utils.workfront_note_send')
|
||||
def test_note_merge(self, utils):
|
||||
JenkinsBuildInfo.objects.create(
|
||||
tag="edc90cd9-37f3-4613-9748-ed05a32031c2",
|
||||
projectname="kamailio",
|
||||
jobname="kamailio-gerrit",
|
||||
buildnumber=897,
|
||||
result="SUCCESS",
|
||||
job_url="https://jenkins.mgm.sipwise.com/job/kamailio-gerrit/",
|
||||
gerrit_patchset="1",
|
||||
gerrit_change="2054",
|
||||
gerrit_eventtype="change-merged",
|
||||
param_tag="none",
|
||||
param_branch="master",
|
||||
param_release="none",
|
||||
param_distribution="wheezy",
|
||||
param_ppa="gerrit_MT10339_review2054")
|
||||
|
||||
gri = WorkfrontNoteInfo.objects.filter(
|
||||
workfront_id="0001",
|
||||
gerrit_change="2054")
|
||||
self.assertEquals(gri.count(), 0)
|
||||
|
||||
JenkinsBuildInfo.objects.create(
|
||||
tag="edc90cd9-37f3-4613-9748-ed05a32031c2",
|
||||
projectname="kamailio",
|
||||
jobname="kamailio-get-code",
|
||||
buildnumber=897,
|
||||
result="SUCCESS",
|
||||
job_url="https://jenkins.mgm.sipwise.com/job/kamailio-get-code/",
|
||||
gerrit_patchset="1",
|
||||
gerrit_change="2054",
|
||||
gerrit_eventtype="change-merged",
|
||||
param_tag="none",
|
||||
param_branch="master",
|
||||
param_release="none",
|
||||
param_distribution="wheezy",
|
||||
param_ppa="gerrit_MT10339_review2054",
|
||||
git_commit_msg="7fg456 TT#0001 whatever")
|
||||
|
||||
gri = WorkfrontNoteInfo.objects.filter(
|
||||
workfront_id="0001",
|
||||
gerrit_change="2054")
|
||||
self.assertEquals(gri.count(), 1)
|
||||
msg = "review merged %s" % settings.GERRIT_URL.format("2054")
|
||||
utils.assert_called_once_with("0001", msg)
|
||||
|
||||
@patch('repoapi.utils.workfront_note_send')
|
||||
def test_note_commit(self, utils):
|
||||
JenkinsBuildInfo.objects.create(
|
||||
tag="edc90cd9-37f3-4613-9748-ed05a32031c2",
|
||||
projectname="kamailio",
|
||||
jobname="kamailio-get-code",
|
||||
buildnumber=897,
|
||||
result="SUCCESS",
|
||||
job_url="https://jenkins.mgm.sipwise.com/job/kamailio-get-code/",
|
||||
param_tag="none",
|
||||
param_branch="master",
|
||||
param_release="none",
|
||||
param_distribution="wheezy",
|
||||
git_commit_msg="7fg4567 TT#0001 whatever")
|
||||
|
||||
gri = WorkfrontNoteInfo.objects.filter(
|
||||
workfront_id="0001",
|
||||
gerrit_change="7fg4567")
|
||||
self.assertEquals(gri.count(), 1)
|
||||
|
||||
JenkinsBuildInfo.objects.create(
|
||||
tag="edc90cd9-37f3-4613-9748-ed05a32031c2",
|
||||
projectname="kamailio",
|
||||
jobname="kamailio-binaries",
|
||||
buildnumber=897,
|
||||
result="SUCCESS",
|
||||
job_url="https://jenkins.mgm.sipwise.com/job/kamailio-binaries/",
|
||||
param_tag="none",
|
||||
param_branch="master",
|
||||
param_release="none",
|
||||
param_distribution="wheezy",
|
||||
git_commit_msg="7fg4567 TT#0001 whatever")
|
||||
|
||||
gri = WorkfrontNoteInfo.objects.filter(
|
||||
workfront_id="0001",
|
||||
gerrit_change="7fg4567")
|
||||
self.assertEquals(gri.count(), 1)
|
||||
msg = "commit created %s" % settings.GITWEB_URL.format(
|
||||
"kamailio", "7fg4567")
|
||||
utils.assert_called_once_with("0001", msg)
|
||||
Loading…
Reference in new issue