Skip to content

Commit

Permalink
fixes: tests
Browse files Browse the repository at this point in the history
Closes HEXA-1037: fixes list of parameters"
  • Loading branch information
nazarfil committed Sep 29, 2024
1 parent e5e356c commit bfcfd5a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
1 change: 0 additions & 1 deletion openhexa/sdk/pipelines/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ def validate(self, value: typing.Any) -> typing.Any:

def to_dict(self) -> dict[str, typing.Any]:
"""Return a dictionary representation of the Parameter instance."""
print(f"Multiple : {self.required}, required: {self.required}")
return {
"code": self.code,
"type": self.type.spec_type,
Expand Down
2 changes: 2 additions & 0 deletions openhexa/sdk/pipelines/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def to_dict(self):
"name": self.name,
"parameters": [p.to_dict() for p in self.parameters],
"timeout": self.timeout,
"function": self.function.__name__ if self.function else None,
"tasks": [t.__dict__ for t in self.tasks],
}

def _get_available_tasks(self) -> list[Task]:
Expand Down
26 changes: 22 additions & 4 deletions tests/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def test_pipeline_no_parameters(self):
)
pipeline = get_pipeline(tmpdirname)
self.assertEqual(
pipeline.to_dict(), {"code": "test", "name": "Test pipeline", "parameters": [], "timeout": None}
pipeline.to_dict(), {"code": "test", "name": "Test pipeline", "function": None,
"tasks": [], "parameters": [], "timeout": None}
)

def test_pipeline_with_args(self):
Expand All @@ -58,7 +59,8 @@ def test_pipeline_with_args(self):
)
pipeline = get_pipeline(tmpdirname)
self.assertEqual(
pipeline.to_dict(), {"code": "test", "name": "Test pipeline", "parameters": [], "timeout": None}
pipeline.to_dict(), {"code": "test", "function": None,
"tasks": [], "name": "Test pipeline", "parameters": [], "timeout": None}
)

def test_pipeline_with_invalid_parameter_args(self):
Expand Down Expand Up @@ -123,6 +125,8 @@ def test_pipeline_with_int_param(self):
{
"code": "test",
"name": "Test pipeline",
"function": None,
"tasks": [],
"parameters": [
{
"choices": None,
Expand Down Expand Up @@ -162,6 +166,8 @@ def test_pipeline_with_multiple_param(self):
{
"code": "test",
"name": "Test pipeline",
"function": None,
"tasks": [],
"parameters": [
{
"choices": None,
Expand Down Expand Up @@ -243,6 +249,8 @@ def test_pipeline_with_choices(self):
{
"code": "test",
"name": "Test pipeline",
"function": None,
"tasks": [],
"parameters": [
{
"choices": ["a", "b"],
Expand Down Expand Up @@ -277,8 +285,14 @@ def test_pipeline_with_timeout(self):
pipeline = get_pipeline(tmpdirname)
self.assertEqual(
pipeline.to_dict(),
{"code": "test", "function": None, "name": "Test pipeline", "parameters": [], "timeout": 42,
"tasks": []}
{
"code": "test",
"name": "Test pipeline",
"parameters": [],
"timeout": 42,
"function": None,
"tasks": []
}
)

def test_pipeline_with_bool(self):
Expand All @@ -304,6 +318,8 @@ def test_pipeline_with_bool(self):
{
"code": "test",
"name": "Test pipeline",
"function": None,
"tasks": [],
"parameters": [
{
"choices": None,
Expand Down Expand Up @@ -344,6 +360,8 @@ def test_pipeline_with_multiple_parameters(self):
{
"code": "test",
"name": "Test pipeline",
"function": None,
"tasks" : [],
"parameters": [
{
"choices": None,
Expand Down

0 comments on commit bfcfd5a

Please sign in to comment.