Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

86: Add system test to check if the first and last progress updates a… #107

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions system_tests/src/test_workflows_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
import threading
import unittest
import uuid
from datetime import timedelta
from pathlib import Path
from pprint import pformat
Expand Down Expand Up @@ -92,8 +93,8 @@ def submit_a_job(
workflow_type: str,
params_dict: ParamsDict,
omotes_job_result_handler: OmotesJobHandler,
):
omotes_client.submit_job(
) -> Job:
return omotes_client.submit_job(
esdl=esdl_file,
workflow_type=omotes_client.get_workflow_type_manager().get_workflow_by_name(workflow_type),
job_timeout=timedelta(hours=1),
Expand Down Expand Up @@ -311,3 +312,35 @@ def test__simulator__job_reference_is_set(self) -> None:
self.assertEqual(
output_esh.energy_system.name, "Untitled EnergySystem with return network_simulator"
)

def test__simulator__check_if_progress_updates_are_received(self) -> None:
# Arrange
result_handler = OmotesJobHandler()
esdl_file = retrieve_esdl_file("./test_esdl/input/simulator_tutorial.esdl")
workflow_type = "simulator"
timeout_seconds = 60.0
params_dict = {
"timestep": datetime.timedelta(hours=1),
"start_time": datetime.datetime(2019, 1, 1, 0, 0, 0),
"end_time": datetime.datetime(2019, 1, 1, 3, 0, 0),
}

# Act
with omotes_client() as omotes_client_:
submitted_job = submit_a_job(
omotes_client_, esdl_file, workflow_type, params_dict, result_handler
)
result_handler.wait_until_result(timeout_seconds)

# Assert
self.expect_a_result(result_handler, JobResult.SUCCEEDED)
first_update = next(
(update for update in result_handler.progress_updates if update.progress == 0.0), None
)
last_update = next(
(update for update in result_handler.progress_updates if update.progress == 1.0), None
)
self.assertIsNotNone(first_update)
self.assertEqual(submitted_job.id, uuid.UUID(first_update.uuid))
self.assertIsNotNone(last_update)
self.assertEqual(submitted_job.id, uuid.UUID(last_update.uuid))
Loading