Commit 44876305 authored by Claude Paroz's avatar Claude Paroz

Transform TeamsAndRolesTests into TeamsAndRolesMixin

parent 2ae83edc
......@@ -11,47 +11,47 @@ from teams.models import Team, Role
from languages.models import Language
class TeamsAndRolesTests(TestCase):
def setUp(self):
self.pn = Person(first_name='John', last_name='Nothing',
class TeamsAndRolesMixin:
@classmethod
def setUpTestData(cls):
super().setUpTestData()
cls.pn = Person(first_name='John', last_name='Nothing',
email='jn@devnull.com', username= 'jn')
self.pn.set_password('password')
self.pn.save()
cls.pn.set_password('password')
cls.pn.save()
self.pt = Person.objects.create(first_name='John', last_name='Translator',
cls.pt = Person.objects.create(first_name='John', last_name='Translator',
email='jt@tf1.com', username= 'jt')
self.pr = Person.objects.create(first_name='John', last_name='Reviewer',
cls.pr = Person.objects.create(first_name='John', last_name='Reviewer',
email='jr@csa.com', username= 'jr')
self.pc = Person.objects.create(first_name='John', last_name='Committer',
cls.pc = Person.objects.create(first_name='John', last_name='Committer',
email='jc@alinsudesonpleingre.fr', username= 'jc',
last_login=datetime.now()-timedelta(days=30*6-1)) #active person, but in limit date
self.pcoo = Person(first_name='John', last_name='Coordinator',
cls.pcoo = Person(first_name='John', last_name='Coordinator',
email='jcoo@imthebigboss.fr', username= 'jcoo')
self.pcoo.set_password('password')
self.pcoo.save()
cls.pcoo.set_password('password')
cls.pcoo.save()
self.t = Team.objects.create(name='fr', description='French',
cls.t = Team.objects.create(name='fr', description='French',
mailing_list='french_ml@example.org')
self.t2 = Team.objects.create(name='pt', description='Portuguese')
cls.t2 = Team.objects.create(name='pt', description='Portuguese')
self.l = Language.objects.create(name='French', locale='fr', team=self.t)
cls.l = Language.objects.create(name='French', locale='fr', team=cls.t)
Role.objects.bulk_create([
Role(team=self.t, person=self.pt),
Role(team=self.t2, person=self.pt, role='reviewer'),
Role(team=self.t, person=self.pr, role='reviewer'),
Role(team=self.t, person=self.pc, role='committer'),
Role(team=self.t, person=self.pcoo, role='coordinator'),
Role(team=cls.t, person=cls.pt),
Role(team=cls.t2, person=cls.pt, role='reviewer'),
Role(team=cls.t, person=cls.pr, role='reviewer'),
Role(team=cls.t, person=cls.pc, role='committer'),
Role(team=cls.t, person=cls.pcoo, role='coordinator'),
])
class TeamTest(TeamsAndRolesTests):
def setUp(self):
super().setUp()
class TeamTests(TeamsAndRolesMixin, TestCase):
def test_get_members_by_role_exact(self):
members = self.t.get_members_by_role_exact('committer')
t = Team.objects.get(name='fr')
......@@ -216,7 +216,7 @@ class TeamTest(TeamsAndRolesTests):
)
class JSONTeamsTest(TeamsAndRolesTests):
class JSONTeamsTest(TeamsAndRolesMixin, TestCase):
def setUp(self):
super().setUp()
t3 = Team.objects.create(name='gl', description='Galician')
......@@ -262,7 +262,7 @@ class JSONTeamsTest(TeamsAndRolesTests):
self.assertJSONEqual(response.content.decode('utf-8'), expected_JSON)
class RoleTest(TeamsAndRolesTests):
class RoleTest(TeamsAndRolesMixin, TestCase):
def setUp(self):
super().setUp()
......
......@@ -9,13 +9,14 @@ from django.core.files.base import File, ContentFile
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core import mail
from django.http import QueryDict
from django.test import TestCase
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.datastructures import MultiValueDict
from people.models import Person
from teams.models import Role
from teams.tests import TeamsAndRolesTests
from teams.tests import TeamsAndRolesMixin
from stats.models import Module, Branch, Release, Category, CategoryName, Domain, Statistics
from stats.tests.utils import patch_shell_command, test_scratchdir
from vertimus.models import (
......@@ -29,7 +30,7 @@ MEDIA_ROOT = tempfile.mkdtemp()
@override_settings(MEDIA_ROOT=MEDIA_ROOT)
class VertimusTest(TeamsAndRolesTests):
class VertimusTest(TeamsAndRolesMixin, TestCase):
def setUp(self):
super().setUp()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment