rusticai-testing 0.0.3__tar.gz → 0.1.0__tar.gz

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 (16) hide show
  1. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/PKG-INFO +6 -7
  2. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/pyproject.toml +6 -4
  3. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/agent_ext/base_test_kvstore.py +5 -4
  4. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/execution/base_test_integration.py +11 -8
  5. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/messaging/base_test_backend.py +94 -36
  6. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/messaging/base_test_messaging.py +52 -7
  7. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/README.md +0 -0
  8. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/__init__.py +0 -0
  9. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/agent_ext/__init__.py +0 -0
  10. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/agents/__init__.py +0 -0
  11. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/agents/sample_agents.py +0 -0
  12. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/agents/simple_agent.py +0 -0
  13. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/execution/__init__.py +0 -0
  14. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/execution/integration_agents.py +0 -0
  15. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/helpers.py +0 -0
  16. {rusticai_testing-0.0.3 → rusticai_testing-0.1.0}/src/rustic_ai/testing/messaging/__init__.py +0 -0
@@ -1,19 +1,18 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: rusticai-testing
3
- Version: 0.0.3
3
+ Version: 0.1.0
4
4
  Summary: Test Utilities for Rustic AI Framework
5
- Home-page: https://www.rustic.ai/
6
5
  License: Apache-2.0
7
6
  Author: Dragonscale Industries Inc.
8
7
  Author-email: dev@dragonscale.ai
9
- Requires-Python: >=3.12,<4.0
8
+ Requires-Python: >=3.12,<3.13
10
9
  Classifier: License :: OSI Approved :: Apache Software License
11
10
  Classifier: Programming Language :: Python :: 3
12
11
  Classifier: Programming Language :: Python :: 3.12
13
- Classifier: Programming Language :: Python :: 3.13
14
12
  Requires-Dist: pytest (>=8.3.5,<9.0.0)
15
- Requires-Dist: rusticai-core (>=0.0.7,<0.1.0)
16
- Project-URL: Repository, https://github.com/rustic-ai/python-framework
13
+ Requires-Dist: rusticai-core (>=0.1.0,<0.2.0)
14
+ Project-URL: Homepage, https://www.rustic.ai/
15
+ Project-URL: Repository, https://github.com/rustic-ai/rustic-ai
17
16
  Project-URL: Rustic AI Core, https://pypi.org/project/rusticai-core/
18
17
  Description-Content-Type: text/markdown
19
18
 
@@ -4,21 +4,21 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "rusticai-testing"
7
- version = "0.0.3"
7
+ version = "0.1.0"
8
8
  description = "Test Utilities for Rustic AI Framework"
9
9
  authors = ["Dragonscale Industries Inc. <dev@dragonscale.ai>"]
10
10
  license = "Apache-2.0"
11
11
  readme = "README.md"
12
12
  homepage = "https://www.rustic.ai/"
13
- repository = "https://github.com/rustic-ai/python-framework"
13
+ repository = "https://github.com/rustic-ai/rustic-ai"
14
14
  packages = [{ include = "rustic_ai", from = "src" }]
15
15
 
16
16
  [tool.poetry.urls]
17
17
  "Rustic AI Core" = "https://pypi.org/project/rusticai-core/"
18
18
 
19
19
  [tool.poetry.dependencies]
20
- python = "^3.12"
21
- rusticai-core = { version = "0.0.7"}
20
+ python = ">=3.12,<3.13"
21
+ rusticai-core = { version = "0.1.0"}
22
22
  pytest = "^8.3.5"
23
23
 
24
24
  [tool.poetry-monorepo.deps]
@@ -61,6 +61,8 @@ explicit_package_bases = true
61
61
 
62
62
  [tool.isort]
63
63
  profile = "black"
64
+ force_sort_within_sections = true # For the sorting order issues
65
+ lines_between_sections = 1 # For the newline issue
64
66
  known_third_party = ["pydantic"]
65
67
  known_first_party = ["rustic_ai.core"]
66
68
 
@@ -1,8 +1,8 @@
1
- import time
2
1
  from abc import ABC, abstractmethod
2
+ import time
3
3
 
4
- import pytest
5
4
  from pydantic import BaseModel, JsonValue
5
+ import pytest
6
6
 
7
7
  from rustic_ai.core.agents.testutils.probe_agent import ProbeAgent
8
8
  from rustic_ai.core.guild import agent
@@ -181,7 +181,7 @@ class BaseTestKVStore(ABC):
181
181
  """
182
182
  raise NotImplementedError("This fixture should be overridden in subclasses.")
183
183
 
184
- def test_kvstore(self, probe_agent: ProbeAgent, dep_map: dict):
184
+ def test_kvstore(self, probe_agent: ProbeAgent, dep_map: dict, org_id):
185
185
  agent_spec: AgentSpec = (
186
186
  AgentBuilder(KVStoreAgent).set_description("KV Store Agent").set_name("KVStoreAgent").build_spec()
187
187
  )
@@ -191,7 +191,7 @@ class BaseTestKVStore(ABC):
191
191
  .add_agent_spec(agent_spec)
192
192
  .set_dependency_map(dep_map)
193
193
  )
194
- guild = guild_builder.launch()
194
+ guild = guild_builder.launch(organization_id=org_id)
195
195
 
196
196
  if "kvstore" in dep_map:
197
197
  guild.dependency_map["kvstore"].class_name = dep_map["kvstore"].class_name
@@ -278,6 +278,7 @@ class BaseTestKVStore(ABC):
278
278
  format=KVGet,
279
279
  )
280
280
 
281
+ time.sleep(0.05)
281
282
  messages = probe_agent.get_messages()
282
283
 
283
284
  assert len(messages) == 3
@@ -1,5 +1,5 @@
1
- import time
2
1
  from abc import ABC, abstractmethod
2
+ import time
3
3
 
4
4
  import pytest
5
5
 
@@ -28,16 +28,17 @@ class IntegrationTestABC(ABC):
28
28
 
29
29
  @pytest.fixture
30
30
  def wait_time(self) -> float:
31
- return 0.01
31
+ return 0.1
32
32
 
33
33
  @pytest.fixture
34
- def guild(self, wait_time, messaging, execution_engine, guild_id):
34
+ def guild(self, wait_time, messaging, execution_engine, guild_id, org_id):
35
35
  guild = Guild(
36
36
  id=guild_id,
37
37
  name="Test Guild",
38
38
  description="A guild for integration testing",
39
39
  messaging_config=messaging,
40
40
  execution_engine_clz=execution_engine,
41
+ organization_id=org_id,
41
42
  )
42
43
  yield guild
43
44
  time.sleep(wait_time * 5) # Allow some time for cleanup
@@ -103,16 +104,18 @@ class IntegrationTestABC(ABC):
103
104
  rair = execution_engine.is_agent_running(guild.id, ra[0].id)
104
105
  assert rair is True
105
106
 
106
- local_exec_engine = SyncExecutionEngine(guild_id=guild.id)
107
+ local_exec_engine = SyncExecutionEngine(guild_id=guild.id, organization_id=guild.organization_id)
107
108
  guild._add_local_agent(local_test_agent, local_exec_engine)
108
109
 
109
- time.sleep(wait_time)
110
+ # Give more time for all agents to initialize fully, especially for Ray/distributed execution
111
+ time.sleep(max(wait_time * 10, 1.0))
112
+
110
113
  # Initiator sends a message to trigger communication
111
114
  local_test_agent.publish_initial_message()
112
115
 
113
- # Allow some time for message processing - adjust as necessary for your environment
116
+ # Allow more time for message processing in distributed scenarios
114
117
  # Consider using a more sophisticated synchronization mechanism for real-world scenarios
115
- time.sleep(2)
118
+ time.sleep(max(wait_time * 30, 3.0))
116
119
 
117
120
  # Assertions to verify communication flow
118
121
  # Ensure the local test agent captured the messages as expected
@@ -154,7 +157,7 @@ class IntegrationTestABC(ABC):
154
157
  # Send a new message to ensure that the responder agent is no longer processing messages
155
158
  local_test_agent.publish_initial_message()
156
159
 
157
- time.sleep(2)
160
+ time.sleep(max(wait_time * 30, 3.0))
158
161
 
159
162
  # Ensure that the responder agent did not process the message
160
163
  assert len(local_test_agent.captured_messages) == 1
@@ -1,5 +1,5 @@
1
- import time
2
1
  from abc import ABC
2
+ import time
3
3
  from typing import List
4
4
 
5
5
  import pytest
@@ -34,7 +34,7 @@ class BaseTestBackendABC(ABC):
34
34
  def topic(self) -> str:
35
35
  return "test_topic"
36
36
 
37
- def test_store_message(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str):
37
+ def test_store_message(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request):
38
38
  """
39
39
  Test adding a message to a topic.
40
40
  """
@@ -45,12 +45,15 @@ class BaseTestBackendABC(ABC):
45
45
  payload={"key": "value"},
46
46
  id_obj=generator.get_id(Priority.NORMAL),
47
47
  )
48
- backend.store_message(topic, message)
48
+ namespace = request.node.name
49
+ backend.store_message(namespace, topic, message)
49
50
  messages = backend.get_messages_for_topic(topic)
50
51
  assert len(messages) == 1
51
52
  assert messages[0].payload == {"key": "value"}
52
53
 
53
- def test_message_ordering_by_priority(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str):
54
+ def test_message_ordering_by_priority(
55
+ self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request
56
+ ):
54
57
  """
55
58
  Test that messages are ordered first by priority and then by ID.
56
59
  """
@@ -107,13 +110,14 @@ class BaseTestBackendABC(ABC):
107
110
  id_obj=id6,
108
111
  )
109
112
 
113
+ namespace = request.node.name
110
114
  # Add messages to the topic
111
- backend.store_message(topic, m1)
112
- backend.store_message(topic, m2)
113
- backend.store_message(topic, m3)
114
- backend.store_message(topic, m4)
115
- backend.store_message(topic, m5)
116
- backend.store_message(topic, m6)
115
+ backend.store_message(namespace, topic, m1)
116
+ backend.store_message(namespace, topic, m2)
117
+ backend.store_message(namespace, topic, m3)
118
+ backend.store_message(namespace, topic, m4)
119
+ backend.store_message(namespace, topic, m5)
120
+ backend.store_message(namespace, topic, m6)
117
121
 
118
122
  # Retrieve messages for the topic
119
123
  retrieved_messages = backend.get_messages_for_topic(topic)
@@ -130,7 +134,9 @@ class BaseTestBackendABC(ABC):
130
134
  # Further assertions can be added based on the expected subscribers in the backend.
131
135
 
132
136
  # Test method to get messages since a given message ID
133
- def test_get_messages_for_topic_since(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str):
137
+ def test_get_messages_for_topic_since(
138
+ self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request
139
+ ):
134
140
  """
135
141
  Test retrieving messages for a topic since a given message ID.
136
142
  """
@@ -188,13 +194,14 @@ class BaseTestBackendABC(ABC):
188
194
  id_obj=id6,
189
195
  )
190
196
 
197
+ namespace = request.node.name
191
198
  # Add messages to the topic
192
- backend.store_message(topic, m1)
193
- backend.store_message(topic, m2)
194
- backend.store_message(topic, m3)
195
- backend.store_message(topic, m4)
196
- backend.store_message(topic, m5)
197
- backend.store_message(topic, m6)
199
+ backend.store_message(namespace, topic, m1)
200
+ backend.store_message(namespace, topic, m2)
201
+ backend.store_message(namespace, topic, m3)
202
+ backend.store_message(namespace, topic, m4)
203
+ backend.store_message(namespace, topic, m5)
204
+ backend.store_message(namespace, topic, m6)
198
205
 
199
206
  # Retrieve messages for the topic since a given message ID
200
207
  retrieved_messages = backend.get_messages_for_topic_since(topic, id3.to_int())
@@ -204,7 +211,7 @@ class BaseTestBackendABC(ABC):
204
211
 
205
212
  # Test method to get the next message since a given message ID
206
213
  def test_get_next_message_for_topic_since(
207
- self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str
214
+ self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request
208
215
  ):
209
216
  """
210
217
  Test retrieving the next message for a topic since a given message ID.
@@ -264,13 +271,14 @@ class BaseTestBackendABC(ABC):
264
271
  id_obj=id6,
265
272
  )
266
273
 
274
+ namespace = request.node.name
267
275
  # Add messages to the topic
268
- backend.store_message(topic, m1)
269
- backend.store_message(topic, m2)
270
- backend.store_message(topic, m3)
271
- backend.store_message(topic, m4)
272
- backend.store_message(topic, m5)
273
- backend.store_message(topic, m6)
276
+ backend.store_message(namespace, topic, m1)
277
+ backend.store_message(namespace, topic, m2)
278
+ backend.store_message(namespace, topic, m3)
279
+ backend.store_message(namespace, topic, m4)
280
+ backend.store_message(namespace, topic, m5)
281
+ backend.store_message(namespace, topic, m6)
274
282
 
275
283
  # Retrieve messages for the topic since a given message ID
276
284
  retrieved_message = backend.get_next_message_for_topic_since(topic, id3.to_int())
@@ -280,7 +288,7 @@ class BaseTestBackendABC(ABC):
280
288
 
281
289
  # Test method to get messages since a given message ID ensuring newer messages with higher priority are not lost
282
290
  def test_get_messages_for_topic_since_with_higher_priority(
283
- self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str
291
+ self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request
284
292
  ):
285
293
  """
286
294
  Test retrieving messages for a topic since a given message ID ensuring newer messages with higher priority are not lost.
@@ -356,15 +364,16 @@ class BaseTestBackendABC(ABC):
356
364
  id_obj=id8,
357
365
  )
358
366
 
367
+ namespace = request.node.name
359
368
  # Add messages to the topic
360
- backend.store_message(topic, m1)
361
- backend.store_message(topic, m2)
362
- backend.store_message(topic, m3)
363
- backend.store_message(topic, m4)
364
- backend.store_message(topic, m5)
365
- backend.store_message(topic, m6)
366
- backend.store_message(topic, m7)
367
- backend.store_message(topic, m8)
369
+ backend.store_message(namespace, topic, m1)
370
+ backend.store_message(namespace, topic, m2)
371
+ backend.store_message(namespace, topic, m3)
372
+ backend.store_message(namespace, topic, m4)
373
+ backend.store_message(namespace, topic, m5)
374
+ backend.store_message(namespace, topic, m6)
375
+ backend.store_message(namespace, topic, m7)
376
+ backend.store_message(namespace, topic, m8)
368
377
 
369
378
  # Retrieve messages for the topic since a given message ID
370
379
  retrieved_messages = backend.get_messages_for_topic_since(topic, id3.to_int())
@@ -373,7 +382,7 @@ class BaseTestBackendABC(ABC):
373
382
  assert retrieved_messages == [m8, m7, m4, m5, m6]
374
383
 
375
384
  # Test subscription on a topic
376
- def test_subscribe(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str):
385
+ def test_subscribe(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request):
377
386
  """
378
387
  Test subscribing to a topic.
379
388
  """
@@ -385,6 +394,7 @@ class BaseTestBackendABC(ABC):
385
394
  messages.append(message)
386
395
 
387
396
  backend.subscribe(topic, callback)
397
+ namespace = request.node.name
388
398
 
389
399
  m1 = Message(
390
400
  topics=topic,
@@ -394,7 +404,7 @@ class BaseTestBackendABC(ABC):
394
404
  id_obj=id1,
395
405
  )
396
406
 
397
- backend.store_message(topic, m1)
407
+ backend.store_message(namespace, topic, m1)
398
408
 
399
409
  time.sleep(0.001)
400
410
 
@@ -410,8 +420,56 @@ class BaseTestBackendABC(ABC):
410
420
  id_obj=generator.get_id(Priority.NORMAL),
411
421
  )
412
422
 
413
- backend.store_message(topic, m2)
423
+ backend.store_message(namespace, topic, m2)
414
424
 
415
425
  time.sleep(0.001)
416
426
 
417
427
  assert len(messages) == 1
428
+
429
+ def test_get_messages_by_id(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request):
430
+ """
431
+ Test retrieving messages by their IDs.
432
+ """
433
+ id1 = generator.get_id(Priority.NORMAL)
434
+ id2 = generator.get_id(Priority.HIGH)
435
+ id3 = generator.get_id(Priority.LOW)
436
+
437
+ sender = AgentTag(id="senderId", name="sender")
438
+
439
+ m1 = Message(
440
+ topics=topic,
441
+ sender=sender,
442
+ format=MessageConstants.RAW_JSON_FORMAT,
443
+ payload={"key": "m1"},
444
+ id_obj=id1,
445
+ )
446
+ m2 = Message(
447
+ topics=topic,
448
+ sender=sender,
449
+ format=MessageConstants.RAW_JSON_FORMAT,
450
+ payload={"key": "m2"},
451
+ id_obj=id2,
452
+ )
453
+ m3 = Message(
454
+ topics=topic,
455
+ sender=sender,
456
+ format=MessageConstants.RAW_JSON_FORMAT,
457
+ payload={"key": "m3"},
458
+ id_obj=id3,
459
+ )
460
+
461
+ namespace = request.node.name
462
+
463
+ # Add messages to the topic
464
+ backend.store_message(namespace, topic, m1)
465
+ backend.store_message(namespace, topic, m2)
466
+ backend.store_message(namespace, topic, m3)
467
+
468
+ # Retrieve messages by their IDs
469
+ msg_ids = [id1.to_int(), id3.to_int()]
470
+ retrieved_messages = backend.get_messages_by_id(namespace, msg_ids)
471
+
472
+ # Check that only requested messages are retrieved
473
+ assert len(retrieved_messages) == 2
474
+ assert retrieved_messages[0] == m1
475
+ assert retrieved_messages[1] == m3
@@ -1,12 +1,16 @@
1
- import time
2
1
  from abc import ABC, abstractmethod
2
+ import time
3
3
  from typing import List, Tuple, Union
4
4
 
5
5
  import pytest
6
6
 
7
7
  from rustic_ai.core.messaging.client import SimpleClient
8
8
  from rustic_ai.core.messaging.core import Client, Message, MessagingInterface
9
- from rustic_ai.core.messaging.core.message import AgentTag, MessageConstants
9
+ from rustic_ai.core.messaging.core.message import (
10
+ AgentTag,
11
+ MessageConstants,
12
+ ProcessEntry,
13
+ )
10
14
  from rustic_ai.core.messaging.core.messaging_config import MessagingConfig
11
15
  from rustic_ai.core.utils.gemstone_id import GemstoneGenerator
12
16
  from rustic_ai.core.utils.priority import Priority
@@ -93,6 +97,8 @@ class BaseTestMessagingABC(ABC):
93
97
  format: str,
94
98
  payload: dict,
95
99
  message_id,
100
+ message_history: List[ProcessEntry] = [],
101
+ enrich_with_history: int = 0,
96
102
  ):
97
103
  message = Message(
98
104
  topics=topic,
@@ -100,6 +106,8 @@ class BaseTestMessagingABC(ABC):
100
106
  format=format,
101
107
  payload=payload,
102
108
  id_obj=message_id,
109
+ message_history=message_history,
110
+ enrich_with_history=enrich_with_history,
103
111
  )
104
112
  self.publish(message)
105
113
  return message
@@ -132,7 +140,7 @@ class BaseTestMessagingABC(ABC):
132
140
  message_id = generator.get_id(Priority.NORMAL)
133
141
  sender.send_message("topic1", MessageConstants.RAW_JSON_FORMAT, {"data": "value"}, message_id)
134
142
 
135
- time.sleep(1) # Give the message time to be processed
143
+ time.sleep(0.01) # Give the message time to be processed
136
144
 
137
145
  assert len(messages_received) == 1
138
146
  assert messages_received[0].payload == {"data": "value"}
@@ -160,7 +168,7 @@ class BaseTestMessagingABC(ABC):
160
168
  message_id1,
161
169
  )
162
170
 
163
- time.sleep(1)
171
+ time.sleep(0.01)
164
172
  assert len(messages_received) == 2
165
173
 
166
174
  assert messages_received[0].payload == {"data": "value1"}
@@ -215,7 +223,7 @@ class BaseTestMessagingABC(ABC):
215
223
  message_id = generator.get_id(Priority.NORMAL)
216
224
  sender.send_message("topic1", MessageConstants.RAW_JSON_FORMAT, {"data": "value"}, message_id)
217
225
 
218
- time.sleep(1) # Give the message time to be processed
226
+ time.sleep(0.01) # Give the message time to be processed
219
227
 
220
228
  assert len(messages_received1) == 1
221
229
  assert len(messages_received2) == 1
@@ -240,7 +248,7 @@ class BaseTestMessagingABC(ABC):
240
248
  sender.send_message("topic1", MessageConstants.RAW_JSON_FORMAT, {"data": "value1"}, message_id1)
241
249
  sender.send_message("topic2", MessageConstants.RAW_JSON_FORMAT, {"data": "value2"}, message_id2)
242
250
 
243
- time.sleep(1) # Give the message time to be processed
251
+ time.sleep(0.01) # Give the message time to be processed
244
252
 
245
253
  assert len(messages_received) == 2
246
254
  assert messages_received[0].payload == {"data": "value1"}
@@ -411,7 +419,44 @@ class BaseTestMessagingABC(ABC):
411
419
  message_id = generator.get_id(Priority.NORMAL)
412
420
  sender.send_message("topic1", MessageConstants.RAW_JSON_FORMAT, {"data": "value"}, message_id)
413
421
 
414
- time.sleep(1) # Give the message time to be processed
422
+ time.sleep(0.01) # Give the message time to be processed
415
423
 
416
424
  assert len(messages_received) == 1
417
425
  assert len(alt_messages_received) == 0
426
+
427
+ def test_enrich_message(
428
+ self, messaging, alt_messaging, message_publisher, simple_client, simple_client_2, generator
429
+ ):
430
+
431
+ topic = "enrich_topic"
432
+ client, messages_received = simple_client
433
+ messaging.register_client(client)
434
+ messaging.subscribe(topic, client)
435
+
436
+ sender, _ = message_publisher
437
+ messaging.register_client(sender)
438
+ messaging.subscribe(topic, sender)
439
+
440
+ message_id1 = generator.get_id(Priority.NORMAL)
441
+ sender.send_message(topic, MessageConstants.RAW_JSON_FORMAT, {"data": "value"}, message_id1)
442
+
443
+ message_id2 = generator.get_id(Priority.NORMAL)
444
+ history = [
445
+ ProcessEntry(agent=AgentTag(name="test-sender"), origin=message_id1.to_int(), result=message_id2.to_int())
446
+ ]
447
+ sender.send_message(topic, MessageConstants.RAW_JSON_FORMAT, {"data": "value2"}, message_id2, history)
448
+
449
+ message_id3 = generator.get_id(Priority.NORMAL)
450
+ history.append(
451
+ ProcessEntry(agent=AgentTag(name="test-sender"), origin=message_id2.to_int(), result=message_id3.to_int())
452
+ )
453
+ sender.send_message(topic, MessageConstants.RAW_JSON_FORMAT, {"data": "value2"}, message_id3, history, 2)
454
+
455
+ time.sleep(0.01) # Give the message time to be processed
456
+
457
+ assert len(messages_received) == 3
458
+
459
+ prev_msgs = messages_received[2].session_state["enriched_history"]
460
+ assert len(prev_msgs) == 2
461
+ assert Message.from_json(prev_msgs[0]).id == message_id1.to_int()
462
+ assert Message.from_json(prev_msgs[1]).id == message_id2.to_int()