# Unit test konova app

* adds unit test for konova app models
* drops unused/unnecessary code fragments
* updates translation
This commit is contained in:
2023-09-08 12:47:50 +02:00
parent 530ceb3876
commit 89efc33d75
11 changed files with 255 additions and 85 deletions

View File

@@ -23,13 +23,9 @@ from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpRequest
from django.utils.timezone import now
from django.db import models, transaction
from compensation.settings import COMPENSATION_IDENTIFIER_TEMPLATE, COMPENSATION_IDENTIFIER_LENGTH, \
ECO_ACCOUNT_IDENTIFIER_TEMPLATE, ECO_ACCOUNT_IDENTIFIER_LENGTH
from ema.settings import EMA_IDENTIFIER_LENGTH, EMA_IDENTIFIER_TEMPLATE
from intervention.settings import INTERVENTION_IDENTIFIER_LENGTH, INTERVENTION_IDENTIFIER_TEMPLATE
from konova.utils import generators
from konova.utils.generators import generate_random_string
from konova.utils.message_templates import CHECKED_RECORDED_RESET, GEOMETRY_CONFLICT_WITH_TEMPLATE
from konova.utils.message_templates import GEOMETRY_CONFLICT_WITH_TEMPLATE
class UuidModel(models.Model):
@@ -298,27 +294,6 @@ class RecordableObjectMixin(models.Model):
return action
def unrecord(self, performing_user, request: HttpRequest = None):
""" Unrecords a dataset
Args:
performing_user (User): The user which performed the editing action
request (HttpRequest): The used request for this action
Returns:
"""
action = None
if self.recorded:
action = self.set_unrecorded(performing_user)
self.log.add(action)
if request:
messages.info(
request,
CHECKED_RECORDED_RESET
)
return action
@abstractmethod
def is_ready_for_publish(self) -> bool:
""" Check for all needed publishing-constraints on the data
@@ -353,7 +328,7 @@ class CheckableObjectMixin(models.Model):
abstract = True
def set_unchecked(self) -> None:
""" Perform unrecording
""" Perform unchecking
Args:
@@ -363,7 +338,7 @@ class CheckableObjectMixin(models.Model):
if not self.checked:
# Nothing to do
return
# Do not .delete() the checked attribute! Just set it to None, since a delete() would kill it out of the
# Do not .delete() the checked attribute! Just set it to None, since a delete() would remove it from the
# log history, which is not what we want!
self.checked = None
self.save()