|
@@ -13,7 +13,8 @@ import pytest
|
|
|
|
|
|
from taipy.config.common.frequency import Frequency
|
|
from taipy.config.common.frequency import Frequency
|
|
from taipy.core.exceptions.exceptions import InvalidEventAttributeName, InvalidEventOperation
|
|
from taipy.core.exceptions.exceptions import InvalidEventAttributeName, InvalidEventOperation
|
|
-from taipy.core.notification.event import Event, EventEntityType, EventOperation
|
|
|
|
|
|
+from taipy.core.notification.event import Event, EventEntityType, EventOperation, _make_event
|
|
|
|
+from taipy.core.submission.submission import Submission
|
|
|
|
|
|
|
|
|
|
def test_event_creation_cycle():
|
|
def test_event_creation_cycle():
|
|
@@ -360,3 +361,39 @@ def test_event_creation_job():
|
|
operation=EventOperation.SUBMISSION,
|
|
operation=EventOperation.SUBMISSION,
|
|
attribute_name="force",
|
|
attribute_name="force",
|
|
)
|
|
)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def test_event_creation_submission():
|
|
|
|
+ event_1 = Event(
|
|
|
|
+ entity_type=EventEntityType.SUBMISSION, entity_id="submission_id", operation=EventOperation.CREATION
|
|
|
|
+ )
|
|
|
|
+ assert event_1.creation_date is not None
|
|
|
|
+ assert event_1.entity_type == EventEntityType.SUBMISSION
|
|
|
|
+ assert event_1.entity_id == "submission_id"
|
|
|
|
+ assert event_1.operation == EventOperation.CREATION
|
|
|
|
+ assert event_1.attribute_name is None
|
|
|
|
+
|
|
|
|
+ with pytest.raises(InvalidEventAttributeName):
|
|
|
|
+ _ = Event(
|
|
|
|
+ entity_type=EventEntityType.SUBMISSION,
|
|
|
|
+ entity_id="submission_id",
|
|
|
|
+ operation=EventOperation.DELETION,
|
|
|
|
+ attribute_name="force",
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ with pytest.raises(InvalidEventOperation):
|
|
|
|
+ _ = Event(
|
|
|
|
+ entity_type=EventEntityType.SUBMISSION, entity_id="submission_id", operation=EventOperation.SUBMISSION
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def test_make_event_from_submission():
|
|
|
|
+ submission = Submission("submission_id", entity_type="task", entity_config_id="task_config_id_1")
|
|
|
|
+ event = _make_event(submission, EventOperation.CREATION)
|
|
|
|
+
|
|
|
|
+ assert event.operation == EventOperation.CREATION
|
|
|
|
+ assert event.entity_id
|
|
|
|
+ assert event.entity_type == EventEntityType.SUBMISSION
|
|
|
|
+ assert event.metadata["origin_entity_id"] == "submission_id"
|
|
|
|
+ assert event.metadata["origin_entity_type"] == "task"
|
|
|
|
+ assert event.metadata["origin_entity_config_id"] == "task_config_id_1"
|