Skip to content

Commit 53b858b

Browse files
author
Alan Christie
committed
fix: Fix test execution
1 parent a38c626 commit 53b858b

File tree

3 files changed

+13
-82
lines changed

3 files changed

+13
-82
lines changed

tests/instance_launcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def launch(self, *, launch_parameters: LaunchParameters) -> LaunchResult:
106106
)
107107

108108
# Now add the running workflow ID ot the instance record.
109-
self._api_adapter.set_instance_running_workflow_id(
109+
self._api_adapter.set_instance_running_workflow_step_id(
110110
instance_id=instance_id,
111111
running_workflow_step_id=rwfs_id,
112112
)

tests/test_test_wapi_adapter.py

Lines changed: 3 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -324,20 +324,9 @@ def test_get_running_workflow_step_with_prior_step():
324324
def test_create_instance():
325325
# Arrange
326326
utaa = UnitTestWorkflowAPIAdapter()
327-
response = utaa.create_workflow(workflow_definition={"name": "blah"})
328-
response = utaa.create_running_workflow(
329-
user_id="dlister",
330-
workflow_id=response["id"],
331-
project_id=TEST_PROJECT_ID,
332-
variables={},
333-
)
334-
response, _ = utaa.create_running_workflow_step(
335-
running_workflow_id=response["id"], step="step-1", instance_id=_I_ID
336-
)
337-
rwfs_id = response["id"]
338327

339328
# Act
340-
response = utaa.create_instance(running_workflow_step_id=rwfs_id)
329+
response = utaa.create_instance()
341330

342331
# Assert
343332
assert "id" in response
@@ -346,79 +335,14 @@ def test_create_instance():
346335
def test_create_and_get_instance():
347336
# Arrange
348337
utaa = UnitTestWorkflowAPIAdapter()
349-
response = utaa.create_workflow(workflow_definition={"name": "blah"})
350-
response = utaa.create_running_workflow(
351-
user_id="dlister",
352-
workflow_id=response["id"],
353-
project_id=TEST_PROJECT_ID,
354-
variables={},
355-
)
356-
response, _ = utaa.create_running_workflow_step(
357-
running_workflow_id=response["id"], step="step-1", instance_id=_I_ID
358-
)
359-
rwfs_id = response["id"]
360-
response = utaa.create_instance(running_workflow_step_id=rwfs_id)
338+
response = utaa.create_instance()
361339
instance_id = response["id"]
362340

363341
# Act
364342
response, _ = utaa.get_instance(instance_id=instance_id)
365343

366344
# Assert
367-
assert response["running_workflow_step_id"] == rwfs_id
368-
369-
370-
def test_create_instance_and_get_step_instance_directory():
371-
# Arrange
372-
utaa = UnitTestWorkflowAPIAdapter()
373-
response = utaa.create_workflow(workflow_definition={"name": "blah"})
374-
response = utaa.create_running_workflow(
375-
user_id="dlister",
376-
workflow_id=response["id"],
377-
project_id=TEST_PROJECT_ID,
378-
variables={},
379-
)
380-
response, _ = utaa.create_running_workflow_step(
381-
running_workflow_id=response["id"], step="step-1", instance_id=_I_ID
382-
)
383-
rwfs_id = response["id"]
384-
response = utaa.create_instance(running_workflow_step_id=rwfs_id)
385-
i_id = response["id"]
386-
387-
# Act
388-
response, _ = utaa.get_running_workflow_step(running_workflow_step_id=rwfs_id)
389-
390-
# Assert
391-
assert "instance_directory" in response
392-
assert response["instance_directory"] == f".{i_id}"
393-
394-
395-
def test_create_instance_and_get_step_instance_directory_by_name():
396-
# Arrange
397-
utaa = UnitTestWorkflowAPIAdapter()
398-
response = utaa.create_workflow(workflow_definition={"name": "blah"})
399-
wf_id = response["id"]
400-
response = utaa.create_running_workflow(
401-
user_id="dlister",
402-
workflow_id=wf_id,
403-
project_id=TEST_PROJECT_ID,
404-
variables={},
405-
)
406-
rwf_id = response["id"]
407-
response, _ = utaa.create_running_workflow_step(
408-
running_workflow_id=rwf_id, step="step-1", instance_id=_I_ID
409-
)
410-
rwfs_id = response["id"]
411-
response = utaa.create_instance(running_workflow_step_id=rwfs_id)
412-
i_id = response["id"]
413-
414-
# Act
415-
response, _ = utaa.get_running_workflow_step_by_name(
416-
running_workflow_id=rwf_id, name="step-1"
417-
)
418-
419-
# Assert
420-
assert "instance_directory" in response
421-
assert response["instance_directory"] == f".{i_id}"
345+
assert response["running_workflow_step_id"] == ""
422346

423347

424348
def test_get_running_workflow_step_by_name():

tests/wapi_adapter.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,22 +352,29 @@ def create_instance(self) -> dict[str, Any]:
352352
next_id: int = len(instances) + 1
353353
instance_id: str = _INSTANCE_ID_FORMAT.format(id=next_id)
354354

355+
record = {
356+
"id": "instance_id",
357+
"running_workflow_step_id": "",
358+
"instance_directory": f".{instance_id}",
359+
}
360+
instances[instance_id] = record
361+
355362
with open(_INSTANCE_PICKLE_FILE, "wb") as pickle_file:
356363
Pickler(pickle_file).dump(instances)
357364

358365
UnitTestWorkflowAPIAdapter.lock.release()
359366

360367
return {"id": instance_id}
361368

362-
def set_instance_running_workflow_id(
369+
def set_instance_running_workflow_step_id(
363370
self, *, instance_id: str, running_workflow_step_id: str
364371
) -> None:
365372
UnitTestWorkflowAPIAdapter.lock.acquire()
366373
with open(_INSTANCE_PICKLE_FILE, "rb") as pickle_file:
367374
instances = Unpickler(pickle_file).load()
368375

369376
assert instance_id in instances
370-
instances["running_workflow_step_id"] = running_workflow_step_id
377+
instances[instance_id]["running_workflow_step_id"] = running_workflow_step_id
371378

372379
with open(_INSTANCE_PICKLE_FILE, "wb") as pickle_file:
373380
Pickler(pickle_file).dump(instances)

0 commit comments

Comments
 (0)