Further tests
* restructures compensation/tests into subtests for ecoaccount and compensation * adds tests for ema workflow * improved test data setup
This commit is contained in:
@@ -132,7 +132,7 @@ class BaseObject(BaseResource):
|
||||
|
||||
self.save()
|
||||
|
||||
def mark_as_edited(self, performing_user: User, edit_comment: str = None):
|
||||
def mark_as_edited(self, performing_user: User, request: HttpRequest = None, edit_comment: str = None):
|
||||
""" In case the object or a related object changed the log history needs to be updated
|
||||
|
||||
Args:
|
||||
|
||||
@@ -7,6 +7,7 @@ Created on: 26.10.21
|
||||
"""
|
||||
import datetime
|
||||
|
||||
from codelist.settings import CODELIST_CONSERVATION_OFFICE_ID
|
||||
from ema.models import Ema
|
||||
from user.models import User
|
||||
from django.contrib.auth.models import Group
|
||||
@@ -15,7 +16,7 @@ from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.test import TestCase, Client
|
||||
from django.urls import reverse
|
||||
|
||||
from codelist.models import KonovaCode
|
||||
from codelist.models import KonovaCode, KonovaCodeList
|
||||
from compensation.models import Compensation, CompensationState, CompensationAction, EcoAccount, EcoAccountDeduction
|
||||
from intervention.models import Legal, Responsibility, Intervention
|
||||
from konova.management.commands.setup_data import GROUPS_DATA
|
||||
@@ -236,10 +237,10 @@ class BaseTestCase(TestCase):
|
||||
|
||||
"""
|
||||
codes = KonovaCode.objects.bulk_create([
|
||||
KonovaCode(id=1, is_selectable=True, long_name="Test1"),
|
||||
KonovaCode(id=2, is_selectable=True, long_name="Test2"),
|
||||
KonovaCode(id=3, is_selectable=True, long_name="Test3"),
|
||||
KonovaCode(id=4, is_selectable=True, long_name="Test4"),
|
||||
KonovaCode(id=1, is_selectable=True, is_archived=False, is_leaf=True, long_name="Test1"),
|
||||
KonovaCode(id=2, is_selectable=True, is_archived=False, is_leaf=True, long_name="Test2"),
|
||||
KonovaCode(id=3, is_selectable=True, is_archived=False, is_leaf=True, long_name="Test3"),
|
||||
KonovaCode(id=4, is_selectable=True, is_archived=False, is_leaf=True, long_name="Test4"),
|
||||
])
|
||||
return codes
|
||||
|
||||
@@ -298,6 +299,37 @@ class BaseTestCase(TestCase):
|
||||
compensation.geometry.save()
|
||||
return compensation
|
||||
|
||||
@classmethod
|
||||
def get_conservation_office_code(cls):
|
||||
""" Returns a dummy KonovaCode as conservation office code
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
codelist = KonovaCodeList.objects.get_or_create(
|
||||
id=CODELIST_CONSERVATION_OFFICE_ID
|
||||
)[0]
|
||||
code = KonovaCode.objects.get(id=2)
|
||||
codelist.codes.add(code)
|
||||
return code
|
||||
|
||||
@classmethod
|
||||
def fill_out_ema(cls, ema):
|
||||
""" Adds all required (dummy) data to an Ema
|
||||
|
||||
Returns:
|
||||
"""
|
||||
ema.responsible.conservation_office = cls.get_conservation_office_code()
|
||||
ema.responsible.conservation_file_number = "test"
|
||||
ema.responsible.handler = "handler"
|
||||
ema.responsible.save()
|
||||
ema.after_states.add(cls.comp_state)
|
||||
ema.before_states.add(cls.comp_state)
|
||||
ema.actions.add(cls.comp_action)
|
||||
ema.geometry.geom = cls.create_dummy_geometry()
|
||||
ema.geometry.save()
|
||||
return ema
|
||||
|
||||
def assert_equal_geometries(self, geom1: MultiPolygon, geom2: MultiPolygon):
|
||||
""" Assert for geometries to be equal
|
||||
|
||||
|
||||
Reference in New Issue
Block a user