Skip to content

Commit

Permalink
Format codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
mirohudec committed Feb 28, 2024
1 parent 45b55c5 commit 6e2b06a
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 52 deletions.
23 changes: 10 additions & 13 deletions frinx_conductor_workers/frinx_conductor_workers/cli_worker_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,16 @@
}

cli_node_already_installed = {
"errors": {
"error": [
{
"error-tag": "data-exists",
"error-info": {
"node-id": "xr6",
"topology-id": "protocol"
},
"error-message": "Node has already been installed using other protocols",
"error-type": "application"
}
]
}
"errors": {
"error": [
{
"error-tag": "data-exists",
"error-info": {"node-id": "xr6", "topology-id": "protocol"},
"error-message": "Node has already been installed using other protocols",
"error-type": "application",
}
]
}
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module contains helper functions and objects for logging."""

import io
import logging

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def execute_mount_netconf(task):
and task["inputData"]["between-attempts-timeout-millis"] is not None
and task["inputData"]["between-attempts-timeout-millis"] is not ""
):
mount_body["input"]["netconf"][
"netconf-node-topology:between-attempts-timeout-millis"
] = task["inputData"]["between-attempts-timeout-millis"]
mount_body["input"]["netconf"]["netconf-node-topology:between-attempts-timeout-millis"] = (
task["inputData"]["between-attempts-timeout-millis"]
)

if (
"connection-timeout-millis" in task["inputData"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,16 @@
}

netconf_node_already_installed = {
"errors": {
"error": [
{
"error-tag": "data-exists",
"error-info": {
"node-id": "xr6",
"topology-id": "protocol"
},
"error-message": "Node has already been installed using other protocols",
"error-type": "application"
}
]
}
"errors": {
"error": [
{
"error-tag": "data-exists",
"error-info": {"node-id": "xr6", "topology-id": "protocol"},
"error-message": "Node has already been installed using other protocols",
"error-type": "application",
}
]
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"node-result": [
{
"node-id": "xr5",
"configuration": "2019-09-13T08:37:28.331: configure terminal\n2019-09-13T08:37:28.536: interface GigabitEthernet0/0/0/1\nshutdown\nroot\n\n2019-09-13T08:37:28.536: commit\n2019-09-13T08:37:28.536: end\n"
"configuration": "2019-09-13T08:37:28.331: configure terminal\n2019-09-13T08:37:28.536: interface GigabitEthernet0/0/0/1\nshutdown\nroot\n\n2019-09-13T08:37:28.536: commit\n2019-09-13T08:37:28.536: end\n",
}
]
},
Expand All @@ -94,10 +94,10 @@
"data-actual": '{\n "frinx-openconfig-interfaces:config": {\n "type": "iana-if-type:ethernetCsmacd",\n "enabled": false,\n "name": "GigabitEthernet0/0/0/0"\n }\n}',
"data-intended": '{\n "frinx-openconfig-interfaces:config": {\n "type": "iana-if-type:ethernetCsmacd",\n "enabled": false,\n "name": "GigabitEthernet0/0/0/0dfhdfghd"\n }\n}',
}
]
],
}
]
},
}
}
}

Expand Down Expand Up @@ -432,9 +432,7 @@ def test_calculate_diff_with_non_existing_device(self):
class TestSyncFromNetwork(unittest.TestCase):
def test_sync_from_network_with_existing_devices(self):
with patch("frinx_conductor_workers.uniconfig_worker.requests.post") as mock:
mock.return_value = MockResponse(
bytes(json.dumps({}), encoding="utf-8"), 204, ""
)
mock.return_value = MockResponse(bytes(json.dumps({}), encoding="utf-8"), 204, "")
request = frinx_conductor_workers.uniconfig_worker.sync_from_network(
{"inputData": {"devices": "xr5, xr6"}}
)
Expand All @@ -455,9 +453,7 @@ def test_sync_from_network_with_non_existing_device(self):
class TestReplaceConfigWithOper(unittest.TestCase):
def test_replace_config_with_oper_with_existing_devices(self):
with patch("frinx_conductor_workers.uniconfig_worker.requests.post") as mock:
mock.return_value = MockResponse(
bytes(json.dumps({}), encoding="utf-8"), 204, ""
)
mock.return_value = MockResponse(bytes(json.dumps({}), encoding="utf-8"), 204, "")
request = frinx_conductor_workers.uniconfig_worker.replace_config_with_oper(
{"inputData": {"devices": "xr5, xr6"}}
)
Expand Down
9 changes: 3 additions & 6 deletions frinx_python_sdk/src/frinx/common/worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ class WorkerImpl(ABC):
task_def: TaskDefinition = None
task_def_template: type[BaseTaskdef] | type[DefaultTaskDefinition] = None

class WorkerDefinition(TaskDefinition):
...
class WorkerDefinition(TaskDefinition): ...

class WorkerInput(TaskInput):
...
class WorkerInput(TaskInput): ...

class WorkerOutput(TaskOutput):
...
class WorkerOutput(TaskOutput): ...

def __init__(
self, task_def_template: type[BaseTaskdef] | type[DefaultTaskDefinition] = None
Expand Down
7 changes: 6 additions & 1 deletion frinx_python_sdk/src/frinx/common/workflow/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,12 @@ class DynamicForkTask(WorkflowTaskImpl):
type = TaskType.FORK_JOIN_DYNAMIC
dynamic_fork_tasks_param: str = Field(default="dynamicTasks")
dynamic_fork_tasks_input_param_name: str = Field(default="dynamicTasksInput")
input_parameters: DynamicForkArraysTaskInputParameters | DynamicForkTaskInputParameters | DynamicForkArraysTaskFromDefInputParameters | DynamicForkTaskFromDefInputParameters
input_parameters: (
DynamicForkArraysTaskInputParameters
| DynamicForkTaskInputParameters
| DynamicForkArraysTaskFromDefInputParameters
| DynamicForkTaskFromDefInputParameters
)


class ForkTask(WorkflowTaskImpl):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,11 @@ def add_device(
labelIds=label_ids if type(label_ids) is not None else None,
vendor=vendor if type(vendor) is not None and len(vendor) > 0 else None,
model=model if type(model) is not None and len(model) > 0 else None,
deviceSize=str(device_size)
if type(device_size) is not None and len(device_size) > 0
else None,
deviceSize=(
str(device_size)
if type(device_size) is not None and len(device_size) > 0
else None
),
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ class WorkerDefinition(TaskDefinition):
timeout_seconds = 3600
response_timeout_seconds = 3600

class WorkerInput(TaskInput):
...
class WorkerInput(TaskInput): ...

class WorkerOutput(TaskOutput):
url: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ class WorkerDefinition(TaskDefinition):
class WorkerInput(TaskInput):
uniconfig_contexts: str

class WorkerOutput(TaskOutput):
...
class WorkerOutput(TaskOutput): ...

def execute(self, task: Task) -> TaskResult:
response = uniconfig.rollback_all_tx(**task.input_data)
Expand Down

0 comments on commit 6e2b06a

Please sign in to comment.