lionagi 0.2.2__py3-none-any.whl → 0.2.3__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,196 +1,198 @@
1
- import unittest
2
- from unittest.mock import MagicMock, patch
3
- from lionagi.core.tool.structure import *
4
-
5
-
6
- class TestBaseStructure(unittest.TestCase):
7
- def setUp(self):
8
- self.structure = BaseStructure()
9
- self.node1 = BaseNode(id_="node1")
10
- self.node2 = BaseNode(id_="node2")
11
- self.node3 = BaseNode(id_="node3")
12
- self.edge1 = Edge(id_="edge1", source_node_id="node1", target_node_id="node2")
13
- self.edge2 = Edge(id_="edge2", source_node_id="node2", target_node_id="node3")
14
-
15
- def test_node_edges_property(self):
16
- self.node1.in_relations = {"edge1": self.edge1}
17
- self.node1.out_relations = {"edge2": self.edge2}
18
- self.structure.structure_nodes = {"node1": self.node1}
19
- expected_result = {
20
- "node1": {"in": {"edge1": self.edge1}, "out": {"edge2": self.edge2}}
21
- }
22
- self.assertEqual(self.structure.node_edges, expected_result)
23
-
24
- def test_get_node_edges_with_node(self):
25
- self.node1.out_relations = {"edge1": self.edge1}
26
- self.node1.in_relations = {"edge2": self.edge2}
27
- self.structure.structure_nodes = {"node1": self.node1}
28
- self.assertEqual(
29
- self.structure.get_node_edges(self.node1, direction="out"), [self.edge1]
30
- )
31
- self.assertEqual(
32
- self.structure.get_node_edges(self.node1, direction="in"), [self.edge2]
33
- )
34
- self.assertEqual(
35
- self.structure.get_node_edges(self.node1, direction="all"),
36
- [self.edge2, self.edge1],
37
- )
38
-
39
- def test_get_node_edges_without_node(self):
40
- self.structure.structure_edges = {"edge1": self.edge1, "edge2": self.edge2}
41
- self.assertEqual(self.structure.get_node_edges(), [self.edge1, self.edge2])
42
-
43
- def test_get_node_edges_node_not_found(self):
44
- invalid_node = BaseNode(id_="invalid_node")
45
- try:
46
- self.structure.get_node_edges(invalid_node)
47
- except KeyError as e:
48
- self.assertEqual(str(e), f"node {invalid_node.id_} is not found")
49
-
50
- def test_has_structure_edge_with_edge_object(self):
51
- self.structure.structure_edges = {"edge1": self.edge1}
52
- self.assertTrue(self.structure.has_structure_edge(self.edge1))
53
-
54
- def test_has_structure_edge_with_edge_id(self):
55
- self.structure.structure_edges = {"edge1": self.edge1}
56
- self.assertTrue(self.structure.has_structure_edge("edge1"))
57
-
58
- def test_get_structure_edge_with_edge_object(self):
59
- self.structure.structure_edges = {"edge1": self.edge1}
60
- self.assertEqual(self.structure.get_structure_edge(self.edge1), self.edge1)
61
-
62
- def test_get_structure_edge_with_edge_id(self):
63
- self.structure.structure_edges = {"edge1": self.edge1}
64
- self.assertEqual(self.structure.get_structure_edge("edge1"), self.edge1)
65
-
66
- def test_add_structure_edge_success(self):
67
- self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
68
- self.structure.add_structure_edge(self.edge1)
69
- self.assertEqual(self.structure.structure_edges, {"edge1": self.edge1})
70
- self.assertEqual(self.node1.out_relations, {"node2": self.edge1})
71
- self.assertEqual(self.node2.in_relations, {"node1": self.edge1})
72
-
73
- def test_add_structure_edge_failure(self):
74
- with self.assertRaises(ValueError):
75
- self.structure.add_structure_edge(self.edge1)
76
-
77
- def test_remove_structure_edge_with_edge_object(self):
78
- self.structure.structure_edges = {"edge1": self.edge1}
79
- self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
80
- self.node1.out_relations = {"node2": self.edge1}
81
- self.node2.in_relations = {"node1": self.edge1}
82
- self.structure.remove_structure_edge(self.edge1)
83
- self.assertEqual(self.structure.structure_edges, {})
84
- self.assertEqual(self.node1.out_relations, {})
85
- self.assertEqual(self.node2.in_relations, {})
86
-
87
- def test_remove_structure_edge_with_edge_id(self):
88
- self.structure.structure_edges = {"edge1": self.edge1}
89
- self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
90
- self.node1.out_relations = {"node2": self.edge1}
91
- self.node2.in_relations = {"node1": self.edge1}
92
- self.structure.remove_structure_edge("edge1")
93
- self.assertEqual(self.structure.structure_edges, {})
94
- self.assertEqual(self.node1.out_relations, {})
95
- self.assertEqual(self.node2.in_relations, {})
96
-
97
- def test_remove_structure_node_success(self):
98
- self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
99
- self.structure.structure_edges = {"edge1": self.edge1}
100
- self.node1.out_relations = {"node2": self.edge1}
101
- self.node2.in_relations = {"node1": self.edge1}
102
- self.structure.remove_structure_node(self.node1)
103
- self.assertEqual(self.structure.structure_nodes, {"node2": self.node2})
104
- self.assertEqual(self.structure.structure_edges, {})
105
-
106
- def test_remove_structure_node_failure(self):
107
- with self.assertRaises(ValueError):
108
- self.structure.remove_structure_node(self.node1)
109
-
110
- def test_add_structure_node_with_base_node(self):
111
- self.structure.add_structure_node(self.node1)
112
- self.assertEqual(self.structure.structure_nodes, {"node1": self.node1})
113
-
114
- def test_add_structure_node_with_list(self):
115
- self.structure.add_structure_node([self.node1, self.node2])
116
- self.assertEqual(
117
- self.structure.structure_nodes, {"node1": self.node1, "node2": self.node2}
118
- )
119
-
120
- def test_add_structure_node_with_dict(self):
121
- self.structure.add_structure_node({"node1": self.node1, "node2": self.node2})
122
- self.assertEqual(
123
- self.structure.structure_nodes, {"node1": self.node1, "node2": self.node2}
124
- )
125
-
126
- def test_add_structure_node_unsupported_type(self):
127
- with self.assertRaises(NotImplementedError):
128
- self.structure.add_structure_node(1)
129
-
130
- def test_get_structure_node_with_node_id(self):
131
- self.structure.structure_nodes = {"node1": self.node1}
132
- self.assertEqual(self.structure.get_structure_node("node1"), self.node1)
133
-
134
- def test_get_structure_node_with_base_node(self):
135
- self.structure.structure_nodes = {"node1": self.node1}
136
- self.assertEqual(self.structure.get_structure_node(self.node1), self.node1)
137
-
138
- def test_get_structure_node_with_list(self):
139
- self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
140
- self.assertEqual(
141
- self.structure.get_structure_node(["node1", "node2"]),
142
- [self.node1, self.node2],
143
- )
144
-
145
- def test_pop_structure_node_with_node_id(self):
146
- self.structure.structure_nodes = {"node1": self.node1}
147
- self.assertEqual(self.structure.pop_structure_node("node1"), self.node1)
148
- self.assertEqual(self.structure.structure_nodes, {})
149
-
150
- def test_pop_structure_node_with_base_node(self):
151
- self.structure.structure_nodes = {"node1": self.node1}
152
- self.assertEqual(self.structure.pop_structure_node(self.node1), self.node1)
153
- self.assertEqual(self.structure.structure_nodes, {})
154
-
155
- def test_pop_structure_node_with_list(self):
156
- self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
157
- self.assertEqual(
158
- self.structure.pop_structure_node(["node1", "node2"]),
159
- [self.node1, self.node2],
160
- )
161
- self.assertEqual(self.structure.structure_nodes, {})
162
-
163
- def test_pop_structure_node_unsupported_type(self):
164
- with self.assertRaises(NotImplementedError):
165
- self.structure.pop_structure_node(1)
166
-
167
- def test_has_structure_node_with_node_id(self):
168
- self.structure.structure_nodes = {"node1": self.node1}
169
- self.assertTrue(self.structure.has_structure_node("node1"))
170
- self.assertFalse(self.structure.has_structure_node("node2"))
171
-
172
- def test_has_structure_node_with_base_node(self):
173
- self.structure.structure_nodes = {"node1": self.node1}
174
- self.assertTrue(self.structure.has_structure_node(self.node1))
175
- self.assertFalse(self.structure.has_structure_node(self.node2))
176
-
177
- def test_has_structure_node_with_list(self):
178
- self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
179
- self.assertTrue(self.structure.has_structure_node(["node1", "node2"]))
180
- self.assertFalse(self.structure.has_structure_node(["node1", "node3"]))
181
-
182
- def test_is_empty_property(self):
183
- self.assertTrue(self.structure.is_empty)
184
- self.structure.structure_nodes = {"node1": self.node1}
185
- self.assertFalse(self.structure.is_empty)
186
-
187
- def test_clear_method(self):
188
- self.structure.structure_nodes = {"node1": self.node1}
189
- self.structure.structure_edges = {"edge1": self.edge1}
190
- self.structure.clear()
191
- self.assertEqual(self.structure.structure_nodes, {})
192
- self.assertEqual(self.structure.structure_edges, {})
193
-
194
-
195
- if __name__ == "__main__":
196
- unittest.main()
1
+ #TODO
2
+
3
+ # import unittest
4
+ # from unittest.mock import MagicMock, patch
5
+ # from lionagi.core.tool.structure import *
6
+ #
7
+ #
8
+ # class TestBaseStructure(unittest.TestCase):
9
+ # def setUp(self):
10
+ # self.structure = BaseStructure()
11
+ # self.node1 = BaseNode(id_="node1")
12
+ # self.node2 = BaseNode(id_="node2")
13
+ # self.node3 = BaseNode(id_="node3")
14
+ # self.edge1 = Edge(id_="edge1", source_node_id="node1", target_node_id="node2")
15
+ # self.edge2 = Edge(id_="edge2", source_node_id="node2", target_node_id="node3")
16
+ #
17
+ # def test_node_edges_property(self):
18
+ # self.node1.in_relations = {"edge1": self.edge1}
19
+ # self.node1.out_relations = {"edge2": self.edge2}
20
+ # self.structure.structure_nodes = {"node1": self.node1}
21
+ # expected_result = {
22
+ # "node1": {"in": {"edge1": self.edge1}, "out": {"edge2": self.edge2}}
23
+ # }
24
+ # self.assertEqual(self.structure.node_edges, expected_result)
25
+ #
26
+ # def test_get_node_edges_with_node(self):
27
+ # self.node1.out_relations = {"edge1": self.edge1}
28
+ # self.node1.in_relations = {"edge2": self.edge2}
29
+ # self.structure.structure_nodes = {"node1": self.node1}
30
+ # self.assertEqual(
31
+ # self.structure.get_node_edges(self.node1, direction="out"), [self.edge1]
32
+ # )
33
+ # self.assertEqual(
34
+ # self.structure.get_node_edges(self.node1, direction="in"), [self.edge2]
35
+ # )
36
+ # self.assertEqual(
37
+ # self.structure.get_node_edges(self.node1, direction="all"),
38
+ # [self.edge2, self.edge1],
39
+ # )
40
+ #
41
+ # def test_get_node_edges_without_node(self):
42
+ # self.structure.structure_edges = {"edge1": self.edge1, "edge2": self.edge2}
43
+ # self.assertEqual(self.structure.get_node_edges(), [self.edge1, self.edge2])
44
+ #
45
+ # def test_get_node_edges_node_not_found(self):
46
+ # invalid_node = BaseNode(id_="invalid_node")
47
+ # try:
48
+ # self.structure.get_node_edges(invalid_node)
49
+ # except KeyError as e:
50
+ # self.assertEqual(str(e), f"node {invalid_node.id_} is not found")
51
+ #
52
+ # def test_has_structure_edge_with_edge_object(self):
53
+ # self.structure.structure_edges = {"edge1": self.edge1}
54
+ # self.assertTrue(self.structure.has_structure_edge(self.edge1))
55
+ #
56
+ # def test_has_structure_edge_with_edge_id(self):
57
+ # self.structure.structure_edges = {"edge1": self.edge1}
58
+ # self.assertTrue(self.structure.has_structure_edge("edge1"))
59
+ #
60
+ # def test_get_structure_edge_with_edge_object(self):
61
+ # self.structure.structure_edges = {"edge1": self.edge1}
62
+ # self.assertEqual(self.structure.get_structure_edge(self.edge1), self.edge1)
63
+ #
64
+ # def test_get_structure_edge_with_edge_id(self):
65
+ # self.structure.structure_edges = {"edge1": self.edge1}
66
+ # self.assertEqual(self.structure.get_structure_edge("edge1"), self.edge1)
67
+ #
68
+ # def test_add_structure_edge_success(self):
69
+ # self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
70
+ # self.structure.add_structure_edge(self.edge1)
71
+ # self.assertEqual(self.structure.structure_edges, {"edge1": self.edge1})
72
+ # self.assertEqual(self.node1.out_relations, {"node2": self.edge1})
73
+ # self.assertEqual(self.node2.in_relations, {"node1": self.edge1})
74
+ #
75
+ # def test_add_structure_edge_failure(self):
76
+ # with self.assertRaises(ValueError):
77
+ # self.structure.add_structure_edge(self.edge1)
78
+ #
79
+ # def test_remove_structure_edge_with_edge_object(self):
80
+ # self.structure.structure_edges = {"edge1": self.edge1}
81
+ # self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
82
+ # self.node1.out_relations = {"node2": self.edge1}
83
+ # self.node2.in_relations = {"node1": self.edge1}
84
+ # self.structure.remove_structure_edge(self.edge1)
85
+ # self.assertEqual(self.structure.structure_edges, {})
86
+ # self.assertEqual(self.node1.out_relations, {})
87
+ # self.assertEqual(self.node2.in_relations, {})
88
+ #
89
+ # def test_remove_structure_edge_with_edge_id(self):
90
+ # self.structure.structure_edges = {"edge1": self.edge1}
91
+ # self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
92
+ # self.node1.out_relations = {"node2": self.edge1}
93
+ # self.node2.in_relations = {"node1": self.edge1}
94
+ # self.structure.remove_structure_edge("edge1")
95
+ # self.assertEqual(self.structure.structure_edges, {})
96
+ # self.assertEqual(self.node1.out_relations, {})
97
+ # self.assertEqual(self.node2.in_relations, {})
98
+ #
99
+ # def test_remove_structure_node_success(self):
100
+ # self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
101
+ # self.structure.structure_edges = {"edge1": self.edge1}
102
+ # self.node1.out_relations = {"node2": self.edge1}
103
+ # self.node2.in_relations = {"node1": self.edge1}
104
+ # self.structure.remove_structure_node(self.node1)
105
+ # self.assertEqual(self.structure.structure_nodes, {"node2": self.node2})
106
+ # self.assertEqual(self.structure.structure_edges, {})
107
+ #
108
+ # def test_remove_structure_node_failure(self):
109
+ # with self.assertRaises(ValueError):
110
+ # self.structure.remove_structure_node(self.node1)
111
+ #
112
+ # def test_add_structure_node_with_base_node(self):
113
+ # self.structure.add_structure_node(self.node1)
114
+ # self.assertEqual(self.structure.structure_nodes, {"node1": self.node1})
115
+ #
116
+ # def test_add_structure_node_with_list(self):
117
+ # self.structure.add_structure_node([self.node1, self.node2])
118
+ # self.assertEqual(
119
+ # self.structure.structure_nodes, {"node1": self.node1, "node2": self.node2}
120
+ # )
121
+ #
122
+ # def test_add_structure_node_with_dict(self):
123
+ # self.structure.add_structure_node({"node1": self.node1, "node2": self.node2})
124
+ # self.assertEqual(
125
+ # self.structure.structure_nodes, {"node1": self.node1, "node2": self.node2}
126
+ # )
127
+ #
128
+ # def test_add_structure_node_unsupported_type(self):
129
+ # with self.assertRaises(NotImplementedError):
130
+ # self.structure.add_structure_node(1)
131
+ #
132
+ # def test_get_structure_node_with_node_id(self):
133
+ # self.structure.structure_nodes = {"node1": self.node1}
134
+ # self.assertEqual(self.structure.get_structure_node("node1"), self.node1)
135
+ #
136
+ # def test_get_structure_node_with_base_node(self):
137
+ # self.structure.structure_nodes = {"node1": self.node1}
138
+ # self.assertEqual(self.structure.get_structure_node(self.node1), self.node1)
139
+ #
140
+ # def test_get_structure_node_with_list(self):
141
+ # self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
142
+ # self.assertEqual(
143
+ # self.structure.get_structure_node(["node1", "node2"]),
144
+ # [self.node1, self.node2],
145
+ # )
146
+ #
147
+ # def test_pop_structure_node_with_node_id(self):
148
+ # self.structure.structure_nodes = {"node1": self.node1}
149
+ # self.assertEqual(self.structure.pop_structure_node("node1"), self.node1)
150
+ # self.assertEqual(self.structure.structure_nodes, {})
151
+ #
152
+ # def test_pop_structure_node_with_base_node(self):
153
+ # self.structure.structure_nodes = {"node1": self.node1}
154
+ # self.assertEqual(self.structure.pop_structure_node(self.node1), self.node1)
155
+ # self.assertEqual(self.structure.structure_nodes, {})
156
+ #
157
+ # def test_pop_structure_node_with_list(self):
158
+ # self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
159
+ # self.assertEqual(
160
+ # self.structure.pop_structure_node(["node1", "node2"]),
161
+ # [self.node1, self.node2],
162
+ # )
163
+ # self.assertEqual(self.structure.structure_nodes, {})
164
+ #
165
+ # def test_pop_structure_node_unsupported_type(self):
166
+ # with self.assertRaises(NotImplementedError):
167
+ # self.structure.pop_structure_node(1)
168
+ #
169
+ # def test_has_structure_node_with_node_id(self):
170
+ # self.structure.structure_nodes = {"node1": self.node1}
171
+ # self.assertTrue(self.structure.has_structure_node("node1"))
172
+ # self.assertFalse(self.structure.has_structure_node("node2"))
173
+ #
174
+ # def test_has_structure_node_with_base_node(self):
175
+ # self.structure.structure_nodes = {"node1": self.node1}
176
+ # self.assertTrue(self.structure.has_structure_node(self.node1))
177
+ # self.assertFalse(self.structure.has_structure_node(self.node2))
178
+ #
179
+ # def test_has_structure_node_with_list(self):
180
+ # self.structure.structure_nodes = {"node1": self.node1, "node2": self.node2}
181
+ # self.assertTrue(self.structure.has_structure_node(["node1", "node2"]))
182
+ # self.assertFalse(self.structure.has_structure_node(["node1", "node3"]))
183
+ #
184
+ # def test_is_empty_property(self):
185
+ # self.assertTrue(self.structure.is_empty)
186
+ # self.structure.structure_nodes = {"node1": self.node1}
187
+ # self.assertFalse(self.structure.is_empty)
188
+ #
189
+ # def test_clear_method(self):
190
+ # self.structure.structure_nodes = {"node1": self.node1}
191
+ # self.structure.structure_edges = {"edge1": self.edge1}
192
+ # self.structure.clear()
193
+ # self.assertEqual(self.structure.structure_nodes, {})
194
+ # self.assertEqual(self.structure.structure_edges, {})
195
+ #
196
+ #
197
+ # if __name__ == "__main__":
198
+ # unittest.main()
@@ -1,54 +1,55 @@
1
- import unittest
2
- from unittest.mock import MagicMock, patch
3
- from lionagi.core.generic import BaseNode, Edge
4
- from lionagi.new.schema.todo.graph import Graph
5
-
6
-
7
- class TestGraph(unittest.TestCase):
8
- def setUp(self):
9
- self.graph = Graph()
10
- self.node1 = BaseNode(id_="node1", content="Node 1")
11
- self.node2 = BaseNode(id_="node2", content="Node 2")
12
- self.edge1 = Edge(
13
- id_="edge1", source_node_id="node1", target_node_id="node2", label="Edge 1"
14
- )
15
- self.graph.structure_nodes = {"node1": self.node1, "node2": self.node2}
16
- self.graph.structure_edges = {"edge1": self.edge1}
17
-
18
- @patch("lionagi.libs.SysUtil.check_import")
19
- def test_to_networkx_success(self, mock_check_import):
20
- mock_check_import.return_value = None
21
- with patch("networkx.DiGraph") as mock_digraph:
22
- mock_graph = MagicMock()
23
- mock_digraph.return_value = mock_graph
24
-
25
- result = self.graph.to_networkx()
26
-
27
- self.assertEqual(result, mock_graph)
28
-
29
- @patch("lionagi.libs.SysUtil.check_import")
30
- def test_to_networkx_empty_graph(self, mock_check_import):
31
- mock_check_import.return_value = None
32
- with patch("networkx.DiGraph") as mock_digraph:
33
- mock_graph = MagicMock()
34
- mock_digraph.return_value = mock_graph
35
-
36
- self.graph.structure_nodes = {}
37
- self.graph.structure_edges = {}
38
- result = self.graph.to_networkx()
39
-
40
- self.assertEqual(result, mock_graph)
41
- mock_check_import.assert_called_once_with("networkx")
42
- mock_digraph.assert_called_once()
43
- mock_graph.add_node.assert_not_called()
44
- mock_graph.add_edge.assert_not_called()
45
-
46
- @patch("lionagi.libs.SysUtil.check_import", side_effect=ImportError)
47
- def test_to_networkx_import_error(self, mock_check_import):
48
- with self.assertRaises(ImportError):
49
- self.graph.to_networkx()
50
- mock_check_import.assert_called_once_with("networkx")
51
-
52
-
53
- if __name__ == "__main__":
54
- unittest.main()
1
+ #TODO
2
+ # import unittest
3
+ # from unittest.mock import MagicMock, patch
4
+ # from lionagi.core.generic import BaseNode, Edge
5
+ # from lionagi.new.schema.todo.graph import Graph
6
+ #
7
+ #
8
+ # class TestGraph(unittest.TestCase):
9
+ # def setUp(self):
10
+ # self.graph = Graph()
11
+ # self.node1 = BaseNode(id_="node1", content="Node 1")
12
+ # self.node2 = BaseNode(id_="node2", content="Node 2")
13
+ # self.edge1 = Edge(
14
+ # id_="edge1", source_node_id="node1", target_node_id="node2", label="Edge 1"
15
+ # )
16
+ # self.graph.structure_nodes = {"node1": self.node1, "node2": self.node2}
17
+ # self.graph.structure_edges = {"edge1": self.edge1}
18
+ #
19
+ # @patch("lionagi.libs.SysUtil.check_import")
20
+ # def test_to_networkx_success(self, mock_check_import):
21
+ # mock_check_import.return_value = None
22
+ # with patch("networkx.DiGraph") as mock_digraph:
23
+ # mock_graph = MagicMock()
24
+ # mock_digraph.return_value = mock_graph
25
+ #
26
+ # result = self.graph.to_networkx()
27
+ #
28
+ # self.assertEqual(result, mock_graph)
29
+ #
30
+ # @patch("lionagi.libs.SysUtil.check_import")
31
+ # def test_to_networkx_empty_graph(self, mock_check_import):
32
+ # mock_check_import.return_value = None
33
+ # with patch("networkx.DiGraph") as mock_digraph:
34
+ # mock_graph = MagicMock()
35
+ # mock_digraph.return_value = mock_graph
36
+ #
37
+ # self.graph.structure_nodes = {}
38
+ # self.graph.structure_edges = {}
39
+ # result = self.graph.to_networkx()
40
+ #
41
+ # self.assertEqual(result, mock_graph)
42
+ # mock_check_import.assert_called_once_with("networkx")
43
+ # mock_digraph.assert_called_once()
44
+ # mock_graph.add_node.assert_not_called()
45
+ # mock_graph.add_edge.assert_not_called()
46
+ #
47
+ # @patch("lionagi.libs.SysUtil.check_import", side_effect=ImportError)
48
+ # def test_to_networkx_import_error(self, mock_check_import):
49
+ # with self.assertRaises(ImportError):
50
+ # self.graph.to_networkx()
51
+ # mock_check_import.assert_called_once_with("networkx")
52
+ #
53
+ #
54
+ # if __name__ == "__main__":
55
+ # unittest.main()
@@ -1,48 +1,49 @@
1
- import unittest
2
- from lionagi.new.schema.todo.tree import Tree
3
- from lionagi.core.generic import TreeNode
4
-
5
-
6
- class TestTree(unittest.TestCase):
7
- def setUp(self):
8
- self.tree = Tree()
9
- self.node1 = TreeNode(id_="node1", content="Node 1")
10
- self.node2 = TreeNode(id_="node2", content="Node 2")
11
- self.node3 = TreeNode(id_="node3", content="Node 3")
12
- self.tree.add_structure_node(self.node1)
13
- self.tree.add_structure_node(self.node2)
14
- self.tree.add_structure_node(self.node3)
15
-
16
- def test_add_parent_to_child(self):
17
- self.tree.add_parent_to_child(self.node1, self.node2)
18
- self.assertEqual(self.node2, self.node1.parent)
19
- self.assertIn(self.node1, self.node2.children)
20
-
21
- def test_add_child_to_parent(self):
22
- self.tree.add_child_to_parent(self.node3, self.node2)
23
- self.assertEqual(self.node2, self.node3.parent)
24
- self.assertIn(self.node3, self.node2.children)
25
-
26
- def test_find_parent(self):
27
- self.tree.add_parent_to_child(self.node1, self.node2)
28
- parent = self.tree.find_parent(self.node1)
29
- self.assertEqual(self.node2, parent)
30
-
31
- def test_find_child(self):
32
- self.tree.add_parent_to_child(self.node1, self.node2)
33
- children = self.tree.find_child(self.node2)
34
- self.assertIn(self.node1, children)
35
-
36
- def test_parent_child_relationship(self):
37
- self.tree.add_parent_to_child(self.node1, self.node2)
38
- self.tree.add_child_to_parent(self.node3, self.node2)
39
- self.assertIn(self.node1, self.node2.children)
40
- self.assertIn(self.node3, self.node2.children)
41
- self.assertEqual(self.node2, self.node1.parent)
42
- self.assertEqual(self.node2, self.node3.parent)
43
-
44
- # Add more tests as necessary to cover edge cases and other functionalities
45
-
46
-
47
- if __name__ == "__main__":
48
- unittest.main()
1
+ #TODO
2
+ # import unittest
3
+ # from lionagi.new.schema.todo.tree import Tree
4
+ # from lionagi.core.generic import TreeNode
5
+ #
6
+ #
7
+ # class TestTree(unittest.TestCase):
8
+ # def setUp(self):
9
+ # self.tree = Tree()
10
+ # self.node1 = TreeNode(id_="node1", content="Node 1")
11
+ # self.node2 = TreeNode(id_="node2", content="Node 2")
12
+ # self.node3 = TreeNode(id_="node3", content="Node 3")
13
+ # self.tree.add_structure_node(self.node1)
14
+ # self.tree.add_structure_node(self.node2)
15
+ # self.tree.add_structure_node(self.node3)
16
+ #
17
+ # def test_add_parent_to_child(self):
18
+ # self.tree.add_parent_to_child(self.node1, self.node2)
19
+ # self.assertEqual(self.node2, self.node1.parent)
20
+ # self.assertIn(self.node1, self.node2.children)
21
+ #
22
+ # def test_add_child_to_parent(self):
23
+ # self.tree.add_child_to_parent(self.node3, self.node2)
24
+ # self.assertEqual(self.node2, self.node3.parent)
25
+ # self.assertIn(self.node3, self.node2.children)
26
+ #
27
+ # def test_find_parent(self):
28
+ # self.tree.add_parent_to_child(self.node1, self.node2)
29
+ # parent = self.tree.find_parent(self.node1)
30
+ # self.assertEqual(self.node2, parent)
31
+ #
32
+ # def test_find_child(self):
33
+ # self.tree.add_parent_to_child(self.node1, self.node2)
34
+ # children = self.tree.find_child(self.node2)
35
+ # self.assertIn(self.node1, children)
36
+ #
37
+ # def test_parent_child_relationship(self):
38
+ # self.tree.add_parent_to_child(self.node1, self.node2)
39
+ # self.tree.add_child_to_parent(self.node3, self.node2)
40
+ # self.assertIn(self.node1, self.node2.children)
41
+ # self.assertIn(self.node3, self.node2.children)
42
+ # self.assertEqual(self.node2, self.node1.parent)
43
+ # self.assertEqual(self.node2, self.node3.parent)
44
+ #
45
+ # # Add more tests as necessary to cover edge cases and other functionalities
46
+ #
47
+ #
48
+ # if __name__ == "__main__":
49
+ # unittest.main()
lionagi/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.2.2"
1
+ __version__ = "0.2.3"