#101 Team sharing tests
* adds tests for team sharing * extends the API for team sharing support * adds shared_teams property shortcut for ShareableObjectMixin * adds full support for team-based sharing to all views and functions * simplifies ShareModalForm * adds/updates translations
This commit is contained in:
@@ -9,7 +9,7 @@ import datetime
|
||||
|
||||
from codelist.settings import CODELIST_CONSERVATION_OFFICE_ID
|
||||
from ema.models import Ema
|
||||
from user.models import User
|
||||
from user.models import User, Team
|
||||
from django.contrib.auth.models import Group
|
||||
from django.contrib.gis.geos import MultiPolygon, Polygon
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
@@ -65,6 +65,7 @@ class BaseTestCase(TestCase):
|
||||
self.create_dummy_states()
|
||||
self.create_dummy_action()
|
||||
self.codes = self.create_dummy_codes()
|
||||
self.team = self.create_dummy_team()
|
||||
|
||||
# Set the default group as only group for the user
|
||||
default_group = self.groups.get(name=DEFAULT_GROUP)
|
||||
@@ -251,6 +252,24 @@ class BaseTestCase(TestCase):
|
||||
])
|
||||
return codes
|
||||
|
||||
def create_dummy_team(self):
|
||||
""" Creates a dummy team
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
if self.superuser is None:
|
||||
self.create_users()
|
||||
|
||||
team = Team.objects.get_or_create(
|
||||
name="Testteam",
|
||||
description="Testdescription",
|
||||
admin=self.superuser,
|
||||
)[0]
|
||||
team.users.add(self.superuser)
|
||||
|
||||
return team
|
||||
|
||||
@staticmethod
|
||||
def create_dummy_geometry() -> MultiPolygon:
|
||||
""" Creates some geometry
|
||||
|
||||
Reference in New Issue
Block a user