* adds EcoAccount tests
* fixes bugs found by testing
This commit is contained in:
2021-11-10 09:11:24 +01:00
parent 1dc931d736
commit eb2e19cbe0
4 changed files with 251 additions and 6 deletions

View File

@@ -11,7 +11,7 @@ from django.contrib.auth.models import User, Group
from django.test import TestCase, Client
from django.urls import reverse
from compensation.models import Compensation, CompensationState, CompensationAction
from compensation.models import Compensation, CompensationState, CompensationAction, EcoAccount
from intervention.models import LegalData, ResponsibilityData, Intervention
from konova.management.commands.setup_data import GROUPS_DATA
from konova.models import Geometry
@@ -66,6 +66,7 @@ class BaseViewTestCase(BaseTestCase):
login_url = None
intervention = None
compensation = None
eco_account = None
comp_state = None
comp_action = None
@@ -75,6 +76,7 @@ class BaseViewTestCase(BaseTestCase):
cls.create_groups()
cls.create_dummy_intervention()
cls.create_dummy_compensation()
cls.create_dummy_eco_account()
cls.login_url = reverse("simple-sso-login")
def assert_url_success(self, client: Client, urls: list):
@@ -151,10 +153,11 @@ class BaseViewTestCase(BaseTestCase):
comment="Test",
)
cls.intervention.generate_access_token(make_unique=True)
return cls.intervention
@classmethod
def create_dummy_compensation(cls):
""" Creates an intervention which can be used for tests
""" Creates a compensation which can be used for tests
Returns:
@@ -178,6 +181,36 @@ class BaseViewTestCase(BaseTestCase):
comment="Test",
)
cls.intervention.generate_access_token(make_unique=True)
return cls.compensation
@classmethod
def create_dummy_eco_account(cls):
""" Creates an eco account which can be used for tests
Returns:
"""
# Create dummy data
# Create log entry
action = UserActionLogEntry.objects.create(
user=cls.superuser,
action=UserAction.CREATED,
)
geometry = Geometry.objects.create()
# Create responsible data object
lega_data = LegalData.objects.create()
responsible_data = ResponsibilityData.objects.create()
# Finally create main object, holding the other objects
cls.eco_account = EcoAccount.objects.create(
identifier="TEST",
title="Test_title",
legal=lega_data,
responsible=responsible_data,
created=action,
geometry=geometry,
comment="Test",
)
return cls.eco_account
@classmethod
def create_dummy_states(cls):

View File

@@ -16,4 +16,7 @@ DATA_UNSHARED = _("This data is not shared with you")
DATA_UNSHARED_EXPLANATION = _("Remember: This data has not been shared with you, yet. This means you can only read but can not edit or perform any actions like running a check or recording.")
MISSING_GROUP_PERMISSION = _("You need to be part of another user group.")
CHECKED_RECORDED_RESET = _("Status of Checked and Recorded reseted")
CHECKED_RECORDED_RESET = _("Status of Checked and Recorded reseted")
# ECO ACCOUNT
CANCEL_ACC_RECORDED_OR_DEDUCTED = _("Action canceled. Eco account is recorded or deductions exist. Only conservation office member can perform this action.")