Skip to content

Add test suite — mock-based, enforce correct collection move format #4

Description

@simonives

Summary

There are currently no tests. The core correctness claim of this project — that collection moves use {"collection": {"$id": n}} and not {"collectionId": n} — is not programmatically enforced.

What to test

Priority 1 — the fix itself:

async def test_update_raindrop_uses_nested_collection_format():
    """The collection move fix: must send {"collection": {"$id": n}}, never {"collectionId": n}."""
    with respx.mock() as mock:
        mock.put("https://api.raindrop.io/rest/v1/raindrop/123").respond(200, json={"item": {}})
        client = RaindropClient()
        await client.update_raindrop(123, collection_id=456)
        request_body = json.loads(mock.calls[0].request.content)
        assert request_body["collection"] == {"$id": 456}
        assert "collectionId" not in request_body

async def test_bulk_move_uses_nested_collection_format():
    with respx.mock() as mock:
        mock.put("https://api.raindrop.io/rest/v1/raindrops/0").respond(200, json={})
        client = RaindropClient()
        await client.bulk_move(0, [1, 2, 3], 456)
        request_body = json.loads(mock.calls[0].request.content)
        assert request_body["collection"] == {"$id": 456}
        assert "collectionId" not in request_body

Priority 2 — happy path for each tool group (collections, raindrops, bulk, search, tags).

Stack suggestion

  • pytest + pytest-asyncio for async tests
  • respx for mocking httpx at the transport level (cleaner than unittest.mock)

Notes

These tests should run in CI without a real Raindrop.io token. The mock enforces the API contract, not the live service.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions