rusticai-testing 1.3.0__tar.gz → 1.5.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.5.0}/PKG-INFO +3 -3
  2. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/pyproject.toml +10 -11
  3. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/messaging/base_test_backend.py +84 -89
  4. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/README.md +0 -0
  5. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/__init__.py +0 -0
  6. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/agent_ext/__init__.py +0 -0
  7. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/agent_ext/base_test_kvstore.py +0 -0
  8. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/agents/__init__.py +0 -0
  9. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/agents/sample_agents.py +0 -0
  10. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/agents/simple_agent.py +0 -0
  11. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/execution/__init__.py +0 -0
  12. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/execution/base_test_integration.py +0 -0
  13. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/execution/integration_agents.py +0 -0
  14. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/helpers.py +0 -0
  15. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/messaging/__init__.py +0 -0
  16. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/messaging/base_test_delivery_guarantees.py +0 -0
  17. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/messaging/base_test_messaging.py +0 -0
  18. {rusticai_testing-1.3.0 → rusticai_testing-1.5.0}/src/rustic_ai/testing/state/__init__.py +0 -0
  19. {rusticai_testing-1.3.0 → rusticai_testing-1.5.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.5.0
4
4
  Summary: Test Utilities for Rustic AI Framework
5
5
  License-Expression: Apache-2.0
6
6
  Author: Dragonscale Industries Inc.
@@ -8,8 +8,8 @@ Author-email: dev@dragonscale.ai
8
8
  Requires-Python: >=3.13,<3.14
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Programming Language :: Python :: 3.13
11
- Requires-Dist: pytest (>=9.1.1,<10.0.0)
12
- Requires-Dist: rusticai-core (>=1.3.0,<1.4.0)
11
+ Requires-Dist: pytest (>=9.2.0,<10.0.0)
12
+ Requires-Dist: rusticai-core (>=1.5.0,<1.6.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/
@@ -1,11 +1,11 @@
1
1
  [build-system]
2
- requires = ["poetry-core"]
2
+ requires = ["poetry-core>=2.5.0,<3.0.0"]
3
3
  build-backend = "poetry.core.masonry.api"
4
4
 
5
5
 
6
6
  [project]
7
7
  name = "rusticai-testing"
8
- version = "1.3.0"
8
+ version = "1.5.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,8 +19,8 @@ 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"}
23
- pytest = "^9.1.1"
22
+ rusticai-core = { version = "1.5.0"}
23
+ pytest = "^9.2.0"
24
24
 
25
25
  [tool.poetry-monorepo.deps]
26
26
 
@@ -28,12 +28,12 @@ pytest = "^9.1.1"
28
28
  optional = true
29
29
 
30
30
  [tool.poetry.group.dev.dependencies]
31
- pytest = "^9.1.1"
32
- black = { version = "^26.5.1", extras = ["jupyter"] }
33
- flake8 = "^7.3.0"
34
- tox = "^4.57.1"
35
- isort = "^8.0.1"
36
- mypy = "^2.3.0"
31
+ pytest = "^9.2.0"
32
+ black = { version = "^26.10.1", extras = ["jupyter"] }
33
+ flake8 = "^7.5.0"
34
+ tox = "^4.67.16"
35
+ isort = "^9.0.2"
36
+ mypy = "^2.4.1"
37
37
 
38
38
  [tool.black]
39
39
  line-length = 120
@@ -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
-
@@ -1,6 +1,7 @@
1
1
  from abc import ABC
2
2
  import time
3
3
  from typing import List
4
+ from uuid import uuid4
4
5
 
5
6
  import pytest
6
7
 
@@ -11,7 +12,7 @@ from rustic_ai.core.messaging.core.message import (
11
12
  Priority,
12
13
  )
13
14
  from rustic_ai.core.messaging.core.messaging_backend import MessagingBackend
14
- from rustic_ai.core.utils.gemstone_id import GemstoneGenerator
15
+ from rustic_ai.core.utils.gemstone_id import EPOCH, GemstoneGenerator, GemstoneID
15
16
 
16
17
 
17
18
  class BaseTestBackendABC(ABC):
@@ -287,99 +288,93 @@ class BaseTestBackendABC(ABC):
287
288
  assert retrieved_message == m4
288
289
 
289
290
  # 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
- ):
291
+ def test_get_messages_for_topic_since_with_higher_priority(self, backend: MessagingBackend, request):
293
292
  """
294
- Test retrieving messages for a topic since a given message ID ensuring newer messages with higher priority are not lost.
293
+ Verify the Redis/NATS contract for a guild's default topic at a
294
+ priority-inverted timestamp boundary.
295
295
  """
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
-
296
+ base_timestamp = EPOCH + 1_000_000
297
+ boundary = GemstoneID(Priority.NORMAL, base_timestamp, 1, 0)
298
+ same_millisecond = GemstoneID(Priority.NORMAL, base_timestamp, 1, 1)
299
+ later_normal = GemstoneID(Priority.NORMAL, base_timestamp + 1, 1, 0)
300
+ later_high = GemstoneID(Priority.HIGH, base_timestamp + 2, 1, 0)
301
+ later_urgent = GemstoneID(Priority.URGENT, base_timestamp + 3, 1, 0)
302
+
303
+ assert later_high.to_int() < boundary.to_int()
304
+ assert later_urgent.to_int() < boundary.to_int()
305
+
306
+ namespace = f"guild_{request.node.name}_{uuid4().hex}"
307
+ topic = f"{namespace}:default_topic"
308
308
  sender = AgentTag(id="senderId", name="sender")
309
309
 
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())
310
+ def make_message(label: str, id_obj: GemstoneID) -> Message:
311
+ return Message(
312
+ topics="default_topic",
313
+ sender=sender,
314
+ format=MessageConstants.RAW_JSON_FORMAT,
315
+ payload={"label": label},
316
+ id_obj=id_obj,
317
+ topic_published_to="default_topic",
318
+ )
380
319
 
381
- # Check the order of the retrieved messages
382
- assert retrieved_messages == [m8, m7, m4, m5, m6]
320
+ fixtures = [
321
+ make_message("boundary", boundary),
322
+ make_message("same_millisecond", same_millisecond),
323
+ make_message("later_normal", later_normal),
324
+ make_message("later_high", later_high),
325
+ make_message("later_urgent", later_urgent),
326
+ ]
327
+ for message in fixtures:
328
+ backend.store_message(namespace, topic, message)
329
+
330
+ retrieved_messages = backend.get_messages_for_topic_since(topic, boundary.to_int())
331
+ actual_ids = [message.id for message in retrieved_messages]
332
+ expected_ids = [
333
+ later_urgent.to_int(),
334
+ later_high.to_int(),
335
+ later_normal.to_int(),
336
+ ]
337
+ returned_details = [
338
+ (
339
+ f"{message.payload['label']}"
340
+ f"(priority={int(message.priority)},"
341
+ f"timestamp={int(message.timestamp)},id={message.id})"
342
+ )
343
+ for message in retrieved_messages
344
+ ]
345
+ assert actual_ids == expected_ids, (
346
+ f"cursor={boundary.to_int()}"
347
+ f"(priority={boundary.priority},timestamp={boundary.timestamp}), "
348
+ f"returned={returned_details}"
349
+ )
350
+ assert all(message.topic_published_to == "default_topic" for message in retrieved_messages)
351
+
352
+ history = backend.get_messages_for_topic(topic)
353
+ assert [message.id for message in history] == [
354
+ later_urgent.to_int(),
355
+ later_high.to_int(),
356
+ boundary.to_int(),
357
+ same_millisecond.to_int(),
358
+ later_normal.to_int(),
359
+ ]
360
+
361
+ by_id = backend.get_messages_by_id(
362
+ namespace,
363
+ [later_high.to_int(), 999999999, boundary.to_int()],
364
+ )
365
+ assert [message.id for message in by_id] == [
366
+ later_high.to_int(),
367
+ boundary.to_int(),
368
+ ]
369
+
370
+ other_namespace = f"{namespace}_other"
371
+ other_topic = f"{other_namespace}:default_topic"
372
+ backend.store_message(
373
+ other_namespace,
374
+ other_topic,
375
+ make_message("other_guild", later_normal),
376
+ )
377
+ assert len(backend.get_messages_for_topic(topic)) == len(fixtures)
383
378
 
384
379
  # Test subscription on a topic
385
380
  def test_subscribe(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request):