Skip to content

Add unit tests for document API methods#5

Merged
harell merged 2 commits intomasterfrom
feature/test-documents-endpoints
Sep 25, 2025
Merged

Add unit tests for document API methods#5
harell merged 2 commits intomasterfrom
feature/test-documents-endpoints

Conversation

@harell
Copy link
Contributor

@harell harell commented Sep 25, 2025

This pull request introduces a comprehensive suite of tests for the document-related API endpoints in the templafy package. It also adds new test fixtures and updates dependencies to support HTTPX-based testing. The most important changes are grouped below by theme.

Testing for Document API Endpoints:

  • Added tests for creating documents, ensuring the API returns the expected document payload. (tests/templafy/api/documents/test_create.py)
  • Added tests for deleting documents by ID, verifying the API returns None on successful deletion (HTTP 204). (tests/templafy/api/documents/test_delete_by_id.py)
  • Added tests for generating documents, checking that the API returns the correct payload and download URL. (tests/templafy/api/documents/test_generate.py)
  • Added tests for retrieving documents by ID and listing documents in a folder, confirming correct parsing and payload structure. (tests/templafy/api/documents/test_get_by_id.py, tests/templafy/api/documents/test_list_in_folder.py) [1] [2]
  • Added tests for updating documents, ensuring the API returns None on successful update (HTTP 204). (tests/templafy/api/documents/test_update.py)

Test Infrastructure and Fixtures:

  • Added the pytest-httpx dependency to pyproject.toml to enable HTTPX mocking in tests.
  • Renamed the authenticated client fixture for clarity and added a new fixture for sample document data. (tests/conftest.py) [1] [2]

Copilot AI review requested due to automatic review settings September 25, 2025 02:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive unit tests for document-related API endpoints in the templafy package, establishing test coverage for core document operations including create, read, update, delete, list, and generate functionality.

  • Adds unit tests for 6 document API endpoints with proper HTTP status code validation
  • Introduces HTTPX mocking infrastructure with pytest-httpx dependency
  • Creates shared test fixtures for document data and renames client fixture for clarity

Reviewed Changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/templafy/api/documents/test_create.py Tests document creation endpoint with file upload mock
tests/templafy/api/documents/test_delete_by_id.py Tests document deletion endpoint expecting None on HTTP 204
tests/templafy/api/documents/test_generate.py Tests document generation endpoint with payload validation
tests/templafy/api/documents/test_get_by_id.py Tests document retrieval by ID endpoint
tests/templafy/api/documents/test_list_in_folder.py Tests listing documents in folder endpoint
tests/templafy/api/documents/test_update.py Tests document update endpoint expecting None on HTTP 204
tests/conftest.py Renames client fixture and adds sample document test data
pyproject.toml Adds pytest-httpx dependency for HTTP mocking

@t-t-sonarqube
Copy link

t-t-sonarqube bot commented Sep 25, 2025

@harell harell merged commit 89e1409 into master Sep 25, 2025
15 checks passed
@harell harell deleted the feature/test-documents-endpoints branch September 25, 2025 02:49
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.

2 participants