diff options
author | Avital Fine <79420960+AvitalFineRedis@users.noreply.github.com> | 2021-11-30 17:47:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-30 18:47:25 +0200 |
commit | 175a05f4de17918b74bde7f554182968b1f6aabb (patch) | |
tree | 6fe2b660c03c4e0342d1b0c6e124490baf14f7a0 /tests/test_graph_utils/test_node.py | |
parent | b94e230b17d08e6c89d134e933c706256b79bc4a (diff) | |
download | redis-py-175a05f4de17918b74bde7f554182968b1f6aabb.tar.gz |
Adding RedisGraph support (#1673)
Co-authored-by: Chayim I. Kirshen <c@kirshen.com>
Diffstat (limited to 'tests/test_graph_utils/test_node.py')
-rw-r--r-- | tests/test_graph_utils/test_node.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/test_graph_utils/test_node.py b/tests/test_graph_utils/test_node.py new file mode 100644 index 0000000..faf8ab6 --- /dev/null +++ b/tests/test_graph_utils/test_node.py @@ -0,0 +1,52 @@ +import pytest + +from redis.commands.graph import node + + +@pytest.fixture +def fixture(): + no_args = node.Node() + no_props = node.Node(node_id=1, alias="alias", label="l") + props_only = node.Node(properties={"a": "a", "b": 10}) + no_label = node.Node(node_id=1, alias="alias", properties={"a": "a"}) + multi_label = node.Node(node_id=1, alias="alias", label=["l", "ll"]) + return no_args, no_props, props_only, no_label, multi_label + + +@pytest.mark.redismod +def test_toString(fixture): + no_args, no_props, props_only, no_label, multi_label = fixture + assert no_args.toString() == "" + assert no_props.toString() == "" + assert props_only.toString() == '{a:"a",b:10}' + assert no_label.toString() == '{a:"a"}' + assert multi_label.toString() == "" + + +@pytest.mark.redismod +def test_stringify(fixture): + no_args, no_props, props_only, no_label, multi_label = fixture + assert str(no_args) == "()" + assert str(no_props) == "(alias:l)" + assert str(props_only) == '({a:"a",b:10})' + assert str(no_label) == '(alias{a:"a"})' + assert str(multi_label) == "(alias:l:ll)" + + +@pytest.mark.redismod +def test_comparision(fixture): + no_args, no_props, props_only, no_label, multi_label = fixture + + assert node.Node() == node.Node() + assert node.Node(node_id=1) == node.Node(node_id=1) + assert node.Node(node_id=1) != node.Node(node_id=2) + assert node.Node(node_id=1, alias="a") == node.Node(node_id=1, alias="b") + assert node.Node(node_id=1, alias="a") == node.Node(node_id=1, alias="a") + assert node.Node(node_id=1, label="a") == node.Node(node_id=1, label="a") + assert node.Node(node_id=1, label="a") != node.Node(node_id=1, label="b") + assert node.Node(node_id=1, alias="a", label="l") == node.Node( + node_id=1, alias="a", label="l" + ) + assert node.Node(alias="a", label="l") != node.Node(alias="a", label="l1") + assert node.Node(properties={"a": 10}) == node.Node(properties={"a": 10}) + assert node.Node() != node.Node(properties={"a": 10}) |