Skip to content

feat(tests): Expand unit test coverage for core SDK operations#12

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/expand-unit-test-coverage
Draft

feat(tests): Expand unit test coverage for core SDK operations#12
Copilot wants to merge 2 commits intomainfrom
copilot/expand-unit-test-coverage

Conversation

Copy link

Copilot AI commented Feb 27, 2026

Both SDKs lacked unit tests for core operations (register, update, get, getHistory/get_history, getAssetTree/get_asset_tree, searchNft/search_nft), relying solely on integration tests to catch regressions.

TypeScript — ts/src/client.test.ts

  • 47 new tests (15 → 62 total) across 6 new describe blocks
  • Covers: HTTP method, URL/query-param construction, Authorization header, request body format (multipart vs. JSON), response parsing, and error type mapping (401 → AuthenticationError, 404 → NotFoundError, 500 → NetworkError)
  • getAssetTree tests verify the two-step fetch sequence (history → merge) and correct commit data forwarding
  • normalizeFile tested indirectly via register with Uint8Array, Blob, and missing-filename error paths

Python — python/tests/test_core_operations.py (new file)

  • 53 new tests using respx mocks, matching parity with TypeScript coverage
  • Dedicated TestNormalizeFile class covering str/Path/bytes/bytearray inputs, nonexistent path errors, MIME inference across common extensions, and application/octet-stream fallback
  • URL-encoded form bodies decoded with unquote_plus for accurate field assertions

Coverage delta

Before After
Python (total) 71% 89%
client.py 50% 82%
TypeScript tests 15 62
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature][Medium] Expand unit test coverage for core SDK operations</issue_title>
<issue_description>## Summary

The current test suites in both Python and TypeScript SDKs only cover initialization, validation, and searchAsset() request/response handling. Core operations that interact with the API lack unit tests with mocked HTTP responses.

Missing Test Coverage

Both SDKs:

  • register() — No tests verifying multipart form construction, signing flow, or file normalization with mocked API
  • update() — No tests verifying PATCH request construction or metadata serialization
  • get() — No tests verifying GET request and response parsing
  • getHistory() / get_history() — No tests verifying history API URL construction, query parameters (especially testnet flag), or commit response parsing
  • getAssetTree() / get_asset_tree() — No tests verifying the two-step flow (history fetch → merge request) or AssetTree response parsing
  • searchNft() / search_nft() — No tests verifying NFT search request or response parsing

Python-specific:

  • python/tests/test_asset_search.py and python/tests/test_asset_tree.py exist but only cover searchAsset and getAssetTree partially
  • No tests for _normalize_file() with Path objects or error cases

TypeScript-specific:

  • ts/src/client.test.ts only tests searchAsset request/response and constructor validation
  • No tests for normalizeFile() with different input types (File, Blob, Buffer)

Suggested Approach

  1. For each untested method, create test cases that:

    • Mock the HTTP client (respx for Python, vi.fn for fetch in TypeScript)
    • Verify correct URL construction and headers
    • Verify request body format (multipart, JSON, query params)
    • Verify response parsing into typed SDK objects
    • Test error handling for various HTTP status codes
  2. Aim for >80% line coverage across both SDKs.

Priority

Medium — the SDK works correctly based on integration testing, but unit tests would catch regressions faster and improve contributor confidence.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- TypeScript: add 47 new tests for register, update, get, getHistory,
  getAssetTree, searchNft, and normalizeFile (15 → 62 total tests)
- Python: add 53 new tests in test_core_operations.py covering register,
  update, get, get_history, search_nft, and _normalize_file edge cases
- Python coverage improved from 71% to 89% (client.py: 50% → 82%)
- All tests mock HTTP responses; no real network calls made

Co-authored-by: numbers-official <181934381+numbers-official@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests for core SDK operations feat(tests): Expand unit test coverage for core SDK operations Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature][Medium] Expand unit test coverage for core SDK operations

2 participants