lionagi 0.2.2__py3-none-any.whl → 0.2.4__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- lionagi/core/engine/branch_engine.py +4 -4
- lionagi/integrations/provider/litellm.py +7 -5
- lionagi/tests/api/__init__.py +0 -0
- lionagi/tests/api/aws/__init__.py +0 -0
- lionagi/tests/api/aws/conftest.py +28 -0
- lionagi/tests/api/aws/test_aws_s3.py +7 -0
- lionagi/tests/test_core/generic/test_structure.py +194 -193
- lionagi/tests/test_core/graph/test_graph.py +71 -70
- lionagi/tests/test_core/graph/test_tree.py +76 -75
- lionagi/tests/test_core/mail/test_mail.py +98 -62
- lionagi/tests/test_core/test_structure/test_base_structure.py +198 -196
- lionagi/tests/test_core/test_structure/test_graph.py +55 -54
- lionagi/tests/test_core/test_structure/test_tree.py +49 -48
- lionagi/version.py +1 -1
- {lionagi-0.2.2.dist-info → lionagi-0.2.4.dist-info}/METADATA +7 -3
- {lionagi-0.2.2.dist-info → lionagi-0.2.4.dist-info}/RECORD +19 -15
- {lionagi-0.2.2.dist-info → lionagi-0.2.4.dist-info}/WHEEL +1 -1
- {lionagi-0.2.2.dist-info → lionagi-0.2.4.dist-info}/LICENSE +0 -0
- {lionagi-0.2.2.dist-info → lionagi-0.2.4.dist-info}/top_level.txt +0 -0
@@ -44,7 +44,7 @@ class BranchExecutor(Branch, BaseExecutor):
|
|
44
44
|
it processes starts, nodes, node lists, conditions, or ends, accordingly executing different functions.
|
45
45
|
"""
|
46
46
|
for key in list(self.mailbox.pending_ins.keys()):
|
47
|
-
while self.mailbox.pending_ins
|
47
|
+
while self.mailbox.pending_ins.get(key, Pile()).size() > 0:
|
48
48
|
mail_id = self.mailbox.pending_ins[key].popleft()
|
49
49
|
mail = self.mailbox.pile.pop(mail_id)
|
50
50
|
if mail.category == "start":
|
@@ -57,7 +57,7 @@ class BranchExecutor(Branch, BaseExecutor):
|
|
57
57
|
await self._process_condition(mail)
|
58
58
|
elif mail.category == "end":
|
59
59
|
self._process_end(mail)
|
60
|
-
if self.mailbox.pending_ins
|
60
|
+
if key in self.mailbox.pending_ins and self.mailbox.pending_ins.get(key, Pile()).size() == 0:
|
61
61
|
self.mailbox.pending_ins.pop(key)
|
62
62
|
|
63
63
|
async def execute(self, refresh_time=1) -> None:
|
@@ -118,8 +118,8 @@ class BranchExecutor(Branch, BaseExecutor):
|
|
118
118
|
package=node.ln_id,
|
119
119
|
request_source=self.ln_id,
|
120
120
|
)
|
121
|
-
except:
|
122
|
-
raise ValueError(f"Invalid mail to process. Mail:{mail}")
|
121
|
+
except Exception as e:
|
122
|
+
raise ValueError(f"Invalid mail to process. Mail:{mail}, Error: {e}")
|
123
123
|
|
124
124
|
def _process_node_list(self, mail: Mail):
|
125
125
|
"""
|
@@ -26,9 +26,10 @@ class LiteLLMService(BaseService):
|
|
26
26
|
|
27
27
|
SysUtil.check_import("litellm")
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
import litellm
|
30
|
+
litellm.drop_params = True
|
31
|
+
|
32
|
+
self.acompletion = litellm.acompletion
|
32
33
|
self.model = model
|
33
34
|
self.kwargs = kwargs
|
34
35
|
self.allowed_kwargs = allowed_kwargs
|
@@ -41,12 +42,13 @@ class LiteLLMService(BaseService):
|
|
41
42
|
config[k] = v
|
42
43
|
|
43
44
|
kwargs = {**self.kwargs, **config}
|
45
|
+
kwargs["model"] = self.model or kwargs.get("model")
|
44
46
|
|
45
47
|
try:
|
46
48
|
completion = await self.acompletion(
|
47
|
-
|
49
|
+
messages=messages, **kwargs
|
48
50
|
)
|
49
|
-
return payload, completion
|
51
|
+
return payload, completion.model_dump()
|
50
52
|
except Exception as e:
|
51
53
|
self.status_tracker.num_tasks_failed += 1
|
52
54
|
raise e
|
File without changes
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import pytest
|
2
|
+
from api.apicore import _connect as _connect_
|
3
|
+
from api.apicore import _config as _config_
|
4
|
+
|
5
|
+
|
6
|
+
"""
|
7
|
+
Setup the testing construct to ease future testing cases
|
8
|
+
"""
|
9
|
+
|
10
|
+
|
11
|
+
@pytest.fixture()
|
12
|
+
def config():
|
13
|
+
_config = _config_.ConfigSingleton()
|
14
|
+
_config.config["MOCK"] = True # turn on mock mode
|
15
|
+
yield _config
|
16
|
+
|
17
|
+
|
18
|
+
@pytest.fixture
|
19
|
+
def test_s3_conn(config):
|
20
|
+
yield _connect_.get_object("AWSS3")
|
21
|
+
|
22
|
+
|
23
|
+
@pytest.fixture
|
24
|
+
def test_ec2_conn(config):
|
25
|
+
yield _connect_.get_object("AWSEC2")
|
26
|
+
|
27
|
+
|
28
|
+
|
@@ -1,193 +1,194 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
1
|
+
#TODO
|
2
|
+
# import unittest
|
3
|
+
# from lionagi.core.generic.structure import *
|
4
|
+
#
|
5
|
+
# class TestCondition(Condition):
|
6
|
+
# def check(self, node: Node) -> bool:
|
7
|
+
# return True
|
8
|
+
#
|
9
|
+
# class TestBaseStructure(unittest.TestCase):
|
10
|
+
# def setUp(self):
|
11
|
+
# self.structure = BaseStructure(id_="test_structure")
|
12
|
+
# self.node1 = Node(id_="node1", content="Node 1 content")
|
13
|
+
# self.node2 = Node(id_="node2", content="Node 2 content")
|
14
|
+
# self.node3 = Node(id_="node3", content="Node 3 content")
|
15
|
+
#
|
16
|
+
# def test_internal_edges(self):
|
17
|
+
# self.structure.add_node([self.node1, self.node2])
|
18
|
+
# self.structure.relate_nodes(self.node1, self.node2)
|
19
|
+
# self.assertEqual(len(self.structure.internal_edges), 1)
|
20
|
+
#
|
21
|
+
# def test_is_empty(self):
|
22
|
+
# self.assertTrue(self.structure.is_empty)
|
23
|
+
# self.structure.add_node(self.node1)
|
24
|
+
# self.assertFalse(self.structure.is_empty)
|
25
|
+
#
|
26
|
+
# def test_add_node_single(self):
|
27
|
+
# self.structure.add_node(self.node1)
|
28
|
+
# self.assertIn(self.node1.id_, self.structure.internal_nodes)
|
29
|
+
#
|
30
|
+
# def test_add_node_list(self):
|
31
|
+
# self.structure.add_node([self.node1, self.node2])
|
32
|
+
# self.assertIn(self.node1.id_, self.structure.internal_nodes)
|
33
|
+
# self.assertIn(self.node2.id_, self.structure.internal_nodes)
|
34
|
+
#
|
35
|
+
# def test_add_node_dict(self):
|
36
|
+
# self.structure.add_node({self.node1.id_: self.node1, self.node2.id_: self.node2})
|
37
|
+
# self.assertIn(self.node1.id_, self.structure.internal_nodes)
|
38
|
+
# self.assertIn(self.node2.id_, self.structure.internal_nodes)
|
39
|
+
#
|
40
|
+
# def test_add_node_duplicate(self):
|
41
|
+
# self.structure.add_node(self.node1)
|
42
|
+
# with self.assertRaises(ValueError):
|
43
|
+
# self.structure.add_node(self.node1)
|
44
|
+
#
|
45
|
+
# def test_get_node_str(self):
|
46
|
+
# self.structure.add_node(self.node1)
|
47
|
+
# self.assertEqual(self.structure.get_node(self.node1.id_), self.node1)
|
48
|
+
#
|
49
|
+
# def test_get_node_node(self):
|
50
|
+
# self.structure.add_node(self.node1)
|
51
|
+
# self.assertEqual(self.structure.get_node(self.node1), self.node1)
|
52
|
+
#
|
53
|
+
# def test_get_node_list(self):
|
54
|
+
# self.structure.add_node([self.node1, self.node2])
|
55
|
+
# self.assertEqual(self.structure.get_node([self.node1.id_, self.node2.id_]), [self.node1, self.node2])
|
56
|
+
#
|
57
|
+
# def test_get_node_dict(self):
|
58
|
+
# self.structure.add_node([self.node1, self.node2])
|
59
|
+
# self.assertEqual(self.structure.get_node({self.node1.id_: self.node1, self.node2.id_: self.node2}), [self.node1, self.node2])
|
60
|
+
#
|
61
|
+
# def test_get_node_not_found(self):
|
62
|
+
# with self.assertRaises(KeyError):
|
63
|
+
# self.structure.get_node("nonexistent_node")
|
64
|
+
#
|
65
|
+
# def test_get_node_default(self):
|
66
|
+
# self.assertIsNone(self.structure.get_node("nonexistent_node", default=None))
|
67
|
+
#
|
68
|
+
# def test_remove_node_node(self):
|
69
|
+
# self.structure.add_node(self.node1)
|
70
|
+
# self.structure.remove_node(self.node1)
|
71
|
+
# self.assertNotIn(self.node1.id_, self.structure.internal_nodes)
|
72
|
+
#
|
73
|
+
# def test_remove_node_str(self):
|
74
|
+
# self.structure.add_node(self.node1)
|
75
|
+
# self.structure.remove_node(self.node1.id_)
|
76
|
+
# self.assertNotIn(self.node1.id_, self.structure.internal_nodes)
|
77
|
+
#
|
78
|
+
# def test_remove_node_list(self):
|
79
|
+
# self.structure.add_node([self.node1, self.node2])
|
80
|
+
# self.structure.remove_node([self.node1, self.node2])
|
81
|
+
# self.assertNotIn(self.node1.id_, self.structure.internal_nodes)
|
82
|
+
# self.assertNotIn(self.node2.id_, self.structure.internal_nodes)
|
83
|
+
#
|
84
|
+
# def test_remove_node_dict(self):
|
85
|
+
# self.structure.add_node([self.node1, self.node2])
|
86
|
+
# self.structure.remove_node({self.node1.id_: self.node1, self.node2.id_: self.node2})
|
87
|
+
# self.assertNotIn(self.node1.id_, self.structure.internal_nodes)
|
88
|
+
# self.assertNotIn(self.node2.id_, self.structure.internal_nodes)
|
89
|
+
#
|
90
|
+
# def test_pop_node_node(self):
|
91
|
+
# self.structure.add_node(self.node1)
|
92
|
+
# popped_node = self.structure.pop_node(self.node1)
|
93
|
+
# self.assertEqual(popped_node, self.node1)
|
94
|
+
# self.assertNotIn(self.node1.id_, self.structure.internal_nodes)
|
95
|
+
#
|
96
|
+
# def test_pop_node_str(self):
|
97
|
+
# self.structure.add_node(self.node1)
|
98
|
+
# popped_node = self.structure.pop_node(self.node1.id_)
|
99
|
+
# self.assertEqual(popped_node, self.node1)
|
100
|
+
# self.assertNotIn(self.node1.id_, self.structure.internal_nodes)
|
101
|
+
#
|
102
|
+
# def test_pop_node_list(self):
|
103
|
+
# self.structure.add_node([self.node1, self.node2])
|
104
|
+
# popped_nodes = self.structure.pop_node([self.node1, self.node2])
|
105
|
+
# self.assertEqual(popped_nodes, [self.node1, self.node2])
|
106
|
+
# self.assertNotIn(self.node1.id_, self.structure.internal_nodes)
|
107
|
+
# self.assertNotIn(self.node2.id_, self.structure.internal_nodes)
|
108
|
+
#
|
109
|
+
# def test_pop_node_dict(self):
|
110
|
+
# self.structure.add_node([self.node1, self.node2])
|
111
|
+
# popped_nodes = self.structure.pop_node({self.node1.id_: self.node1, self.node2.id_: self.node2})
|
112
|
+
# self.assertEqual(popped_nodes, [self.node1, self.node2])
|
113
|
+
# self.assertNotIn(self.node1.id_, self.structure.internal_nodes)
|
114
|
+
# self.assertNotIn(self.node2.id_, self.structure.internal_nodes)
|
115
|
+
#
|
116
|
+
# def test_pop_node_default(self):
|
117
|
+
# self.assertIsNone(self.structure.pop_node("nonexistent_node", default=None))
|
118
|
+
#
|
119
|
+
# def test_remove_edge_edge(self):
|
120
|
+
# self.structure.add_node([self.node1, self.node2])
|
121
|
+
# self.structure.relate_nodes(self.node1, self.node2)
|
122
|
+
# edge = list(self.node1.edges.values())[0]
|
123
|
+
# self.structure.remove_edge(edge)
|
124
|
+
# self.assertNotIn(edge.id_, self.structure.internal_edges)
|
125
|
+
#
|
126
|
+
# def test_remove_edge_str(self):
|
127
|
+
# self.structure.add_node([self.node1, self.node2])
|
128
|
+
# self.structure.relate_nodes(self.node1, self.node2)
|
129
|
+
# edge = list(self.node1.edges.values())[0]
|
130
|
+
# self.structure.remove_edge(edge.id_)
|
131
|
+
# self.assertNotIn(edge.id_, self.structure.internal_edges)
|
132
|
+
#
|
133
|
+
# def test_remove_edge_list(self):
|
134
|
+
# self.structure.add_node([self.node1, self.node2, self.node3])
|
135
|
+
# self.structure.relate_nodes(self.node1, self.node2)
|
136
|
+
# self.structure.relate_nodes(self.node2, self.node3)
|
137
|
+
# edges = list(self.node2.edges.values())
|
138
|
+
#
|
139
|
+
# self.structure.remove_edge(edges)
|
140
|
+
# self.assertNotIn(edges[0].id_, self.structure.internal_edges)
|
141
|
+
# self.assertNotIn(edges[1].id_, self.structure.internal_edges)
|
142
|
+
#
|
143
|
+
# def test_remove_edge_dict(self):
|
144
|
+
# self.structure.add_node([self.node1, self.node2, self.node3])
|
145
|
+
# self.structure.relate_nodes(self.node1, self.node2)
|
146
|
+
# self.structure.relate_nodes(self.node2, self.node3)
|
147
|
+
#
|
148
|
+
# edge_dict = self.node2.edges
|
149
|
+
# edge_list = list(edge_dict.values())
|
150
|
+
#
|
151
|
+
# self.structure.remove_edge(edge_dict)
|
152
|
+
# self.assertNotIn(edge_list[0].id_, self.structure.internal_edges)
|
153
|
+
# self.assertNotIn(edge_list[1].id_, self.structure.internal_edges)
|
154
|
+
#
|
155
|
+
# def test_remove_edge_not_found(self):
|
156
|
+
# with self.assertRaises(ValueError):
|
157
|
+
# self.structure.remove_edge("nonexistent_edge")
|
158
|
+
#
|
159
|
+
# def test_clear(self):
|
160
|
+
# self.structure.add_node([self.node1, self.node2])
|
161
|
+
# self.structure.clear()
|
162
|
+
# self.assertTrue(self.structure.is_empty)
|
163
|
+
#
|
164
|
+
# def test_get_node_edges_head(self):
|
165
|
+
# self.structure.add_node([self.node1, self.node2])
|
166
|
+
# self.structure.relate_nodes(self.node1, self.node2)
|
167
|
+
# edges = self.structure.get_node_edges(self.node1, node_as="head")
|
168
|
+
# self.assertEqual(len(edges), 1)
|
169
|
+
#
|
170
|
+
# def test_get_node_edges_tail(self):
|
171
|
+
# self.structure.add_node([self.node1, self.node2])
|
172
|
+
# self.structure.relate_nodes(self.node1, self.node2)
|
173
|
+
# edges = self.structure.get_node_edges(self.node2, node_as="tail")
|
174
|
+
# self.assertEqual(len(edges), 1)
|
175
|
+
#
|
176
|
+
# def test_get_node_edges_label(self):
|
177
|
+
# self.structure.add_node([self.node1, self.node2])
|
178
|
+
# self.structure.relate_nodes(self.node1, self.node2, label="test_label")
|
179
|
+
# edges = self.structure.get_node_edges(self.node1, node_as="head", label="test_label")
|
180
|
+
# self.assertEqual(len(edges), 1)
|
181
|
+
#
|
182
|
+
# def test_add_edge(self):
|
183
|
+
# self.structure.relate_nodes(self.node1, self.node2)
|
184
|
+
# self.assertIn(self.node1.id_, self.structure.internal_nodes)
|
185
|
+
# self.assertIn(self.node2.id_, self.structure.internal_nodes)
|
186
|
+
# self.assertEqual(len(self.structure.internal_edges), 1)
|
187
|
+
#
|
188
|
+
# def test_add_edge_with_label(self):
|
189
|
+
# self.structure.relate_nodes(self.node1, self.node2, label="test_label")
|
190
|
+
# edge = list(self.structure.internal_edges.values())[0]
|
191
|
+
# self.assertEqual(edge.label, "test_label")
|
192
|
+
#
|
193
|
+
# if __name__ == "__main__":
|
194
|
+
# unittest.main()
|
@@ -1,70 +1,71 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
from
|
4
|
-
from lionagi.core.
|
5
|
-
from lionagi.core.generic.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
1
|
+
#TODO
|
2
|
+
# import unittest
|
3
|
+
# from unittest.mock import MagicMock, patch
|
4
|
+
# from lionagi.core.graph.graph import Graph
|
5
|
+
# from lionagi.core.generic.node import Node
|
6
|
+
# from lionagi.core.generic.edge import Edge
|
7
|
+
#
|
8
|
+
# class TestGraph(unittest.TestCase):
|
9
|
+
#
|
10
|
+
# def setUp(self):
|
11
|
+
# self.graph = Graph()
|
12
|
+
# self.node1 = Node(id_="node1", content="Node 1 content")
|
13
|
+
# self.node2 = Node(id_="node2", content="Node 2 content")
|
14
|
+
# self.node3 = Node(id_="node3", content="Node 3 content")
|
15
|
+
# self.graph.add_node(self.node1)
|
16
|
+
# self.graph.add_node(self.node2)
|
17
|
+
# self.graph.add_node(self.node3)
|
18
|
+
#
|
19
|
+
# def test_graph_heads(self):
|
20
|
+
# self.graph.relate_nodes(self.node1, self.node2)
|
21
|
+
# self.assertEqual(["node1"], self.graph.graph_heads)
|
22
|
+
#
|
23
|
+
#
|
24
|
+
# def test_acyclic(self):
|
25
|
+
# self.graph.relate_nodes(self.node1, self.node2)
|
26
|
+
# self.assertTrue(self.graph.acyclic)
|
27
|
+
#
|
28
|
+
# self.graph.relate_nodes(self.node2, self.node1) # Creating a cycle
|
29
|
+
# self.assertFalse(self.graph.acyclic)
|
30
|
+
#
|
31
|
+
# @patch("lionagi.libs.SysUtil.check_import")
|
32
|
+
# def test_to_networkx_success(self, mock_check_import):
|
33
|
+
# mock_check_import.return_value = None
|
34
|
+
# with patch("networkx.DiGraph") as mock_digraph:
|
35
|
+
# mock_graph = MagicMock()
|
36
|
+
# mock_digraph.return_value = mock_graph
|
37
|
+
# result = self.graph.to_networkx()
|
38
|
+
# self.assertEqual(result, mock_graph)
|
39
|
+
#
|
40
|
+
# @patch("lionagi.libs.SysUtil.check_import")
|
41
|
+
# def test_to_networkx_empty_graph(self, mock_check_import):
|
42
|
+
# mock_check_import.return_value = None
|
43
|
+
# with patch("networkx.DiGraph") as mock_digraph:
|
44
|
+
# mock_graph = MagicMock()
|
45
|
+
# mock_digraph.return_value = mock_graph
|
46
|
+
#
|
47
|
+
# self.graph.internal_nodes = {}
|
48
|
+
# result = self.graph.to_networkx()
|
49
|
+
#
|
50
|
+
# self.assertEqual(result, mock_graph)
|
51
|
+
# mock_check_import.assert_called_once_with("networkx")
|
52
|
+
# mock_digraph.assert_called_once()
|
53
|
+
# mock_graph.add_node.assert_not_called()
|
54
|
+
# mock_graph.add_edge.assert_not_called()
|
55
|
+
#
|
56
|
+
# def test_add_node(self):
|
57
|
+
# new_node = Node(id_="node4", content="Node 4 content")
|
58
|
+
# self.graph.add_node(new_node)
|
59
|
+
# self.assertIn("node4", self.graph.internal_nodes)
|
60
|
+
#
|
61
|
+
# def test_remove_node(self):
|
62
|
+
# self.graph.remove_node(self.node1)
|
63
|
+
# self.assertNotIn("node1", self.graph.internal_nodes)
|
64
|
+
#
|
65
|
+
# def test_clear(self):
|
66
|
+
# self.graph.clear()
|
67
|
+
# self.assertEqual(len(self.graph.internal_nodes), 0)
|
68
|
+
# self.assertTrue(self.graph.is_empty)
|
69
|
+
#
|
70
|
+
# if __name__ == "__main__":
|
71
|
+
# unittest.main()
|