test(agno-moss): add offline unit tests for runtime

AM
5d ago
+344-0

Pull Request Checklist

Please ensure that your PR meets the following requirements:

  • I have read the CONTRIBUTING guide.
  • I have updated the documentation (if applicable).
  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Description

Adds a complete, fast (<0.2s), and fully offline test suite for packages/agno-moss using pytest, pytest-asyncio, and an AsyncMock-backed MossClient.

Scope of Coverage:

  • Round-trip document mapping: Verifies _to_moss_doc() and _to_document() preserve id, text/content, metadata, content_hash, and score mapping.
  • Insert / Upsert: Tests index auto-creation when missing, add_docs delegation with upsert=True when present, and empty list no-op.
  • Search: Tests search and async_search option forwarding (top_k, alpha, filters) and result mapping to agno Document objects.
  • Existence checks: exists(), async_exists(), name_exists(), id_exists(), and content_hash_exists().
  • Lifecycle & Deletions: create(), drop(), delete(), delete_by_id(), and no-op / unsupported deletion fallbacks.
  • Sync execution wrapper: Confirms _run() works seamlessly both outside and inside an active asyncio event loop.

Partially addresses #521 (agno-moss component).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Summary by CodeRabbit

  • Tests
    • Added coverage for runtime initialization, synchronous and asynchronous operations, document handling, search, and index lifecycle behavior.
    • Added checks for missing credentials, empty upserts, unloaded-index content checks, and unsupported deletion methods.