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
@@ -1,75 +1,76 @@
|
|
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
|
-
|
1
|
+
#TODO
|
2
|
+
# import unittest
|
3
|
+
# from lionagi.core.graph.tree import TreeNode, Tree
|
4
|
+
#
|
5
|
+
# class TestTreeNode(unittest.TestCase):
|
6
|
+
# def setUp(self):
|
7
|
+
# self.parent_node = TreeNode(id_="parent", content="Parent Node")
|
8
|
+
# self.child_node1 = TreeNode(id_="child1", content="Child Node 1")
|
9
|
+
# self.child_node2 = TreeNode(id_="child2", content="Child Node 2")
|
10
|
+
#
|
11
|
+
# def test_relate_child(self):
|
12
|
+
# self.parent_node.relate_child(self.child_node1)
|
13
|
+
# self.assertIn("child1", self.parent_node.children)
|
14
|
+
# self.assertEqual(self.child_node1.parent, self.parent_node)
|
15
|
+
#
|
16
|
+
# def test_relate_children(self):
|
17
|
+
# self.parent_node.relate_child([self.child_node1, self.child_node2])
|
18
|
+
# self.assertIn("child1", self.parent_node.children)
|
19
|
+
# self.assertIn("child2", self.parent_node.children)
|
20
|
+
# self.assertEqual(self.child_node1.parent, self.parent_node)
|
21
|
+
# self.assertEqual(self.child_node2.parent, self.parent_node)
|
22
|
+
#
|
23
|
+
# def test_relate_parent(self):
|
24
|
+
# self.child_node1.relate_parent(self.parent_node)
|
25
|
+
# self.assertIn("child1", self.parent_node.children)
|
26
|
+
# self.assertEqual(self.child_node1.parent, self.parent_node)
|
27
|
+
#
|
28
|
+
# def test_unrelate_child(self):
|
29
|
+
# self.parent_node.relate_child(self.child_node1)
|
30
|
+
# self.parent_node.unrelate_child(self.child_node1)
|
31
|
+
# self.assertNotIn("child1", self.parent_node.children)
|
32
|
+
# self.assertIsNone(self.child_node1.parent)
|
33
|
+
#
|
34
|
+
# def test_unrelate_parent(self):
|
35
|
+
# self.child_node1.relate_parent(self.parent_node)
|
36
|
+
# self.child_node1.unrelate_parent()
|
37
|
+
# self.assertNotIn("child1", self.parent_node.children)
|
38
|
+
# self.assertIsNone(self.child_node1.parent)
|
39
|
+
#
|
40
|
+
# class TestTree(unittest.TestCase):
|
41
|
+
# def setUp(self):
|
42
|
+
# self.tree = Tree()
|
43
|
+
# self.root = TreeNode(id_="root", content="Root Node")
|
44
|
+
# self.child_node1 = TreeNode(id_="child1", content="Child Node 1")
|
45
|
+
# self.child_node2 = TreeNode(id_="child2", content="Child Node 2")
|
46
|
+
# self.grandchild_node = TreeNode(id_="grandchild", content="Grandchild Node")
|
47
|
+
#
|
48
|
+
# def test_add_node(self):
|
49
|
+
# self.tree.add_node(self.root)
|
50
|
+
# self.assertIn("root", self.tree.internal_nodes)
|
51
|
+
#
|
52
|
+
# def test_relate_parent_child(self):
|
53
|
+
# self.tree.relate_parent_child(self.root, [self.child_node1, self.child_node2])
|
54
|
+
# self.assertIn("child1", self.root.children)
|
55
|
+
# self.assertIn("child2", self.root.children)
|
56
|
+
# self.assertEqual(self.tree.root, self.root)
|
57
|
+
#
|
58
|
+
# def test_tree_structure(self):
|
59
|
+
# # Build the tree
|
60
|
+
# self.tree.relate_parent_child(self.root, [self.child_node1, self.child_node2])
|
61
|
+
# self.tree.relate_parent_child(self.child_node1, self.grandchild_node)
|
62
|
+
#
|
63
|
+
# # Check the tree structure
|
64
|
+
# self.assertIn("grandchild", self.child_node1.children)
|
65
|
+
# self.assertEqual(self.grandchild_node.parent, self.child_node1)
|
66
|
+
# self.assertEqual(self.child_node1.parent, self.root)
|
67
|
+
#
|
68
|
+
# def test_acyclic(self):
|
69
|
+
# # Build the tree
|
70
|
+
# self.tree.relate_parent_child(self.root, self.child_node1)
|
71
|
+
# self.tree.relate_parent_child(self.child_node1, self.child_node2)
|
72
|
+
# # Trees should always be acyclic
|
73
|
+
# self.assertTrue(self.tree.acyclic)
|
74
|
+
#
|
75
|
+
# if __name__ == "__main__":
|
76
|
+
# unittest.main()
|
@@ -1,62 +1,98 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import
|
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
|
-
|
1
|
+
import pytest
|
2
|
+
|
3
|
+
from lionagi.core.mail import Mail
|
4
|
+
from lionagi.core.mail.package import Package
|
5
|
+
from datetime import datetime
|
6
|
+
|
7
|
+
"""
|
8
|
+
More to be added
|
9
|
+
"""
|
10
|
+
|
11
|
+
|
12
|
+
def trim_timestamp_to_day(timestamp_str):
|
13
|
+
dt = datetime.fromisoformat(timestamp_str)
|
14
|
+
return dt.strftime('%Y-%m-%d')
|
15
|
+
|
16
|
+
|
17
|
+
class MockPackage(Package):
|
18
|
+
"""A mock package class for testing purposes."""
|
19
|
+
|
20
|
+
|
21
|
+
@pytest.fixture
|
22
|
+
def mail():
|
23
|
+
"""Fixture to create a Mail instance with a MockPackage."""
|
24
|
+
package = MockPackage()
|
25
|
+
mail_instance = Mail(timestamp=datetime.today().strftime('%Y-%m-%d'), package=package)
|
26
|
+
return mail_instance
|
27
|
+
|
28
|
+
|
29
|
+
def test_mail_category(mail):
|
30
|
+
"""Test the category property of Mail."""
|
31
|
+
assert mail.category is None
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
# from lionagi.core.generic.mail import *
|
38
|
+
#
|
39
|
+
# import unittest
|
40
|
+
#
|
41
|
+
#
|
42
|
+
# class TestMail(unittest.TestCase):
|
43
|
+
# def setUp(self):
|
44
|
+
# self.mail = Mail(
|
45
|
+
# sender="node1",
|
46
|
+
# recipient="node2",
|
47
|
+
# category=MailPackageCategory.MESSAGES,
|
48
|
+
# package="Hello, World!"
|
49
|
+
# )
|
50
|
+
#
|
51
|
+
# def test_mail_initialization(self):
|
52
|
+
# """Test initialization of Mail objects."""
|
53
|
+
# self.assertIsInstance(self.mail, BaseComponent)
|
54
|
+
# self.assertEqual(self.mail.sender, "node1")
|
55
|
+
# self.assertEqual(self.mail.recipient, "node2")
|
56
|
+
# self.assertEqual(self.mail.category, MailPackageCategory.MESSAGES)
|
57
|
+
# self.assertEqual(self.mail.package, "Hello, World!")
|
58
|
+
#
|
59
|
+
# def test_mail_str(self):
|
60
|
+
# """Test the string representation of Mail."""
|
61
|
+
# expected_str = "Mail from node1 to node2 with category messages and package Hello, World!"
|
62
|
+
# self.assertEqual(str(self.mail), expected_str)
|
63
|
+
#
|
64
|
+
# class TestMailBox(unittest.TestCase):
|
65
|
+
# def setUp(self):
|
66
|
+
# self.mailbox = MailBox()
|
67
|
+
# self.mail1 = Mail(
|
68
|
+
# sender="node1",
|
69
|
+
# recipient="node3",
|
70
|
+
# category="model",
|
71
|
+
# package={"model": "Random Forest"}
|
72
|
+
# )
|
73
|
+
# self.mail2 = Mail(
|
74
|
+
# sender="node2",
|
75
|
+
# recipient="node3",
|
76
|
+
# category=MailPackageCategory.SERVICE,
|
77
|
+
# package={"service": "Prediction"}
|
78
|
+
# )
|
79
|
+
#
|
80
|
+
# def test_adding_mails(self):
|
81
|
+
# """Test adding mails to MailBox."""
|
82
|
+
# self.mailbox.pending_ins["node1"] = self.mail1
|
83
|
+
# self.mailbox.pending_outs["node3"] = self.mail2
|
84
|
+
#
|
85
|
+
# self.assertIn("node1", self.mailbox.pending_ins)
|
86
|
+
# self.assertIn("node3", self.mailbox.pending_outs)
|
87
|
+
# self.assertEqual(self.mailbox.pending_ins["node1"], self.mail1)
|
88
|
+
# self.assertEqual(self.mailbox.pending_outs["node3"], self.mail2)
|
89
|
+
#
|
90
|
+
# def test_mailbox_str(self):
|
91
|
+
# """Test the string representation of MailBox."""
|
92
|
+
# self.mailbox.pending_ins["node1"] = self.mail1
|
93
|
+
# self.mailbox.pending_outs["node3"] = self.mail2
|
94
|
+
# expected_str = "MailBox with 1 pending incoming mails and 1 pending outgoing mails."
|
95
|
+
# self.assertEqual(str(self.mailbox), expected_str)
|
96
|
+
#
|
97
|
+
# if __name__ == "__main__":
|
98
|
+
# unittest.main()
|