summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBen Copeland <ben.copeland@linaro.org>2017-04-20 15:38:42 +0100
committerBen Copeland <ben.copeland@linaro.org>2017-05-04 15:20:59 +0100
commitfca0acaf973b9f1266bd3a9615beaf8d1640c95e (patch)
tree3e4b77705d34302f6563bba247d3ce08f062f14a /tests
parent0eb2053654b485f6dc48ff3923398d7c945c7b80 (diff)
update_commited_patches: Add support for Team/Group credits
Add support to allow reviewed/signed off by (etc) to be added as a credit into the database. Change-Id: Id814b89b59a6150a8400c95a0040b51a2cfedd56
Diffstat (limited to 'tests')
-rw-r--r--tests/test_update_commited_patches.py38
1 files changed, 35 insertions, 3 deletions
diff --git a/tests/test_update_commited_patches.py b/tests/test_update_commited_patches.py
index e03e504..a94bc6b 100644
--- a/tests/test_update_commited_patches.py
+++ b/tests/test_update_commited_patches.py
@@ -7,8 +7,14 @@ import update_commited_patches
from django.test import TestCase
from patchwork.models import Patch, Project, State
+from linaro_metrics.models import TeamTagCredit, TeamMembership, Team
+from linaro_metrics.parsemail import get_linaro_person
from tests import TestRepo
+import mock
+
+from linaro_metrics.team_project_credit import update_commit_callback
+
class TestUpdateCommitedPatches(TestCase):
'''This class does a bunch of mocking and setup, but the code it tests is
@@ -47,7 +53,7 @@ class TestUpdateCommitedPatches(TestCase):
self.assertEqual(State.objects.get(name='New'), patches[0].state)
update_commited_patches._update_project(
- self.tmpdir, self.project, [], False)
+ None, self.tmpdir, self.project, [], False)
patches = Patch.objects.all()
self.assertEqual(1, patches.count())
@@ -66,7 +72,7 @@ class TestUpdateCommitedPatches(TestCase):
self.assertEqual(State.objects.get(name='New'), patches[0].state)
update_commited_patches._update_project(
- self.tmpdir, self.project, [], False)
+ None, self.tmpdir, self.project, [], False)
patches = Patch.objects.all()
self.assertEqual(1, patches.count())
@@ -88,8 +94,34 @@ class TestUpdateCommitedPatches(TestCase):
['git', 'commit', '--amend', '--no-edit',
'--author=foo bar <foo@bar.com>'])
update_commited_patches._update_project(
- self.tmpdir, self.project, [], False)
+ None, self.tmpdir, self.project, [], False)
patches = Patch.objects.all()
self.assertEqual(1, patches.count())
self.assertEqual(State.objects.get(name='Accepted'), patches[0].state)
+
+ def test_team_project_credit(self):
+ '''Ensure a git tag credit gets added'''
+
+ commits = mock.Mock()
+ commits.message = 'Commit message\n' \
+ 'Signed-off-by: Foo Bar <foo.bar@linaro.org>'
+ commits.id = '1234'
+ crowd = mock.Mock()
+ crowd.user_valid.return_value = True
+
+ crowd.get_user_no_cache.return_value = {
+ 'display-name': 'foo.bar@linaro.org',
+ 'email': 'foo.bar@linaro.org',
+ }
+
+ p = get_linaro_person(crowd, 'foo.bar@linaro.org').user
+ t = Team.objects.create(name='TeamName')
+ TeamMembership.objects.create(team=t, user=p)
+
+ update_commit_callback(crowd, self.project, None, commits, False)
+
+ credits = TeamTagCredit.objects.all()
+ self.assertEqual(1, credits.count())
+ credit = TeamTagCredit.objects.get(tag='Signed-off')
+ self.assertEqual('1234', credit.commit)