Skip to content

Commit 04e60a7

Browse files
author
Alan Christie
committed
test: Better tests (decoder and validator)
1 parent a2b1398 commit 04e60a7

File tree

3 files changed

+54
-20
lines changed

3 files changed

+54
-20
lines changed

tests/test_decoder_minimal.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ def test_validate_minimal():
2626
assert error is None
2727

2828

29+
def test_validate_minimal_get_step_names():
30+
# Arrange
31+
32+
# Act
33+
names = decoder.get_step_names(_MINIMAL_WORKFLOW)
34+
35+
# Assert
36+
assert names == ["step-1"]
37+
38+
2939
def test_validate_without_name():
3040
# Arrange
3141
workflow = _MINIMAL_WORKFLOW.copy()

tests/test_worflow_validator.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/test_workflow_validator.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import os
2+
from typing import Any
3+
4+
import pytest
5+
import yaml
6+
7+
pytestmark = pytest.mark.unit
8+
9+
from tests.test_decoder_minimal import _MINIMAL_WORKFLOW
10+
from workflow.workflow_validator import ValidationLevel, WorkflowValidator
11+
12+
13+
def test_validate_minimal_for_create():
14+
# Arrange
15+
16+
# Act
17+
error = WorkflowValidator.validate(
18+
level=ValidationLevel.CREATE,
19+
workflow_definition=_MINIMAL_WORKFLOW,
20+
)
21+
22+
# Assert
23+
assert error.error_num == 0
24+
assert error.error_msg is None
25+
26+
27+
def test_validate_example_smiles_to_file_for_create():
28+
# Arrange
29+
workflow_file: str = os.path.join(
30+
os.path.dirname(__file__), "workflow-definitions", "example-smiles-to-file.yaml"
31+
)
32+
with open(workflow_file, "r", encoding="utf8") as workflow_file:
33+
workflow: dict[str, Any] = yaml.load(workflow_file, Loader=yaml.FullLoader)
34+
assert workflow
35+
36+
# Act
37+
error = WorkflowValidator.validate(
38+
level=ValidationLevel.CREATE,
39+
workflow_definition=workflow,
40+
)
41+
42+
# Assert
43+
assert error.error_num == 0
44+
assert error.error_msg is None

0 commit comments

Comments
 (0)