lionagi 0.0.306__py3-none-any.whl → 0.0.308__py3-none-any.whl

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.
Files changed (78) hide show
  1. lionagi/__init__.py +2 -5
  2. lionagi/core/__init__.py +7 -5
  3. lionagi/core/agent/__init__.py +3 -0
  4. lionagi/core/agent/base_agent.py +10 -12
  5. lionagi/core/branch/__init__.py +4 -0
  6. lionagi/core/branch/base_branch.py +81 -81
  7. lionagi/core/branch/branch.py +16 -28
  8. lionagi/core/branch/branch_flow_mixin.py +3 -7
  9. lionagi/core/branch/executable_branch.py +86 -56
  10. lionagi/core/branch/util.py +77 -162
  11. lionagi/core/{flow/direct → direct}/__init__.py +1 -1
  12. lionagi/core/{flow/direct/predict.py → direct/parallel_predict.py} +39 -17
  13. lionagi/core/direct/parallel_react.py +0 -0
  14. lionagi/core/direct/parallel_score.py +0 -0
  15. lionagi/core/direct/parallel_select.py +0 -0
  16. lionagi/core/direct/parallel_sentiment.py +0 -0
  17. lionagi/core/direct/predict.py +174 -0
  18. lionagi/core/{flow/direct → direct}/react.py +2 -2
  19. lionagi/core/{flow/direct → direct}/score.py +28 -23
  20. lionagi/core/{flow/direct → direct}/select.py +48 -45
  21. lionagi/core/direct/utils.py +83 -0
  22. lionagi/core/flow/monoflow/ReAct.py +6 -5
  23. lionagi/core/flow/monoflow/__init__.py +9 -0
  24. lionagi/core/flow/monoflow/chat.py +10 -10
  25. lionagi/core/flow/monoflow/chat_mixin.py +11 -10
  26. lionagi/core/flow/monoflow/followup.py +6 -5
  27. lionagi/core/flow/polyflow/__init__.py +1 -0
  28. lionagi/core/flow/polyflow/chat.py +15 -3
  29. lionagi/core/mail/mail_manager.py +18 -19
  30. lionagi/core/mail/schema.py +5 -4
  31. lionagi/core/messages/schema.py +18 -20
  32. lionagi/core/prompt/__init__.py +0 -0
  33. lionagi/core/prompt/prompt_template.py +0 -0
  34. lionagi/core/schema/__init__.py +2 -2
  35. lionagi/core/schema/action_node.py +11 -3
  36. lionagi/core/schema/base_mixin.py +56 -59
  37. lionagi/core/schema/base_node.py +34 -37
  38. lionagi/core/schema/condition.py +24 -0
  39. lionagi/core/schema/data_logger.py +96 -99
  40. lionagi/core/schema/data_node.py +19 -19
  41. lionagi/core/schema/prompt_template.py +0 -0
  42. lionagi/core/schema/structure.py +171 -169
  43. lionagi/core/session/__init__.py +1 -3
  44. lionagi/core/session/session.py +196 -214
  45. lionagi/core/tool/tool_manager.py +95 -103
  46. lionagi/integrations/__init__.py +1 -3
  47. lionagi/integrations/bridge/langchain_/documents.py +17 -18
  48. lionagi/integrations/bridge/langchain_/langchain_bridge.py +14 -14
  49. lionagi/integrations/bridge/llamaindex_/llama_index_bridge.py +22 -22
  50. lionagi/integrations/bridge/llamaindex_/node_parser.py +12 -12
  51. lionagi/integrations/bridge/llamaindex_/reader.py +11 -11
  52. lionagi/integrations/bridge/llamaindex_/textnode.py +7 -7
  53. lionagi/integrations/config/openrouter_configs.py +0 -1
  54. lionagi/integrations/provider/oai.py +26 -26
  55. lionagi/integrations/provider/services.py +38 -38
  56. lionagi/libs/__init__.py +34 -1
  57. lionagi/libs/ln_api.py +211 -221
  58. lionagi/libs/ln_async.py +53 -60
  59. lionagi/libs/ln_convert.py +118 -120
  60. lionagi/libs/ln_dataframe.py +32 -33
  61. lionagi/libs/ln_func_call.py +334 -342
  62. lionagi/libs/ln_nested.py +99 -107
  63. lionagi/libs/ln_parse.py +161 -165
  64. lionagi/libs/sys_util.py +52 -52
  65. lionagi/tests/test_core/test_session.py +254 -266
  66. lionagi/tests/test_core/test_session_base_util.py +299 -300
  67. lionagi/tests/test_core/test_tool_manager.py +70 -74
  68. lionagi/tests/test_libs/test_nested.py +2 -7
  69. lionagi/tests/test_libs/test_parse.py +2 -2
  70. lionagi/version.py +1 -1
  71. {lionagi-0.0.306.dist-info → lionagi-0.0.308.dist-info}/METADATA +4 -2
  72. lionagi-0.0.308.dist-info/RECORD +115 -0
  73. lionagi/core/flow/direct/utils.py +0 -43
  74. lionagi-0.0.306.dist-info/RECORD +0 -106
  75. /lionagi/core/{flow/direct → direct}/sentiment.py +0 -0
  76. {lionagi-0.0.306.dist-info → lionagi-0.0.308.dist-info}/LICENSE +0 -0
  77. {lionagi-0.0.306.dist-info → lionagi-0.0.308.dist-info}/WHEEL +0 -0
  78. {lionagi-0.0.306.dist-info → lionagi-0.0.308.dist-info}/top_level.txt +0 -0
@@ -1,266 +1,254 @@
1
- from lionagi.core.branch.branch import Branch
2
- from lionagi.core.session.session import Session
3
-
4
- import unittest
5
- from unittest.mock import patch, call, MagicMock
6
- import pandas as pd
7
- import json
8
- from datetime import datetime
9
-
10
-
11
- class TestSession(unittest.TestCase):
12
-
13
- def setUp(self):
14
- mock_branch = MagicMock()
15
-
16
- mock_branch.to_csv_file = MagicMock()
17
- mock_branch.to_json_file = MagicMock()
18
-
19
- mock_datalogger = MagicMock()
20
- mock_datalogger.to_csv_file = MagicMock()
21
- mock_datalogger.to_json_file = MagicMock()
22
-
23
- # Assign the mocked datalogger to the mock_branch
24
- mock_branch.datalogger = mock_datalogger
25
-
26
- self.branch1 = mock_branch(name="branch1")
27
- self.branch1.messages = pd.DataFrame(
28
- [
29
- {
30
- "node_id": "1",
31
- "timestamp": "2021-01-01 00:00:00",
32
- "role": "system",
33
- "sender": "system",
34
- "content": json.dumps({"system_info": "System message"}),
35
- }
36
- ]
37
- )
38
- self.branch2 = mock_branch(name="branch2")
39
- self.branch1.messages = pd.DataFrame(
40
- [
41
- {
42
- "node_id": "2",
43
- "timestamp": "2021-01-01 00:01:00",
44
- "role": "user",
45
- "sender": "user1",
46
- "content": json.dumps({"instruction": "User message"}),
47
- }
48
- ]
49
- )
50
-
51
- branches = {"branch1": self.branch1, "branch2": self.branch2}
52
-
53
- self.session = Session(
54
- branches=branches,
55
- default_branch_name="branch1",
56
- default_branch=branches["branch1"],
57
- )
58
- self.session.mail_manager = MagicMock()
59
-
60
- # def test_from_csv_initialization(self):
61
- # """Test Session initialization from a CSV file."""
62
- # mock_df = pd.DataFrame(
63
- # {
64
- # "node_id": ["1", "2"],
65
- # "timestamp": [datetime(2021, 1, 1), datetime(2021, 1, 1)],
66
- # "role": ["system", "user"],
67
- # "sender": ["system", "user1"],
68
- # "content": [
69
- # json.dumps({"system_info": "System message"}),
70
- # json.dumps({"instruction": "User message"}),
71
- # ],
72
- # }
73
- # )
74
- # filepath = "path/to/mock.csv"
75
-
76
- # with patch("pandas.read_csv", return_value=mock_df) as mock_read_csv:
77
- # session = Session.from_csv(filepath)
78
- # mock_read_csv.assert_called_once_with(filepath)
79
- # pd.testing.assert_frame_equal(session.messages, mock_df)
80
-
81
- # def test_from_json_initialization(self):
82
- # """Test Session initialization from a CSV file."""
83
- # mock_df = pd.DataFrame(
84
- # {
85
- # "node_id": ["1", "2"],
86
- # "timestamp": [datetime(2021, 1, 1), datetime(2021, 1, 1)],
87
- # "role": ["system", "user"],
88
- # "sender": ["system", "user1"],
89
- # "content": [
90
- # json.dumps({"system_info": "System message"}),
91
- # json.dumps({"instruction": "User message"}),
92
- # ],
93
- # }
94
- # )
95
- # filepath = "path/to/mock.json"
96
-
97
- # with patch("pandas.read_json", return_value=mock_df) as mock_read_json:
98
- # session = Session.from_json(filepath)
99
- # mock_read_json.assert_called_once_with(filepath)
100
- # pd.testing.assert_frame_equal(session.messages, mock_df)
101
-
102
- def test_to_csv_file(self):
103
- """Ensure to_csv_file calls each branch's to_csv_file method."""
104
- filename = "test_export.csv"
105
- self.session.to_csv_file(filename=filename)
106
-
107
- for name, branch in self.session.branches.items():
108
- # Verify it was called twice
109
- self.assertEqual(branch.to_csv_file.call_count, 2)
110
-
111
- # Verify the arguments of the last call
112
- expected_filename = f"{name}_{filename}"
113
- self.assertIn(
114
- expected_filename,
115
- ["branch1_test_export.csv", "branch2_test_export.csv"],
116
- )
117
-
118
- def test_to_json_file(self):
119
- """Ensure to_json_file calls each branch's to_json_file method."""
120
- filename = "test_export.json"
121
- self.session.to_json_file(filename=filename)
122
-
123
- for name, branch in self.session.branches.items():
124
- # Verify it was called twice
125
- self.assertEqual(branch.to_json_file.call_count, 2)
126
-
127
- # Verify the arguments of the last call
128
- expected_filename = f"{name}_{filename}"
129
- self.assertIn(
130
- expected_filename,
131
- ["branch1_test_export.json", "branch2_test_export.json"],
132
- )
133
-
134
- def test_log_to_csv(self):
135
- """Ensure log_to_csv calls each branch's log_to_csv method."""
136
- filename = "test_export.csv"
137
- self.session.log_to_csv(filename=filename)
138
-
139
- for name, branch in self.session.branches.items():
140
- # Verify it was called twice
141
- self.assertEqual(branch.log_to_csv.call_count, 2)
142
-
143
- # Verify the arguments of the last call
144
- expected_filename = f"{name}_{filename}"
145
- self.assertIn(
146
- expected_filename,
147
- ["branch1_test_export.csv", "branch2_test_export.csv"],
148
- )
149
-
150
- def test_log_to_json(self):
151
- """Ensure log_to_json calls each branch's log_to_json method."""
152
- filename = "test_export.json"
153
- self.session.log_to_json(filename=filename)
154
-
155
- for name, branch in self.session.branches.items():
156
- # Verify it was called twice
157
- self.assertEqual(branch.log_to_json.call_count, 2)
158
-
159
- # Verify the arguments of the last call
160
- expected_filename = f"{name}_{filename}"
161
- self.assertIn(
162
- expected_filename,
163
- ["branch1_test_export.json", "branch2_test_export.json"],
164
- )
165
-
166
- def test_all_messages(self):
167
- """Test aggregation of all messages across branches."""
168
- expected_df = pd.concat(
169
- [self.branch1.messages, self.branch2.messages], ignore_index=True
170
- )
171
-
172
- actual_df = self.session.all_messages
173
-
174
- pd.testing.assert_frame_equal(actual_df, expected_df)
175
-
176
- def test_new_branch_creation(self):
177
- """Test creating a new branch successfully."""
178
- branch_name = "test_branch"
179
- self.session.new_branch(branch_name=branch_name)
180
- self.assertIn(branch_name, self.session.branches)
181
-
182
- def test_new_branch_duplicate_name(self):
183
- """Test error handling for duplicate branch names."""
184
- branch_name = "test_branch"
185
- self.session.new_branch(branch_name=branch_name)
186
- with self.assertRaises(ValueError):
187
- self.session.new_branch(branch_name=branch_name)
188
-
189
- def test_get_branch_by_name(self):
190
- """Test retrieving a branch by its name."""
191
- branch_name = "test_branch"
192
- self.session.new_branch(branch_name=branch_name)
193
- branch = self.session.get_branch(branch_name)
194
- self.assertIsInstance(branch, Branch)
195
-
196
- def test_get_branch_invalid_name(self):
197
- """Test error handling for invalid branch names."""
198
- with self.assertRaises(ValueError):
199
- self.session.get_branch("nonexistent_branch")
200
-
201
- def test_change_default_branch(self):
202
- """Test changing the default branch."""
203
- branch_name = "new_default"
204
- self.session.new_branch(branch_name=branch_name)
205
- self.session.change_default_branch(branch_name)
206
- self.assertEqual(self.session.default_branch_name, branch_name)
207
-
208
- def test_delete_branch(self):
209
- """Test deleting a branch."""
210
- branch_name = "test_branch"
211
- self.session.new_branch(branch_name=branch_name)
212
- self.session.delete_branch(branch_name)
213
- self.assertNotIn(branch_name, self.session.branches)
214
-
215
- def test_delete_default_branch_error(self):
216
- """Test error when trying to delete the default branch."""
217
- with self.assertRaises(ValueError):
218
- self.session.delete_branch(self.session.default_branch_name)
219
-
220
- def test_merge_branch(self):
221
- """Test merging two branches."""
222
- from_branch = "source_branch"
223
- to_branch = "target_branch"
224
- self.session.new_branch(branch_name=from_branch)
225
- self.session.new_branch(branch_name=to_branch)
226
- self.session.merge_branch(from_=from_branch, to_branch=to_branch, del_=True)
227
- self.assertIn(to_branch, self.session.branches)
228
- self.assertNotIn(from_branch, self.session.branches)
229
-
230
- def test_collect_from_specified_branches(self):
231
- """Test collecting requests from specified branches."""
232
- self.session.collect(from_=["branch1"])
233
- self.assertEqual(self.session.mail_manager.collect.call_count, 1)
234
-
235
- def test_collect_from_all_branches(self):
236
- """Test collecting requests from all branches."""
237
- self.session.collect()
238
- self.assertEqual(self.session.mail_manager.collect.call_count, 2)
239
-
240
- def test_send_to_specified_branches(self):
241
- """Test sending requests to specified branches."""
242
- self.session.send(to_=["branch_1"])
243
- self.assertEqual(self.session.mail_manager.send.call_count, 1)
244
-
245
- def test_send_to_all_branches(self):
246
- """Test sending requests to all branches."""
247
- self.session.send()
248
- self.assertEqual(self.session.mail_manager.send.call_count, 2)
249
-
250
- def test_collect_send_all_without_receive_all(self):
251
- """Test collecting and sending requests across all branches without receiving."""
252
- self.session.collect_send_all()
253
- self.assertEqual(self.session.mail_manager.collect.call_count, 2)
254
- self.assertEqual(self.session.mail_manager.send.call_count, 2)
255
- self.branch1.receive_all.assert_not_called()
256
- self.branch2.receive_all.assert_not_called()
257
-
258
- def test_collect_send_all_with_receive_all(self):
259
- """Test collecting and sending requests across all branches with receiving."""
260
- self.session.collect_send_all(receive_all=True)
261
- self.branch1.receive_all.assert_called()
262
- self.branch2.receive_all.assert_called()
263
-
264
-
265
- if __name__ == "__main__":
266
- unittest.main()
1
+ # from lionagi.core.branch.branch import Branch
2
+ # from lionagi.core.session.session import Session
3
+
4
+ # import unittest
5
+ # from unittest.mock import patch, call, MagicMock
6
+ # import pandas as pd
7
+ # import json
8
+ # from datetime import datetime
9
+
10
+
11
+ # class TestSession(unittest.TestCase):
12
+
13
+ # def setUp(self):
14
+ # mock_branch = MagicMock()
15
+
16
+ # mock_branch.to_csv_file = MagicMock()
17
+ # mock_branch.to_json_file = MagicMock()
18
+
19
+ # mock_datalogger = MagicMock()
20
+ # mock_datalogger.to_csv_file = MagicMock()
21
+ # mock_datalogger.to_json_file = MagicMock()
22
+
23
+ # # Assign the mocked datalogger to the mock_branch
24
+ # mock_branch.datalogger = mock_datalogger
25
+
26
+ # self.branch1 = mock_branch(name="branch1")
27
+ # self.branch1.messages = pd.DataFrame(
28
+ # [{
29
+ # "node_id": "1", "timestamp": "2021-01-01 00:00:00",
30
+ # "role": "system", "sender": "system",
31
+ # "content": json.dumps({"system_info": "System message"}),
32
+ # }]
33
+ # )
34
+ # self.branch2 = mock_branch(name="branch2")
35
+ # self.branch1.messages = pd.DataFrame(
36
+ # [{
37
+ # "node_id": "2", "timestamp": "2021-01-01 00:01:00",
38
+ # "role": "user", "sender": "user1",
39
+ # "content": json.dumps({"instruction": "User message"}),
40
+ # }]
41
+ # )
42
+
43
+ # branches = {"branch1": self.branch1, "branch2": self.branch2}
44
+
45
+ # self.session = Session(
46
+ # branches=branches, default_branch_name="branch1",
47
+ # default_branch=branches["branch1"], )
48
+ # self.session.mail_manager = MagicMock()
49
+
50
+ # # def test_from_csv_initialization(self):
51
+ # # """Test Session initialization from a CSV file."""
52
+ # # mock_df = pd.DataFrame(
53
+ # # {
54
+ # # "node_id": ["1", "2"],
55
+ # # "timestamp": [datetime(2021, 1, 1), datetime(2021, 1, 1)],
56
+ # # "role": ["system", "user"],
57
+ # # "sender": ["system", "user1"],
58
+ # # "content": [
59
+ # # json.dumps({"system_info": "System message"}),
60
+ # # json.dumps({"instruction": "User message"}),
61
+ # # ],
62
+ # # }
63
+ # # )
64
+ # # filepath = "path/to/mock.csv"
65
+
66
+ # # with patch("pandas.read_csv", return_value=mock_df) as mock_read_csv:
67
+ # # session = Session.from_csv(filepath)
68
+ # # mock_read_csv.assert_called_once_with(filepath)
69
+ # # pd.testing.assert_frame_equal(session.messages, mock_df)
70
+
71
+ # # def test_from_json_initialization(self):
72
+ # # """Test Session initialization from a CSV file."""
73
+ # # mock_df = pd.DataFrame(
74
+ # # {
75
+ # # "node_id": ["1", "2"],
76
+ # # "timestamp": [datetime(2021, 1, 1), datetime(2021, 1, 1)],
77
+ # # "role": ["system", "user"],
78
+ # # "sender": ["system", "user1"],
79
+ # # "content": [
80
+ # # json.dumps({"system_info": "System message"}),
81
+ # # json.dumps({"instruction": "User message"}),
82
+ # # ],
83
+ # # }
84
+ # # )
85
+ # # filepath = "path/to/mock.json"
86
+
87
+ # # with patch("pandas.read_json", return_value=mock_df) as mock_read_json:
88
+ # # session = Session.from_json(filepath)
89
+ # # mock_read_json.assert_called_once_with(filepath)
90
+ # # pd.testing.assert_frame_equal(session.messages, mock_df)
91
+
92
+ # def test_to_csv_file(self):
93
+ # """Ensure to_csv_file calls each branch's to_csv_file method."""
94
+ # filename = "test_export.csv"
95
+ # self.session.to_csv_file(filename=filename)
96
+
97
+ # for name, branch in self.session.branches.items():
98
+ # # Verify it was called twice
99
+ # self.assertEqual(branch.to_csv_file.call_count, 2)
100
+
101
+ # # Verify the arguments of the last call
102
+ # expected_filename = f"{name}_{filename}"
103
+ # self.assertIn(
104
+ # expected_filename,
105
+ # ["branch1_test_export.csv", "branch2_test_export.csv"], )
106
+
107
+ # def test_to_json_file(self):
108
+ # """Ensure to_json_file calls each branch's to_json_file method."""
109
+ # filename = "test_export.json"
110
+ # self.session.to_json_file(filename=filename)
111
+
112
+ # for name, branch in self.session.branches.items():
113
+ # # Verify it was called twice
114
+ # self.assertEqual(branch.to_json_file.call_count, 2)
115
+
116
+ # # Verify the arguments of the last call
117
+ # expected_filename = f"{name}_{filename}"
118
+ # self.assertIn(
119
+ # expected_filename,
120
+ # ["branch1_test_export.json", "branch2_test_export.json"], )
121
+
122
+ # def test_log_to_csv(self):
123
+ # """Ensure log_to_csv calls each branch's log_to_csv method."""
124
+ # filename = "test_export.csv"
125
+ # self.session.log_to_csv(filename=filename)
126
+
127
+ # for name, branch in self.session.branches.items():
128
+ # # Verify it was called twice
129
+ # self.assertEqual(branch.log_to_csv.call_count, 2)
130
+
131
+ # # Verify the arguments of the last call
132
+ # expected_filename = f"{name}_{filename}"
133
+ # self.assertIn(
134
+ # expected_filename,
135
+ # ["branch1_test_export.csv", "branch2_test_export.csv"], )
136
+
137
+ # def test_log_to_json(self):
138
+ # """Ensure log_to_json calls each branch's log_to_json method."""
139
+ # filename = "test_export.json"
140
+ # self.session.log_to_json(filename=filename)
141
+
142
+ # for name, branch in self.session.branches.items():
143
+ # # Verify it was called twice
144
+ # self.assertEqual(branch.log_to_json.call_count, 2)
145
+
146
+ # # Verify the arguments of the last call
147
+ # expected_filename = f"{name}_{filename}"
148
+ # self.assertIn(
149
+ # expected_filename,
150
+ # ["branch1_test_export.json", "branch2_test_export.json"], )
151
+
152
+ # def test_all_messages(self):
153
+ # """Test aggregation of all messages across branches."""
154
+ # expected_df = pd.concat(
155
+ # [self.branch1.messages, self.branch2.messages], ignore_index=True
156
+ # )
157
+
158
+ # actual_df = self.session.all_messages
159
+
160
+ # pd.testing.assert_frame_equal(actual_df, expected_df)
161
+
162
+ # def test_new_branch_creation(self):
163
+ # """Test creating a new branch successfully."""
164
+ # branch_name = "test_branch"
165
+ # self.session.new_branch(branch_name=branch_name)
166
+ # self.assertIn(branch_name, self.session.branches)
167
+
168
+ # def test_new_branch_duplicate_name(self):
169
+ # """Test error handling for duplicate branch names."""
170
+ # branch_name = "test_branch"
171
+ # self.session.new_branch(branch_name=branch_name)
172
+ # with self.assertRaises(ValueError):
173
+ # self.session.new_branch(branch_name=branch_name)
174
+
175
+ # def test_get_branch_by_name(self):
176
+ # """Test retrieving a branch by its name."""
177
+ # branch_name = "test_branch"
178
+ # self.session.new_branch(branch_name=branch_name)
179
+ # branch = self.session.get_branch(branch_name)
180
+ # self.assertIsInstance(branch, Branch)
181
+
182
+ # def test_get_branch_invalid_name(self):
183
+ # """Test error handling for invalid branch names."""
184
+ # with self.assertRaises(ValueError):
185
+ # self.session.get_branch("nonexistent_branch")
186
+
187
+ # def test_change_default_branch(self):
188
+ # """Test changing the default branch."""
189
+ # branch_name = "new_default"
190
+ # self.session.new_branch(branch_name=branch_name)
191
+ # self.session.change_default_branch(branch_name)
192
+ # self.assertEqual(self.session.default_branch_name, branch_name)
193
+
194
+ # def test_delete_branch(self):
195
+ # """Test deleting a branch."""
196
+ # branch_name = "test_branch"
197
+ # self.session.new_branch(branch_name=branch_name)
198
+ # self.session.delete_branch(branch_name)
199
+ # self.assertNotIn(branch_name, self.session.branches)
200
+
201
+ # def test_delete_default_branch_error(self):
202
+ # """Test error when trying to delete the default branch."""
203
+ # with self.assertRaises(ValueError):
204
+ # self.session.delete_branch(self.session.default_branch_name)
205
+
206
+ # def test_merge_branch(self):
207
+ # """Test merging two branches."""
208
+ # from_branch = "source_branch"
209
+ # to_branch = "target_branch"
210
+ # self.session.new_branch(branch_name=from_branch)
211
+ # self.session.new_branch(branch_name=to_branch)
212
+ # self.session.merge_branch(
213
+ # from_=from_branch, to_branch=to_branch, del_=True
214
+ # )
215
+ # self.assertIn(to_branch, self.session.branches)
216
+ # self.assertNotIn(from_branch, self.session.branches)
217
+
218
+ # def test_collect_from_specified_branches(self):
219
+ # """Test collecting requests from specified branches."""
220
+ # self.session.collect(from_=["branch1"])
221
+ # self.assertEqual(self.session.mail_manager.collect.call_count, 1)
222
+
223
+ # def test_collect_from_all_branches(self):
224
+ # """Test collecting requests from all branches."""
225
+ # self.session.collect()
226
+ # self.assertEqual(self.session.mail_manager.collect.call_count, 2)
227
+
228
+ # def test_send_to_specified_branches(self):
229
+ # """Test sending requests to specified branches."""
230
+ # self.session.send(to_=["branch_1"])
231
+ # self.assertEqual(self.session.mail_manager.send.call_count, 1)
232
+
233
+ # def test_send_to_all_branches(self):
234
+ # """Test sending requests to all branches."""
235
+ # self.session.send()
236
+ # self.assertEqual(self.session.mail_manager.send.call_count, 2)
237
+
238
+ # def test_collect_send_all_without_receive_all(self):
239
+ # """Test collecting and sending requests across all branches without receiving."""
240
+ # self.session.collect_send_all()
241
+ # self.assertEqual(self.session.mail_manager.collect.call_count, 2)
242
+ # self.assertEqual(self.session.mail_manager.send.call_count, 2)
243
+ # self.branch1.receive_all.assert_not_called()
244
+ # self.branch2.receive_all.assert_not_called()
245
+
246
+ # def test_collect_send_all_with_receive_all(self):
247
+ # """Test collecting and sending requests across all branches with receiving."""
248
+ # self.session.collect_send_all(receive_all=True)
249
+ # self.branch1.receive_all.assert_called()
250
+ # self.branch2.receive_all.assert_called()
251
+
252
+
253
+ # if __name__ == "__main__":
254
+ # unittest.main()