Skip to main content
from praisonaiagents import Agent

agent = Agent(name="test-agent", instructions="Run platform client SDK tests.")
agent.start("Run the full SDK test suite and report results.")
Run integration tests against the real FastAPI app to verify every PlatformClient endpoint and RBAC rule.
pip install praisonai-platform pytest pytest-asyncio httpx
pytest praisonai_platform/tests/ -v
import pytest
from praisonai_platform.client import PlatformClient

@pytest.mark.asyncio
async def test_register_and_workspace():
    client = PlatformClient("http://localhost:8000")
    await client.register("test@example.com", "password")
    workspace = await client.create_workspace("Test Workspace")
    assert workspace["name"] == "Test Workspace"
The user asks the agent to run SDK tests; pytest exercises every PlatformClient endpoint.

Quick Start

1

Simple Usage

Start the platform server, then run client tests:
python -m praisonai_platform --port 8000 &
pytest praisonai_platform/tests/test_client.py -v
2

With Configuration

Test against the in-process FastAPI app with ASGITransport — no server required:
import pytest
import httpx
from httpx import ASGITransport
from praisonai_platform.api.app import create_app
from praisonai_platform.client import PlatformClient

@pytest.mark.asyncio
async def test_full_lifecycle():
    app = create_app()
    transport = ASGITransport(app=app)

    async with httpx.AsyncClient(transport=transport, base_url="http://test") as http:
        client = PlatformClient("http://test")
        await client.register("user@test.com", "password")
        workspace = await client.create_workspace("My Workspace")
        assert workspace["name"] == "My Workspace"

How It Works

LayerPurpose
pytest-asyncioAsync test runner
ASGITransportIn-memory requests against the real app
PlatformClientHTTP wrapper with auto-authentication
SQLite memoryIsolated database per test run

Test Coverage

AreaEndpointsVerification
Authentication/auth/register, /auth/login, /auth/meJWT returned, user retrieved
WorkspacesCRUD on /workspaces/Owner membership enforced
ProjectsCRUD on /workspaces/{id}/projects/Scoped to workspace
IssuesCRUD on /workspaces/{id}/issues/Issue numbers assigned
RBACAll workspace-scoped routesNon-members receive 403

RBAC enforcement test

import pytest
import httpx
from praisonai_platform.client import PlatformClient

@pytest.mark.asyncio
async def test_nonmember_blocked():
    member = PlatformClient("http://localhost:8000")
    await member.register("member@test.com", "password")
    workspace = await member.create_workspace("RBAC Test")

    outsider = PlatformClient("http://localhost:8000")
    await outsider.register("outsider@test.com", "password")

    with pytest.raises(httpx.HTTPStatusError) as exc:
        await outsider.get_workspace(workspace["id"])
    assert exc.value.response.status_code == 403

Best Practices

Configure SQLite with :memory: in test fixtures for fast, isolated runs.
Use ASGITransport(app=create_app()) so tests exercise actual route logic and dependencies.
Assert 403 for non-members on projects, issues, agents, labels, and dependencies.
Use f"test-{uuid.uuid4()}@example.com" per test to avoid collisions.

Platform SDK Client

Complete PlatformClient API reference

RBAC Enforcement

Workspace membership and role checks