funcnodes-basic 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- funcnodes_basic-0.2.2/MANIFEST.in +14 -0
- {funcnodes_basic-0.2.0 → funcnodes_basic-0.2.2}/PKG-INFO +10 -15
- funcnodes_basic-0.2.2/pyproject.toml +45 -0
- funcnodes_basic-0.2.2/setup.cfg +4 -0
- {funcnodes_basic-0.2.0 → funcnodes_basic-0.2.2/src}/funcnodes_basic/__init__.py +3 -1
- funcnodes_basic-0.2.2/src/funcnodes_basic/input.py +84 -0
- {funcnodes_basic-0.2.0 → funcnodes_basic-0.2.2/src}/funcnodes_basic/logic.py +18 -16
- funcnodes_basic-0.2.2/src/funcnodes_basic.egg-info/PKG-INFO +51 -0
- funcnodes_basic-0.2.2/src/funcnodes_basic.egg-info/SOURCES.txt +25 -0
- funcnodes_basic-0.2.2/src/funcnodes_basic.egg-info/dependency_links.txt +1 -0
- funcnodes_basic-0.2.2/src/funcnodes_basic.egg-info/entry_points.txt +3 -0
- funcnodes_basic-0.2.2/src/funcnodes_basic.egg-info/requires.txt +2 -0
- funcnodes_basic-0.2.2/src/funcnodes_basic.egg-info/top_level.txt +1 -0
- funcnodes_basic-0.2.2/tests/test_all_nodes_pytest.py +6 -0
- funcnodes_basic-0.2.2/tests/test_dict.py +101 -0
- funcnodes_basic-0.2.2/tests/test_import.py +8 -0
- funcnodes_basic-0.2.2/tests/test_inputs.py +123 -0
- funcnodes_basic-0.2.2/tests/test_lists.py +239 -0
- funcnodes_basic-0.2.2/tests/test_logic.py +102 -0
- funcnodes_basic-0.2.2/tests/test_math.py +681 -0
- funcnodes_basic-0.2.2/tests/test_strings.py +316 -0
- funcnodes_basic-0.2.0/pyproject.toml +0 -35
- {funcnodes_basic-0.2.0 → funcnodes_basic-0.2.2}/LICENSE +0 -0
- {funcnodes_basic-0.2.0 → funcnodes_basic-0.2.2}/README.md +0 -0
- {funcnodes_basic-0.2.0 → funcnodes_basic-0.2.2/src}/funcnodes_basic/dicts.py +0 -0
- {funcnodes_basic-0.2.0 → funcnodes_basic-0.2.2/src}/funcnodes_basic/lists.py +0 -0
- {funcnodes_basic-0.2.0 → funcnodes_basic-0.2.2/src}/funcnodes_basic/math_nodes.py +0 -0
- {funcnodes_basic-0.2.0 → funcnodes_basic-0.2.2/src}/funcnodes_basic/strings.py +0 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
graft src
|
2
|
+
graft tests
|
3
|
+
|
4
|
+
global-exclude __pycache__/*
|
5
|
+
prune __pycache__
|
6
|
+
prune */__pycache__
|
7
|
+
recursive-exclude */__pycache__ *
|
8
|
+
|
9
|
+
global-exclude .venv/*
|
10
|
+
global-exclude .venv/**/*
|
11
|
+
prune .venv
|
12
|
+
prune */.venv
|
13
|
+
recursive-exclude .venv *
|
14
|
+
recursive-exclude */.venv *
|
@@ -1,24 +1,20 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: funcnodes-basic
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.2
|
4
4
|
Summary: Basic functionalities for funcnodes
|
5
|
+
Author-email: Julian Kimmig <julian.kimmig@linkdlab.de>
|
5
6
|
License: AGPL-3.0
|
6
|
-
Author: Julian Kimmig
|
7
|
-
Author-email: julian.kimmig@gmx.net
|
8
|
-
Requires-Python: >=3.11
|
9
|
-
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
10
|
-
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
15
|
-
Requires-Dist: funcnodes
|
16
|
-
Requires-Dist: funcnodes-core (>=0.3.4)
|
17
|
-
Project-URL: download, https://pypi.org/project/funcnodes-basic/#files
|
18
7
|
Project-URL: homepage, https://github.com/Linkdlab/funcnodes_basic
|
19
8
|
Project-URL: source, https://github.com/Linkdlab/funcnodes_basic
|
20
9
|
Project-URL: tracker, https://github.com/Linkdlab/funcnodes_basic/issues
|
10
|
+
Project-URL: download, https://pypi.org/project/funcnodes-basic/#files
|
11
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
12
|
+
Requires-Python: >=3.11
|
21
13
|
Description-Content-Type: text/markdown
|
14
|
+
License-File: LICENSE
|
15
|
+
Requires-Dist: funcnodes-core>=0.3.9
|
16
|
+
Requires-Dist: funcnodes
|
17
|
+
Dynamic: license-file
|
22
18
|
|
23
19
|
# FuncNodes Basic
|
24
20
|
|
@@ -53,4 +49,3 @@ This project is licensed under the MIT License.
|
|
53
49
|
## Contact
|
54
50
|
|
55
51
|
For any questions or issues, please open an issue on the GitHub repository.
|
56
|
-
|
@@ -0,0 +1,45 @@
|
|
1
|
+
[project]
|
2
|
+
name = "funcnodes-basic"
|
3
|
+
version = "0.2.2"
|
4
|
+
description = "Basic functionalities for funcnodes"
|
5
|
+
readme = "README.md"
|
6
|
+
classifiers = [ "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",]
|
7
|
+
requires-python = ">=3.11"
|
8
|
+
dependencies = [
|
9
|
+
"funcnodes-core>=0.3.9",
|
10
|
+
"funcnodes",
|
11
|
+
]
|
12
|
+
authors = [{name = "Julian Kimmig", email = "julian.kimmig@linkdlab.de"}]
|
13
|
+
|
14
|
+
|
15
|
+
[dependency-groups]
|
16
|
+
dev = [
|
17
|
+
"funcnodes-module>=0.2.9",
|
18
|
+
"pre-commit>=4.1.0",
|
19
|
+
"pytest>=8.3.4",
|
20
|
+
"pytest-funcnodes>=0.1.0",
|
21
|
+
]
|
22
|
+
|
23
|
+
[build-system]
|
24
|
+
requires = [ "setuptools>=42",]
|
25
|
+
build-backend = "setuptools.build_meta"
|
26
|
+
|
27
|
+
[project.license]
|
28
|
+
text = "AGPL-3.0"
|
29
|
+
|
30
|
+
[project.urls]
|
31
|
+
homepage = "https://github.com/Linkdlab/funcnodes_basic"
|
32
|
+
source = "https://github.com/Linkdlab/funcnodes_basic"
|
33
|
+
tracker = "https://github.com/Linkdlab/funcnodes_basic/issues"
|
34
|
+
download = "https://pypi.org/project/funcnodes-basic/#files"
|
35
|
+
|
36
|
+
[project.entry-points."funcnodes.module"]
|
37
|
+
module = "funcnodes_basic"
|
38
|
+
shelf = "funcnodes_basic:NODE_SHELF"
|
39
|
+
|
40
|
+
[tool.setuptools.package-dir]
|
41
|
+
"" = "src"
|
42
|
+
|
43
|
+
|
44
|
+
[tool.setuptools.packages.find]
|
45
|
+
where = [ "src",]
|
@@ -4,13 +4,15 @@ from .math_nodes import NODE_SHELF as math_shelf
|
|
4
4
|
from .lists import NODE_SHELF as lists_shelf
|
5
5
|
from .strings import NODE_SHELF as strings_shelf
|
6
6
|
from .dicts import NODE_SHELF as dicts_shelf
|
7
|
+
from .input import NODE_SHELF as input_shelf
|
7
8
|
|
8
9
|
|
9
|
-
__version__ = "0.2.
|
10
|
+
__version__ = "0.2.2"
|
10
11
|
|
11
12
|
NODE_SHELF = Shelf(
|
12
13
|
nodes=[],
|
13
14
|
subshelves=[
|
15
|
+
input_shelf,
|
14
16
|
lists_shelf,
|
15
17
|
dicts_shelf,
|
16
18
|
strings_shelf,
|
@@ -0,0 +1,84 @@
|
|
1
|
+
from typing import Union
|
2
|
+
import funcnodes_core as fn
|
3
|
+
|
4
|
+
|
5
|
+
@fn.NodeDecorator(
|
6
|
+
node_id="input.any",
|
7
|
+
node_name="Input",
|
8
|
+
description="Any input",
|
9
|
+
outputs=[
|
10
|
+
{"name": "out"},
|
11
|
+
],
|
12
|
+
)
|
13
|
+
def any_input(input: Union[str, float, int, bool]) -> str:
|
14
|
+
return input
|
15
|
+
|
16
|
+
|
17
|
+
@fn.NodeDecorator(
|
18
|
+
node_id="input.str",
|
19
|
+
node_name="String Input",
|
20
|
+
description="Input a string",
|
21
|
+
outputs=[
|
22
|
+
{"name": "string"},
|
23
|
+
],
|
24
|
+
)
|
25
|
+
def str_input(input: str) -> str:
|
26
|
+
return str(input)
|
27
|
+
|
28
|
+
|
29
|
+
@fn.NodeDecorator(
|
30
|
+
node_id="input.int",
|
31
|
+
node_name="Integer Input",
|
32
|
+
description="Input an integer",
|
33
|
+
outputs=[
|
34
|
+
{"name": "integer"},
|
35
|
+
],
|
36
|
+
)
|
37
|
+
def int_input(input: int) -> int:
|
38
|
+
return int(input)
|
39
|
+
|
40
|
+
|
41
|
+
@fn.NodeDecorator(
|
42
|
+
node_id="input.float",
|
43
|
+
node_name="Float Input",
|
44
|
+
description="Input a float",
|
45
|
+
outputs=[
|
46
|
+
{"name": "float"},
|
47
|
+
],
|
48
|
+
)
|
49
|
+
def float_input(input: float) -> float:
|
50
|
+
return float(input)
|
51
|
+
|
52
|
+
|
53
|
+
@fn.NodeDecorator(
|
54
|
+
node_id="input.bool",
|
55
|
+
node_name="Boolean Input",
|
56
|
+
description="Input a boolean",
|
57
|
+
outputs=[
|
58
|
+
{"name": "boolean"},
|
59
|
+
],
|
60
|
+
)
|
61
|
+
def bool_input(input: bool) -> bool:
|
62
|
+
if isinstance(input, str):
|
63
|
+
if input.lower() in ("true", "1", "yes"):
|
64
|
+
input = True
|
65
|
+
elif input.lower() in ("false", "0", "no"):
|
66
|
+
input = False
|
67
|
+
elif isinstance(input, (int, float)):
|
68
|
+
input = bool(input)
|
69
|
+
else:
|
70
|
+
input = bool(input)
|
71
|
+
return bool(input)
|
72
|
+
|
73
|
+
|
74
|
+
NODE_SHELF = fn.Shelf(
|
75
|
+
nodes=[
|
76
|
+
any_input,
|
77
|
+
str_input,
|
78
|
+
int_input,
|
79
|
+
float_input,
|
80
|
+
bool_input,
|
81
|
+
],
|
82
|
+
name="Input",
|
83
|
+
description="Simple input nodes",
|
84
|
+
)
|
@@ -6,6 +6,7 @@ from funcnodes_core.io import NodeInput, NodeOutput, NoValue
|
|
6
6
|
import asyncio
|
7
7
|
|
8
8
|
import funcnodes_core as fn
|
9
|
+
import time
|
9
10
|
|
10
11
|
|
11
12
|
class IfNode(Node):
|
@@ -57,17 +58,18 @@ class WaitNode(Node):
|
|
57
58
|
output = NodeOutput(id="output", type=Any)
|
58
59
|
|
59
60
|
async def func(self, delay: float, input: Optional[Any] = NoValue) -> None:
|
60
|
-
|
61
|
-
|
62
|
-
remaining_seconds = delay - total_seconds
|
63
|
-
self.progress.unit = "s"
|
64
|
-
self.progress.reset(total=total_seconds)
|
65
|
-
self.progress.set_description("Waiting")
|
66
|
-
for _ in range(total_seconds):
|
67
|
-
await asyncio.sleep(1)
|
68
|
-
self.progress.update()
|
69
|
-
await asyncio.sleep(remaining_seconds)
|
61
|
+
start = time.time()
|
62
|
+
remaining_seconds = delay
|
70
63
|
|
64
|
+
if delay > 1:
|
65
|
+
with self.progress(desc="Waiting", unit="s", total=delay) as pbar:
|
66
|
+
while remaining_seconds > 0:
|
67
|
+
interval = min(remaining_seconds, 1)
|
68
|
+
await asyncio.sleep(interval)
|
69
|
+
now = time.time()
|
70
|
+
elapsed = now - start
|
71
|
+
remaining_seconds = max(0, delay - elapsed)
|
72
|
+
pbar.update(interval)
|
71
73
|
else:
|
72
74
|
await asyncio.sleep(delay)
|
73
75
|
self.outputs["output"].value = input
|
@@ -85,12 +87,13 @@ class ForNode(Node):
|
|
85
87
|
results = []
|
86
88
|
self.outputs["done"].value = NoValue
|
87
89
|
|
88
|
-
iplen =
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
iplen = None
|
91
|
+
try:
|
92
|
+
iplen = len(input)
|
93
|
+
except Exception:
|
94
|
+
pass
|
92
95
|
|
93
|
-
for i in input:
|
96
|
+
for i in self.progress(input, desc="Iterating", unit="it", total=iplen):
|
94
97
|
self.outputs["do"].set_value(i, does_trigger=False)
|
95
98
|
triggerstack = TriggerStack()
|
96
99
|
await self.outputs["do"].trigger(triggerstack)
|
@@ -98,7 +101,6 @@ class ForNode(Node):
|
|
98
101
|
if v is not NoValue:
|
99
102
|
results.append(v)
|
100
103
|
self.inputs["collector"].value = NoValue
|
101
|
-
self.progress.update()
|
102
104
|
self.outputs["done"].value = results
|
103
105
|
|
104
106
|
|
@@ -0,0 +1,51 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: funcnodes-basic
|
3
|
+
Version: 0.2.2
|
4
|
+
Summary: Basic functionalities for funcnodes
|
5
|
+
Author-email: Julian Kimmig <julian.kimmig@linkdlab.de>
|
6
|
+
License: AGPL-3.0
|
7
|
+
Project-URL: homepage, https://github.com/Linkdlab/funcnodes_basic
|
8
|
+
Project-URL: source, https://github.com/Linkdlab/funcnodes_basic
|
9
|
+
Project-URL: tracker, https://github.com/Linkdlab/funcnodes_basic/issues
|
10
|
+
Project-URL: download, https://pypi.org/project/funcnodes-basic/#files
|
11
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
|
12
|
+
Requires-Python: >=3.11
|
13
|
+
Description-Content-Type: text/markdown
|
14
|
+
License-File: LICENSE
|
15
|
+
Requires-Dist: funcnodes-core>=0.3.9
|
16
|
+
Requires-Dist: funcnodes
|
17
|
+
Dynamic: license-file
|
18
|
+
|
19
|
+
# FuncNodes Basic
|
20
|
+
|
21
|
+
## Overview
|
22
|
+
|
23
|
+
`funcnodes-basic` is a collection of essential nodes designed to handle fundamental operations in [Funcnodes](https://github.com/linkdlab/funcnodes), such as list manipulation, dictionary operations, logic control, mathematical functions, and string processing. It provides a foundation of commonly needed functionalities in computational graphs built with the FuncNodes framework. Each module within this package contains a set of nodes, grouped by their operation type, allowing seamless integration into broader systems.
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
Install the package with:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
pip install funcnodes-basic
|
31
|
+
```
|
32
|
+
|
33
|
+
## Getting Started
|
34
|
+
|
35
|
+
Please refere to the [Funcnodes](https://github.com/linkdlab/funcnodes) package
|
36
|
+
|
37
|
+
## Example Usage
|
38
|
+
|
39
|
+
You can integrate the provided nodes in your computational graphs, connecting inputs and outputs between nodes to build complex workflows that utilize dictionaries, lists, logic, math, and string operations.
|
40
|
+
|
41
|
+
## Contribution
|
42
|
+
|
43
|
+
Feel free to contribute to this project by submitting pull requests. You can help by adding new nodes, fixing bugs, or enhancing documentation.
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
This project is licensed under the MIT License.
|
48
|
+
|
49
|
+
## Contact
|
50
|
+
|
51
|
+
For any questions or issues, please open an issue on the GitHub repository.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
LICENSE
|
2
|
+
MANIFEST.in
|
3
|
+
README.md
|
4
|
+
pyproject.toml
|
5
|
+
src/funcnodes_basic/__init__.py
|
6
|
+
src/funcnodes_basic/dicts.py
|
7
|
+
src/funcnodes_basic/input.py
|
8
|
+
src/funcnodes_basic/lists.py
|
9
|
+
src/funcnodes_basic/logic.py
|
10
|
+
src/funcnodes_basic/math_nodes.py
|
11
|
+
src/funcnodes_basic/strings.py
|
12
|
+
src/funcnodes_basic.egg-info/PKG-INFO
|
13
|
+
src/funcnodes_basic.egg-info/SOURCES.txt
|
14
|
+
src/funcnodes_basic.egg-info/dependency_links.txt
|
15
|
+
src/funcnodes_basic.egg-info/entry_points.txt
|
16
|
+
src/funcnodes_basic.egg-info/requires.txt
|
17
|
+
src/funcnodes_basic.egg-info/top_level.txt
|
18
|
+
tests/test_all_nodes_pytest.py
|
19
|
+
tests/test_dict.py
|
20
|
+
tests/test_import.py
|
21
|
+
tests/test_inputs.py
|
22
|
+
tests/test_lists.py
|
23
|
+
tests/test_logic.py
|
24
|
+
tests/test_math.py
|
25
|
+
tests/test_strings.py
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
funcnodes_basic
|
@@ -0,0 +1,101 @@
|
|
1
|
+
from funcnodes_basic import dicts
|
2
|
+
import pytest_funcnodes
|
3
|
+
# DictGetNode,
|
4
|
+
# dict_keys,
|
5
|
+
# dict_values,
|
6
|
+
# dict_items,
|
7
|
+
# dict_from_items,
|
8
|
+
# dict_from_keys_values,
|
9
|
+
# dict_to_list,
|
10
|
+
|
11
|
+
|
12
|
+
@pytest_funcnodes.nodetest(dicts.DictGetNode)
|
13
|
+
async def test_dict_get():
|
14
|
+
testdict = {"a": 1, "b": 2, "c": 3}
|
15
|
+
|
16
|
+
node = dicts.DictGetNode()
|
17
|
+
|
18
|
+
node.inputs["dictionary"].value = testdict
|
19
|
+
await node
|
20
|
+
|
21
|
+
assert node.inputs["key"].value_options["options"] == {"a": "0", "b": "1", "c": "2"}
|
22
|
+
|
23
|
+
node.inputs["key"].value = "0"
|
24
|
+
await node
|
25
|
+
|
26
|
+
assert node.outputs["value"].value == 1
|
27
|
+
|
28
|
+
|
29
|
+
@pytest_funcnodes.nodetest(dicts.dict_keys)
|
30
|
+
async def test_dict_keys():
|
31
|
+
testdict = {"a": 1, "b": 2, "c": 3}
|
32
|
+
|
33
|
+
node = dicts.dict_keys()
|
34
|
+
|
35
|
+
node.inputs["dictionary"].value = testdict
|
36
|
+
await node
|
37
|
+
|
38
|
+
assert node.outputs["out"].value == ["a", "b", "c"]
|
39
|
+
|
40
|
+
|
41
|
+
@pytest_funcnodes.nodetest(dicts.dict_values)
|
42
|
+
async def test_dict_values():
|
43
|
+
testdict = {"a": 1, "b": 2, "c": 3}
|
44
|
+
|
45
|
+
node = dicts.dict_values()
|
46
|
+
|
47
|
+
node.inputs["dictionary"].value = testdict
|
48
|
+
await node
|
49
|
+
|
50
|
+
assert node.outputs["out"].value == [1, 2, 3]
|
51
|
+
|
52
|
+
|
53
|
+
@pytest_funcnodes.nodetest(dicts.dict_items)
|
54
|
+
async def test_dict_items():
|
55
|
+
testdict = {"a": 1, "b": 2, "c": 3}
|
56
|
+
|
57
|
+
node = dicts.dict_items()
|
58
|
+
|
59
|
+
node.inputs["dictionary"].value = testdict
|
60
|
+
await node
|
61
|
+
|
62
|
+
assert node.outputs["out"].value == [("a", 1), ("b", 2), ("c", 3)]
|
63
|
+
|
64
|
+
|
65
|
+
@pytest_funcnodes.nodetest(dicts.dict_from_items)
|
66
|
+
async def test_dict_from_items():
|
67
|
+
testitems = [("a", 1), ("b", 2), ("c", 3)]
|
68
|
+
|
69
|
+
node = dicts.dict_from_items()
|
70
|
+
|
71
|
+
node.inputs["items"].value = testitems
|
72
|
+
await node
|
73
|
+
|
74
|
+
assert node.outputs["out"].value == {"a": 1, "b": 2, "c": 3}
|
75
|
+
|
76
|
+
|
77
|
+
@pytest_funcnodes.nodetest(dicts.dict_from_keys_values)
|
78
|
+
async def test_dict_from_keys_values():
|
79
|
+
testkeys = ["a", "b", "c"]
|
80
|
+
testvalues = [1, 2, 3]
|
81
|
+
|
82
|
+
node = dicts.dict_from_keys_values()
|
83
|
+
|
84
|
+
node.inputs["keys"].value = testkeys
|
85
|
+
node.inputs["values"].value = testvalues
|
86
|
+
await node
|
87
|
+
|
88
|
+
assert node.outputs["out"].value == {"a": 1, "b": 2, "c": 3}
|
89
|
+
|
90
|
+
|
91
|
+
@pytest_funcnodes.nodetest(dicts.dict_to_list)
|
92
|
+
async def test_dict_to_list():
|
93
|
+
testdict = {"a": 1, "b": 2, "c": 3}
|
94
|
+
|
95
|
+
node = dicts.dict_to_list()
|
96
|
+
|
97
|
+
node.inputs["dictionary"].value = testdict
|
98
|
+
await node
|
99
|
+
|
100
|
+
assert node.outputs["keys"].value == ["a", "b", "c"]
|
101
|
+
assert node.outputs["values"].value == [1, 2, 3]
|
@@ -0,0 +1,123 @@
|
|
1
|
+
from funcnodes_basic import input
|
2
|
+
import pytest_funcnodes
|
3
|
+
import pytest
|
4
|
+
import funcnodes_core as fn
|
5
|
+
|
6
|
+
|
7
|
+
@pytest_funcnodes.nodetest(input.any_input)
|
8
|
+
async def test_any_input():
|
9
|
+
node = input.any_input()
|
10
|
+
|
11
|
+
node.inputs["input"].value = 1
|
12
|
+
await node
|
13
|
+
|
14
|
+
assert node.outputs["out"].value == 1
|
15
|
+
|
16
|
+
node.inputs["input"].value = "test"
|
17
|
+
await node
|
18
|
+
|
19
|
+
assert node.outputs["out"].value == "test"
|
20
|
+
|
21
|
+
node.inputs["input"].value = [1, 2, 3]
|
22
|
+
await node
|
23
|
+
|
24
|
+
assert node.outputs["out"].value == [1, 2, 3]
|
25
|
+
|
26
|
+
|
27
|
+
@pytest_funcnodes.nodetest(input.str_input)
|
28
|
+
async def test_str_input():
|
29
|
+
node = input.str_input()
|
30
|
+
|
31
|
+
node.inputs["input"].value = 1
|
32
|
+
await node
|
33
|
+
|
34
|
+
assert node.outputs["string"].value == "1"
|
35
|
+
|
36
|
+
node.inputs["input"].value = "test"
|
37
|
+
await node
|
38
|
+
|
39
|
+
assert node.outputs["string"].value == "test"
|
40
|
+
|
41
|
+
node.inputs["input"].value = [1, 2, 3]
|
42
|
+
await node
|
43
|
+
|
44
|
+
assert node.outputs["string"].value == "[1, 2, 3]"
|
45
|
+
|
46
|
+
|
47
|
+
@pytest_funcnodes.nodetest(input.int_input)
|
48
|
+
async def test_int_input():
|
49
|
+
node = input.int_input()
|
50
|
+
|
51
|
+
node.inputs["input"].value = 1
|
52
|
+
await node
|
53
|
+
node.inputs["input"].value = "test"
|
54
|
+
|
55
|
+
with pytest.raises(fn.NodeTriggerError):
|
56
|
+
await node
|
57
|
+
|
58
|
+
node.inputs["input"].value = [1, 2, 3]
|
59
|
+
|
60
|
+
with pytest.raises(fn.NodeTriggerError):
|
61
|
+
await node
|
62
|
+
|
63
|
+
node.inputs["input"].value = 1.5
|
64
|
+
await node
|
65
|
+
assert node.outputs["integer"].value == 1
|
66
|
+
|
67
|
+
|
68
|
+
@pytest_funcnodes.nodetest(input.float_input)
|
69
|
+
async def test_float_input():
|
70
|
+
node = input.float_input()
|
71
|
+
|
72
|
+
node.inputs["input"].value = 1
|
73
|
+
await node
|
74
|
+
|
75
|
+
assert node.outputs["float"].value == 1.0
|
76
|
+
|
77
|
+
node.inputs["input"].value = "test"
|
78
|
+
|
79
|
+
with pytest.raises(fn.NodeTriggerError):
|
80
|
+
await node
|
81
|
+
|
82
|
+
node.inputs["input"].value = [1, 2, 3]
|
83
|
+
|
84
|
+
with pytest.raises(fn.NodeTriggerError):
|
85
|
+
await node
|
86
|
+
|
87
|
+
node.inputs["input"].value = "1.5"
|
88
|
+
await node
|
89
|
+
assert node.outputs["float"].value == 1.5
|
90
|
+
|
91
|
+
|
92
|
+
@pytest_funcnodes.nodetest(input.bool_input)
|
93
|
+
async def test_bool_input():
|
94
|
+
node = input.bool_input()
|
95
|
+
|
96
|
+
node.inputs["input"].value = 1
|
97
|
+
await node
|
98
|
+
|
99
|
+
assert node.outputs["boolean"].value is True
|
100
|
+
|
101
|
+
node.inputs["input"].value = "test"
|
102
|
+
await node
|
103
|
+
assert node.outputs["boolean"].value is True
|
104
|
+
|
105
|
+
node.inputs["input"].value = ""
|
106
|
+
await node
|
107
|
+
assert node.outputs["boolean"].value is False
|
108
|
+
|
109
|
+
node.inputs["input"].value = [1, 2, 3]
|
110
|
+
await node
|
111
|
+
assert node.outputs["boolean"].value is True
|
112
|
+
|
113
|
+
node.inputs["input"].value = None
|
114
|
+
await node
|
115
|
+
assert node.outputs["boolean"].value is False
|
116
|
+
|
117
|
+
node.inputs["input"].value = "True"
|
118
|
+
await node
|
119
|
+
assert node.outputs["boolean"].value is True
|
120
|
+
|
121
|
+
node.inputs["input"].value = "False"
|
122
|
+
await node
|
123
|
+
assert node.outputs["boolean"].value is False
|