rusticai-testing 1.2.5__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.
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/PKG-INFO +3 -3
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/pyproject.toml +12 -12
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/messaging/base_test_backend.py +88 -98
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/messaging/base_test_delivery_guarantees.py +6 -9
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/README.md +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/__init__.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agent_ext/__init__.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agent_ext/base_test_kvstore.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agents/__init__.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agents/sample_agents.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agents/simple_agent.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/execution/__init__.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/execution/base_test_integration.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/execution/integration_agents.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/helpers.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/messaging/__init__.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/messaging/base_test_messaging.py +0 -0
- {rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/state/__init__.py +0 -0
- {rusticai_testing-1.2.5 → 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
|
+
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.
|
|
@@ -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.
|
|
12
|
-
Requires-Dist: rusticai-core (>=1.
|
|
11
|
+
Requires-Dist: pytest (>=9.1.1,<10.0.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.
|
|
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,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.
|
|
23
|
-
pytest = "^9.
|
|
22
|
+
rusticai-core = { version = "1.4.0"}
|
|
23
|
+
pytest = "^9.1.1"
|
|
24
24
|
|
|
25
25
|
[tool.poetry-monorepo.deps]
|
|
26
26
|
|
|
@@ -28,12 +28,12 @@ pytest = "^9.0.3"
|
|
|
28
28
|
optional = true
|
|
29
29
|
|
|
30
30
|
[tool.poetry.group.dev.dependencies]
|
|
31
|
-
pytest = "^9.
|
|
32
|
-
black = { version = "^26.
|
|
33
|
-
flake8 = "^7.
|
|
34
|
-
tox = "^4.
|
|
35
|
-
isort = "^
|
|
36
|
-
mypy = "^
|
|
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"
|
|
37
37
|
|
|
38
38
|
[tool.black]
|
|
39
39
|
line-length = 120
|
|
@@ -64,6 +64,6 @@ explicit_package_bases = true
|
|
|
64
64
|
profile = "black"
|
|
65
65
|
force_sort_within_sections = true # For the sorting order issues
|
|
66
66
|
lines_between_sections = 1 # For the newline issue
|
|
67
|
-
known_third_party = ["pydantic"]
|
|
68
|
-
known_first_party = ["rustic_ai
|
|
69
|
-
|
|
67
|
+
known_third_party = ["pydantic", "fastapi", "starlette", "uvicorn", "ray", "dotenv", "openai", "litellm", "pytest", "playwright", "redis", "serpapi", "vertexai"]
|
|
68
|
+
known_first_party = ["rustic_ai"]
|
|
69
|
+
known_local_folder = ["core", "rustic_ai.testing"]
|
|
@@ -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
|
-
|
|
292
|
+
Verify the Redis/NATS contract for a guild's default topic at a
|
|
293
|
+
priority-inverted timestamp boundary.
|
|
295
294
|
"""
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
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
|
-
|
|
382
|
-
|
|
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):
|
|
@@ -430,9 +424,7 @@ class BaseTestBackendABC(ABC):
|
|
|
430
424
|
# Per-client subscribe tests (client_id parameter)
|
|
431
425
|
# =========================================================================
|
|
432
426
|
|
|
433
|
-
def test_subscribe_per_client(
|
|
434
|
-
self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request
|
|
435
|
-
):
|
|
427
|
+
def test_subscribe_per_client(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request):
|
|
436
428
|
"""Smoke test: per-client subscribe delivers messages to the registered handler."""
|
|
437
429
|
messages: List[Message] = []
|
|
438
430
|
namespace = request.node.name
|
|
@@ -484,9 +476,7 @@ class BaseTestBackendABC(ABC):
|
|
|
484
476
|
backend.unsubscribe(topic, client_id="client_A")
|
|
485
477
|
backend.unsubscribe(topic, client_id="client_B")
|
|
486
478
|
|
|
487
|
-
def test_unsubscribe_per_client(
|
|
488
|
-
self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request
|
|
489
|
-
):
|
|
479
|
+
def test_unsubscribe_per_client(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, request):
|
|
490
480
|
"""After unsubscribing client_A, only client_B receives subsequent messages."""
|
|
491
481
|
messages_a: List[Message] = []
|
|
492
482
|
messages_b: List[Message] = []
|
|
@@ -599,9 +589,9 @@ class BaseTestBackendABC(ABC):
|
|
|
599
589
|
for i, (msg_id, kind) in enumerate(events):
|
|
600
590
|
if kind == "start" and i > 0:
|
|
601
591
|
prev_msg_id, prev_kind = events[i - 1]
|
|
602
|
-
assert
|
|
603
|
-
|
|
604
|
-
)
|
|
592
|
+
assert (
|
|
593
|
+
prev_kind == "end"
|
|
594
|
+
), f"Found concurrent processing: event[{i - 1}]={events[i - 1]}, event[{i}]={events[i]}"
|
|
605
595
|
|
|
606
596
|
backend.unsubscribe(topic, client_id="client_A")
|
|
607
597
|
|
|
@@ -83,9 +83,7 @@ class BaseTestBackendDeliveryGuarantees(ABC):
|
|
|
83
83
|
|
|
84
84
|
backend.unsubscribe(topic, client_id="eo_client")
|
|
85
85
|
|
|
86
|
-
def test_backlog_replay(
|
|
87
|
-
self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, namespace: str
|
|
88
|
-
):
|
|
86
|
+
def test_backlog_replay(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, namespace: str):
|
|
89
87
|
"""
|
|
90
88
|
Store 3 messages BEFORE subscribing, then subscribe and verify all 3 are delivered.
|
|
91
89
|
"""
|
|
@@ -115,9 +113,7 @@ class BaseTestBackendDeliveryGuarantees(ABC):
|
|
|
115
113
|
|
|
116
114
|
backend.unsubscribe(topic, client_id="backlog_client")
|
|
117
115
|
|
|
118
|
-
def test_crash_recovery(
|
|
119
|
-
self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, namespace: str
|
|
120
|
-
):
|
|
116
|
+
def test_crash_recovery(self, backend: MessagingBackend, generator: GemstoneGenerator, topic: str, namespace: str):
|
|
121
117
|
"""
|
|
122
118
|
Subscribe, process 3 messages, unsubscribe (simulate crash), store 2 more,
|
|
123
119
|
re-subscribe with SAME client_id, verify exactly 2 new messages delivered.
|
|
@@ -220,9 +216,10 @@ class BaseTestBackendDeliveryGuarantees(ABC):
|
|
|
220
216
|
assert delivery_event.wait(timeout=10.0), "Expected later messages to keep flowing after dead-lettering"
|
|
221
217
|
|
|
222
218
|
with lock:
|
|
223
|
-
assert received == [
|
|
224
|
-
|
|
225
|
-
|
|
219
|
+
assert received == [
|
|
220
|
+
msgs[1].id,
|
|
221
|
+
msgs[2].id,
|
|
222
|
+
], f"Expected only later messages to be delivered successfully, got {received}"
|
|
226
223
|
first_msg_id = msgs[0].id
|
|
227
224
|
assert call_counts.get(first_msg_id, 0) == 1, "Failed message should not be retried after dead-lettering"
|
|
228
225
|
assert len(dead_letters) == 1, f"Expected one dead-letter message, got {len(dead_letters)}"
|
|
File without changes
|
|
File without changes
|
{rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agent_ext/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agents/sample_agents.py
RENAMED
|
File without changes
|
{rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/agents/simple_agent.py
RENAMED
|
File without changes
|
{rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/execution/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/messaging/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rusticai_testing-1.2.5 → rusticai_testing-1.4.0}/src/rustic_ai/testing/state/base_test_state_mgr.py
RENAMED
|
File without changes
|