Skip to content

Commit ceabba6

Browse files
hifaizskclaude
andcommitted
test: add retention policy endpoint tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2a7b944 commit ceabba6

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

tests/test_chat_misc.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,3 +600,53 @@ def test_event_hooks_sqs_sns(client: Stream):
600600
finally:
601601
# Restore original hooks
602602
client.update_app(event_hooks=original_hooks or [])
603+
604+
605+
def test_set_retention_policy(client: Stream):
606+
"""Set a retention policy for old messages."""
607+
try:
608+
response = client.chat.set_retention_policy(
609+
policy="old-messages", max_age_hours=720
610+
)
611+
assert response.data is not None
612+
assert response.data.policy is not None
613+
assert response.data.policy.policy == "old-messages"
614+
finally:
615+
try:
616+
client.chat.delete_retention_policy(policy="old-messages")
617+
except Exception:
618+
pass
619+
620+
621+
def test_get_retention_policy(client: Stream):
622+
"""Get retention policies."""
623+
# First set a policy to ensure there's something to get
624+
client.chat.set_retention_policy(policy="old-messages", max_age_hours=720)
625+
626+
try:
627+
response = client.chat.get_retention_policy()
628+
assert response.data is not None
629+
assert response.data.policies is not None
630+
assert len(response.data.policies) > 0
631+
finally:
632+
try:
633+
client.chat.delete_retention_policy(policy="old-messages")
634+
except Exception:
635+
pass
636+
637+
638+
def test_get_retention_policy_runs(client: Stream):
639+
"""Get retention policy run history."""
640+
response = client.chat.get_retention_policy_runs()
641+
assert response.data is not None
642+
assert response.data.runs is not None
643+
644+
645+
def test_delete_retention_policy(client: Stream):
646+
"""Delete a retention policy."""
647+
# First set a policy, then delete it
648+
client.chat.set_retention_policy(policy="old-messages", max_age_hours=720)
649+
650+
response = client.chat.delete_retention_policy(policy="old-messages")
651+
assert response.data is not None
652+
assert response.data.duration is not None

0 commit comments

Comments
 (0)