Unit test EMA model

* adds unit test for EMA model
This commit is contained in:
2023-08-24 10:59:32 +02:00
parent f1f73d0a66
commit 02e8d65f02
5 changed files with 108 additions and 8 deletions

View File

@@ -122,7 +122,7 @@ class EmaDocument(AbstractDocument):
def delete(self, user=None, *args, **kwargs):
"""
Custom delete functionality for EcoAccountDocuments.
Custom delete functionality for EmaDocuments.
Removes the folder from the file system if there are no further documents for this entry.
Args:
@@ -139,8 +139,11 @@ class EmaDocument(AbstractDocument):
# The only file left for this EMA is the one which is currently processed and will be deleted
# Make sure that the compensation folder itself is deleted as well, not only the file
# Therefore take the folder path from the file path
folder_path = self.file.path.split("/")[:-1]
folder_path = "/".join(folder_path)
try:
folder_path = self.file.path.split("/")[:-1]
folder_path = "/".join(folder_path)
except ValueError:
folder_path = None
if user:
self.instance.mark_as_edited(user, edit_comment=DOCUMENT_REMOVED_TEMPLATE.format(self.title))