Skip to content

Commit

Permalink
✅ [#76] added documenthandelingen tests for Document admin and api.
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-maykin committed Nov 13, 2024
1 parent 67d86b1 commit 06079d7
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 90 deletions.
6 changes: 5 additions & 1 deletion src/woo_publications/publications/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,11 @@ def documenthandelingen(self) -> document_actions:
{
"soort_handeling": self.soort_handeling,
"vanaf": self.vanaf,
"was_geassocieerd_met": self.publicatie.verantwoordelijke,
"was_geassocieerd_met": (
self.publicatie.verantwoordelijke.uuid
if self.publicatie.verantwoordelijke
else None
),
}
]

Expand Down
19 changes: 18 additions & 1 deletion src/woo_publications/publications/tests/test_admin_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
from woo_publications.utils.tests.webtest import add_dynamic_field

from ..constants import PublicationStatusOptions
from ..constants import DocumentActionTypeOptions, PublicationStatusOptions
from ..models import Document, Publication
from .factories import DocumentFactory, PublicationFactory

Expand Down Expand Up @@ -445,6 +445,8 @@ def test_admin_inline_update_admin(self):
"document_service": None,
"registratiedatum": "2024-09-25T00:14:00Z",
"laatst_gewijzigd_datum": "2024-09-25T00:14:00Z",
"soort_handeling": DocumentActionTypeOptions.declaration,
"vanaf": "2024-09-25T02:14:00+02:00",
},
"_cached_object_repr": "title",
}
Expand Down Expand Up @@ -498,6 +500,11 @@ def test_admin_inline_create_admin(self):
add_dynamic_field(form, "document_set-0-bestandsformaat", "application/pdf")
add_dynamic_field(form, "document_set-0-bestandsnaam", "foo.pdf")
add_dynamic_field(form, "document_set-0-bestandsomvang", "0")
add_dynamic_field(
form,
"document_set-0-soort_handeling",
DocumentActionTypeOptions.declaration.value,
)

with freeze_time("2024-09-26T00:14:00-00:00"):
response = form.submit(name="_save")
Expand Down Expand Up @@ -531,6 +538,8 @@ def test_admin_inline_create_admin(self):
"officiele_titel": "title",
"registratiedatum": "2024-09-26T00:14:00Z",
"laatst_gewijzigd_datum": "2024-09-26T00:14:00Z",
"vanaf": "2024-09-26T00:14:00Z",
"soort_handeling": DocumentActionTypeOptions.declaration,
"document_service": None,
"document_uuid": None,
"lock": "",
Expand Down Expand Up @@ -619,6 +628,8 @@ def test_admin_inline_delete(self):
"document_service": None,
"registratiedatum": "2024-09-25T00:14:00Z",
"laatst_gewijzigd_datum": "2024-09-25T00:14:00Z",
"soort_handeling": DocumentActionTypeOptions.declaration,
"vanaf": "2024-09-25T02:14:00+02:00",
},
"_cached_object_repr": "DELETE THIS ITEM",
}
Expand Down Expand Up @@ -689,6 +700,8 @@ def test_document_admin_create(self):
"document_service": None,
"registratiedatum": "2024-09-24T12:00:00Z",
"laatst_gewijzigd_datum": "2024-09-24T12:00:00Z",
"soort_handeling": DocumentActionTypeOptions.declaration,
"vanaf": "2024-09-24T12:00:00Z",
},
"_cached_object_repr": "The official title of this document",
}
Expand Down Expand Up @@ -769,6 +782,8 @@ def test_document_admin_update(self):
"document_service": None,
"registratiedatum": "2024-09-25T14:00:00Z",
"laatst_gewijzigd_datum": "2024-09-29T14:00:00Z",
"soort_handeling": DocumentActionTypeOptions.declaration,
"vanaf": "2024-09-25T16:00:00+02:00",
},
"_cached_object_repr": "changed official title",
}
Expand Down Expand Up @@ -828,6 +843,8 @@ def test_document_admin_delete(self):
"document_service": None,
"registratiedatum": "2024-09-25T14:00:00Z",
"laatst_gewijzigd_datum": "2024-09-25T14:00:00Z",
"soort_handeling": DocumentActionTypeOptions.declaration,
"vanaf": "2024-09-25T14:00:00Z",
},
"_cached_object_repr": "title one",
}
Expand Down
Loading

0 comments on commit 06079d7

Please sign in to comment.