Back to list
colingwuyu

sdk-e2e-testing

by colingwuyu

0🍴 0📅 Jan 7, 2026

SKILL.md


name: sdk-e2e-testing description: Strategy and patterns for designing and implementing End-to-End scenario tests using the Python SDK. Focuses on full-stack verification and SDK usability.

E2E SDK Scenario Testing

This skill guides the design and implementation of end-to-end tests using the Python SDK.

Goal

  1. Verify System Correctness: Test the full stack (SDK → API → Database).
  2. Validate SDK Design: Ensure the SDK is intuitive and user-friendly.

Phase 1: Scenario Discovery

1. Identify Business Domain Features

Review the implemented features to identify testable scenarios. Map features to user workflows:

Feature AreaUser WorkflowSDK Methods
AuthenticationAPI key managementauth.create_api_key(), auth.revoke_api_key(), auth.get_current_user()
Data PipelinesIngest economic datapipelines.submit_definition(), pipelines.create_instance()
ExperimentsExplore expressionsexperiments.create(), experiments.run()
SignalsRegister alpha signalssignals.create(), signals.validate()
ResourcesOrganize workresources.create(), resources.move()
RBACControl accessrbac.grant_role(), rbac.list_grants()
ChatCollaboratechat.create_channel(), chat.send_message()
VersioningTrack changesrefs.create_branch(), refs.merge()

2. Design Case Study Scenarios

Each case study should represent a coherent business workflow, not isolated operations.

Good Scenario Design:

"Quantitative Researcher Daily Workflow: Create project, run experiment, save macro, register signal, verify audit."

Bad Scenario Design:

"Test Create Resource, Test Update Resource, Test Delete Resource" (Isolated operations)

3. Scenario Coverage Matrix

Ensure scenarios cover all dimensions:

  • CRUD Operations (Create, Read, Update, Delete)
  • Business Logic (Validation, status transitions)
  • Cross-Resource (Relationships, lineage)
  • RBAC (Permission checks)
  • Audit (Activity emission)
  • Error Cases (Invalid inputs, permission denied)

Phase 2: Infrastructure & Patterns

Refer to the following references for implementation details:


Phase 3: SDK Design Feedback

Capture Improvement Opportunities

Create a tracking section in test files to document:

  1. Issues Found: Missing fields, confusing names, inconsistent behavior.
  2. Positive Patterns: Things that work well.

Improvement Workflow

  1. Document issue in comments.
  2. Create minimal repro test.
  3. Propose fix (schema change, new helper).
  4. Implement fix.
  5. Verify.

Phase 4: Running Tests

# Run all E2E tests
uv run pytest tests/e2e/ -xvs

# Run specific case study
uv run pytest tests/e2e/test_case_studies.py::TestCaseStudy1_FREDEconomicData -xvs

# Run with coverage
uv run pytest tests/e2e/ --cov=libs/sdk_py --cov-report=term-missing

Maintenance Rules

  • No Mocks: Use real SDK → API → DB.
  • Independent Tests: Each test creates its own data.
  • Clean Assertions: Assert business outcomes.

Authentication Testing Patterns

Test Setup with Dev Auth

For E2E tests, use dev mode authentication with ASGI transport:

@pytest_asyncio.fixture(scope="function")
async def sdk_client():
    """Create an AsyncPlatformClient using ASGI transport."""
    httpx_client = AsyncClient(
        transport=ASGITransport(app=app),
        base_url="http://test",
    )
    client = AsyncPlatformClient(
        base_url="http://test",
        client=httpx_client,
    )
    yield client
    await client.close()

@pytest_asyncio.fixture(scope="function")
async def auth_test_setup(sdk_client):
    """Set up tenant and principal for auth testing."""
    tenant_id = uuid4()
    principal_id = uuid4()

    sdk_client.set_principal_id(principal_id)
    sdk_client.set_tenant_id(tenant_id)

    # Create tenant (creates principal implicitly)
    await sdk_client.tenants.create(name=f"TestTenant-{tenant_id}")

    return {"client": sdk_client, "tenant_id": tenant_id, "principal_id": principal_id}

API Key Testing Scenarios

ScenarioWhat to Test
API Key CRUDCreate, list, get, revoke
API Key AuthUse key to authenticate new client
Key RevocationRevoked key fails authentication
Multiple KeysMultiple keys work independently
Key ExpiryExpired keys fail authentication

Example: API Key Authentication Test

@pytest.mark.asyncio
async def test_authenticate_with_api_key(auth_test_setup):
    """Test authenticating with an API key."""
    client = auth_test_setup["client"]

    # Create API key with dev auth
    created = await client.auth.create_api_key(name="Test Key")
    full_key = created["key"]

    # Create new client using the API key
    api_key_client = AsyncPlatformClient(
        base_url="http://test",
        api_key=full_key,
        client=AsyncClient(
            transport=ASGITransport(app=app),
            base_url="http://test",
        ),
    )

    try:
        user_info = await api_key_client.auth.get_current_user()
        assert user_info["auth_method"] == "api_key"
    finally:
        await api_key_client.close()

Reference Test File

See tests/e2e/test_auth_e2e.py for complete authentication E2E tests:

  • 17 API key tests
  • 8 session login/logout tests

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon