rusticai-testing 1.3.0__tar.gz → 1.4.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 (19) hide show
  1. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/PKG-INFO +2 -2
  2. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/pyproject.toml +2 -3
  3. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/messaging/base_test_backend.py +83 -89
  4. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/README.md +0 -0
  5. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/__init__.py +0 -0
  6. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agent_ext/__init__.py +0 -0
  7. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agent_ext/base_test_kvstore.py +0 -0
  8. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agents/__init__.py +0 -0
  9. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agents/sample_agents.py +0 -0
  10. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agents/simple_agent.py +0 -0
  11. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/execution/__init__.py +0 -0
  12. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/execution/base_test_integration.py +0 -0
  13. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/execution/integration_agents.py +0 -0
  14. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/helpers.py +0 -0
  15. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/messaging/__init__.py +0 -0
  16. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/messaging/base_test_delivery_guarantees.py +0 -0
  17. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/messaging/base_test_messaging.py +0 -0
  18. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/state/__init__.py +0 -0
  19. {rusticai_testing-1.3.0 → rusticai_testing-1.4.0}/src/rustic_ai/testing/state/base_test_state_mgr.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rusticai-testing
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: Test Utilities for Rustic AI Framework
5
5
  License-Expression: Apache-2.0
6
6
  Author: Dragonscale Industries Inc.
@@ -9,7 +9,7 @@ Requires-Python: >=3.13,<3.14
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Programming Language :: Python :: 3.13
11
11
  Requires-Dist: pytest (>=9.1.1,<10.0.0)
12
- Requires-Dist: rusticai-core (>=1.3.0,<1.4.0)
12
+ Requires-Dist: rusticai-core (>=1.4.0,<1.5.0)
13
13
  Project-URL: Homepage, https://www.rustic.ai/
14
14
  Project-URL: Repository, https://github.com/rustic-ai/rustic-ai
15
15
  Project-URL: Rustic AI Core, https://pypi.org/project/rusticai-core/
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
5
5
 
6
6
  [project]
7
7
  name = "rusticai-testing"
8
- version = "1.3.0"
8
+ version = "1.4.0"
9
9
  description = "Test Utilities for Rustic AI Framework"
10
10
  authors = [{name = "Dragonscale Industries Inc.", email = "dev@dragonscale.ai"}]
11
11
  license = "Apache-2.0"
@@ -19,7 +19,7 @@ urls = { Homepage = "https://www.rustic.ai/", Repository = "https://github.com/r
19
19
  packages = [{ include = "rustic_ai", from = "src" }]
20
20
 
21
21
  [tool.poetry.dependencies]
22
- rusticai-core = { version = "1.3.0"}
22
+ rusticai-core = { version = "1.4.0"}
23
23
  pytest = "^9.1.1"
24
24
 
25
25
  [tool.poetry-monorepo.deps]
@@ -67,4 +67,3 @@ lines_between_sections = 1 # For the newline issue
67
67
  known_third_party = ["pydantic", "fastapi", "starlette", "uvicorn", "ray", "dotenv", "openai", "litellm", "pytest", "playwright", "redis", "serpapi", "vertexai"]
68
68
  known_first_party = ["rustic_ai"]
69
69
  known_local_folder = ["core", "rustic_ai.testing"]
70
-
@@ -11,7 +11,7 @@ from rustic_ai.core.messaging.core.message import (
11
11
  Priority,
12
12
  )
13
13
  from rustic_ai.core.messaging.core.messaging_backend import MessagingBackend
14
- from rustic_ai.core.utils.gemstone_id import GemstoneGenerator
14
+ from rustic_ai.core.utils.gemstone_id import EPOCH, GemstoneGenerator, GemstoneID
15
15
 
16
16
 
17
17
  class BaseTestBackendABC(ABC):
@@ -287,99 +287,93 @@ class BaseTestBackendABC(ABC):
287
287
  assert retrieved_message == m4
288
288
 
289
289
  # Test method to get messages since a given message ID ensuring newer messages with higher priority are not lost
290
- def test_get_messages_for_topic_since_with_higher_priority(
291
- self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request
292
- ):
290
+ def test_get_messages_for_topic_since_with_higher_priority(self, backend: MessagingBackend, request):
293
291
  """
294
- Test retrieving messages for a topic since a given message ID ensuring newer messages with higher priority are not lost.
292
+ Verify the Redis/NATS contract for a guild's default topic at a
293
+ priority-inverted timestamp boundary.
295
294
  """
296
- id1 = generator.get_id(Priority.NORMAL)
297
- id2 = generator.get_id(Priority.NORMAL)
298
- id3 = generator.get_id(Priority.NORMAL)
299
- time.sleep(0.001)
300
- id4 = generator.get_id(Priority.NORMAL)
301
- time.sleep(0.001)
302
- id5 = generator.get_id(Priority.NORMAL)
303
- id6 = generator.get_id(Priority.NORMAL)
304
- time.sleep(0.001)
305
- id7 = generator.get_id(Priority.HIGH)
306
- id8 = generator.get_id(Priority.URGENT)
307
-
295
+ base_timestamp = EPOCH + 1_000_000
296
+ boundary = GemstoneID(Priority.NORMAL, base_timestamp, 1, 0)
297
+ same_millisecond = GemstoneID(Priority.NORMAL, base_timestamp, 1, 1)
298
+ later_normal = GemstoneID(Priority.NORMAL, base_timestamp + 1, 1, 0)
299
+ later_high = GemstoneID(Priority.HIGH, base_timestamp + 2, 1, 0)
300
+ later_urgent = GemstoneID(Priority.URGENT, base_timestamp + 3, 1, 0)
301
+
302
+ assert later_high.to_int() < boundary.to_int()
303
+ assert later_urgent.to_int() < boundary.to_int()
304
+
305
+ namespace = f"guild_{request.node.name}"
306
+ topic = f"{namespace}:default_topic"
308
307
  sender = AgentTag(id="senderId", name="sender")
309
308
 
310
- m1 = Message(
311
- topics=topic,
312
- sender=sender,
313
- format=MessageConstants.RAW_JSON_FORMAT,
314
- payload={"key": "m1"},
315
- id_obj=id1,
316
- )
317
- m2 = Message(
318
- topics=topic,
319
- sender=sender,
320
- format=MessageConstants.RAW_JSON_FORMAT,
321
- payload={"key": "m2"},
322
- id_obj=id2,
323
- )
324
- m3 = Message(
325
- topics=topic,
326
- sender=sender,
327
- format=MessageConstants.RAW_JSON_FORMAT,
328
- payload={"key": "m3"},
329
- id_obj=id3,
330
- )
331
- m4 = Message(
332
- topics=topic,
333
- sender=sender,
334
- format=MessageConstants.RAW_JSON_FORMAT,
335
- payload={"key": "m4"},
336
- id_obj=id4,
337
- )
338
- m5 = Message(
339
- topics=topic,
340
- sender=sender,
341
- format=MessageConstants.RAW_JSON_FORMAT,
342
- payload={"key": "m5"},
343
- id_obj=id5,
344
- )
345
- m6 = Message(
346
- topics=topic,
347
- sender=sender,
348
- format=MessageConstants.RAW_JSON_FORMAT,
349
- payload={"key": "m6"},
350
- id_obj=id6,
351
- )
352
- m7 = Message(
353
- topics=topic,
354
- sender=sender,
355
- format=MessageConstants.RAW_JSON_FORMAT,
356
- payload={"key": "m7"},
357
- id_obj=id7,
358
- )
359
- m8 = Message(
360
- topics=topic,
361
- sender=sender,
362
- format=MessageConstants.RAW_JSON_FORMAT,
363
- payload={"key": "m8"},
364
- id_obj=id8,
365
- )
366
-
367
- namespace = request.node.name
368
- # Add messages to the topic
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)
377
-
378
- # Retrieve messages for the topic since a given message ID
379
- retrieved_messages = backend.get_messages_for_topic_since(topic, id3.to_int())
309
+ def make_message(label: str, id_obj: GemstoneID) -> Message:
310
+ return Message(
311
+ topics="default_topic",
312
+ sender=sender,
313
+ format=MessageConstants.RAW_JSON_FORMAT,
314
+ payload={"label": label},
315
+ id_obj=id_obj,
316
+ topic_published_to="default_topic",
317
+ )
380
318
 
381
- # Check the order of the retrieved messages
382
- assert retrieved_messages == [m8, m7, m4, m5, m6]
319
+ fixtures = [
320
+ make_message("boundary", boundary),
321
+ make_message("same_millisecond", same_millisecond),
322
+ make_message("later_normal", later_normal),
323
+ make_message("later_high", later_high),
324
+ make_message("later_urgent", later_urgent),
325
+ ]
326
+ for message in fixtures:
327
+ backend.store_message(namespace, topic, message)
328
+
329
+ retrieved_messages = backend.get_messages_for_topic_since(topic, boundary.to_int())
330
+ actual_ids = [message.id for message in retrieved_messages]
331
+ expected_ids = [
332
+ later_urgent.to_int(),
333
+ later_high.to_int(),
334
+ later_normal.to_int(),
335
+ ]
336
+ returned_details = [
337
+ (
338
+ f"{message.payload['label']}"
339
+ f"(priority={int(message.priority)},"
340
+ f"timestamp={int(message.timestamp)},id={message.id})"
341
+ )
342
+ for message in retrieved_messages
343
+ ]
344
+ assert actual_ids == expected_ids, (
345
+ f"cursor={boundary.to_int()}"
346
+ f"(priority={boundary.priority},timestamp={boundary.timestamp}), "
347
+ f"returned={returned_details}"
348
+ )
349
+ assert all(message.topic_published_to == "default_topic" for message in retrieved_messages)
350
+
351
+ history = backend.get_messages_for_topic(topic)
352
+ assert [message.id for message in history] == [
353
+ later_urgent.to_int(),
354
+ later_high.to_int(),
355
+ boundary.to_int(),
356
+ same_millisecond.to_int(),
357
+ later_normal.to_int(),
358
+ ]
359
+
360
+ by_id = backend.get_messages_by_id(
361
+ namespace,
362
+ [later_high.to_int(), 999999999, boundary.to_int()],
363
+ )
364
+ assert [message.id for message in by_id] == [
365
+ later_high.to_int(),
366
+ boundary.to_int(),
367
+ ]
368
+
369
+ other_namespace = f"{namespace}_other"
370
+ other_topic = f"{other_namespace}:default_topic"
371
+ backend.store_message(
372
+ other_namespace,
373
+ other_topic,
374
+ make_message("other_guild", later_normal),
375
+ )
376
+ assert len(backend.get_messages_for_topic(topic)) == len(fixtures)
383
377
 
384
378
  # Test subscription on a topic
385
379
  def test_subscribe(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request):