test(notes): Modify tests with updated error handling
This commit is contained in:
@@ -102,13 +102,19 @@ Each Nextcloud app has a corresponding server module that:
|
|||||||
- **Important**: Integration tests run against live Docker containers. After making code changes to the MCP server, rebuild only the MCP container with `docker-compose up --build -d mcp` before running tests
|
- **Important**: Integration tests run against live Docker containers. After making code changes to the MCP server, rebuild only the MCP container with `docker-compose up --build -d mcp` before running tests
|
||||||
|
|
||||||
#### Testing Best Practices
|
#### Testing Best Practices
|
||||||
- **Always restart MCP server** after code changes with `docker-compose up --build -d mcp`
|
- **MANDATORY: Always run tests after implementing features or fixing bugs**
|
||||||
|
- Run tests to completion before considering any task complete
|
||||||
|
- If tests require modifications to pass, ask for permission before proceeding
|
||||||
|
- Use `docker-compose up --build -d mcp` to rebuild MCP container after code changes
|
||||||
- **Use existing fixtures** from `tests/conftest.py` to avoid duplicate setup work:
|
- **Use existing fixtures** from `tests/conftest.py` to avoid duplicate setup work:
|
||||||
- `nc_mcp_client` - MCP client session for tool/resource testing
|
- `nc_mcp_client` - MCP client session for tool/resource testing
|
||||||
- `nc_client` - Direct NextcloudClient for setup/cleanup operations
|
- `nc_client` - Direct NextcloudClient for setup/cleanup operations
|
||||||
- `temporary_note` - Creates and cleans up test notes automatically
|
- `temporary_note` - Creates and cleans up test notes automatically
|
||||||
- `temporary_addressbook` - Creates and cleans up test address books
|
- `temporary_addressbook` - Creates and cleans up test address books
|
||||||
- `temporary_contact` - Creates and cleans up test contacts
|
- `temporary_contact` - Creates and cleans up test contacts
|
||||||
|
- **Test specific functionality** after changes:
|
||||||
|
- For Notes changes: `uv run pytest tests/integration/test_mcp.py -k "notes" -v`
|
||||||
|
- For specific API changes: `uv run pytest tests/integration/test_notes_api.py -v`
|
||||||
- **Avoid creating standalone test scripts** - use pytest with proper fixtures instead
|
- **Avoid creating standalone test scripts** - use pytest with proper fixtures instead
|
||||||
|
|
||||||
### Configuration Files
|
### Configuration Files
|
||||||
|
|||||||
@@ -334,10 +334,13 @@ async def test_mcp_notes_etag_conflict(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# 4. Verify the update was rejected with a 412 error
|
# 4. Verify the update was rejected with a 412 error
|
||||||
assert conflict_result.isError is True, "Update with stale ETag should fail"
|
# The MCP framework doesn't set isError=True for ErrorResponse, so check the response content
|
||||||
error_content = conflict_result.content[0].text
|
response_content = conflict_result.content[0].text
|
||||||
assert "modified by someone else" in error_content or "412" in error_content, (
|
response_data = json.loads(response_content)
|
||||||
f"Expected conflict error message, got: {error_content}"
|
|
||||||
|
assert response_data["success"] is False, "Update with stale ETag should fail"
|
||||||
|
assert "modified by someone else" in response_data["error"], (
|
||||||
|
f"Expected conflict error message, got: {response_data}"
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info("Successfully verified ETag conflict handling via MCP")
|
logger.info("Successfully verified ETag conflict handling via MCP")
|
||||||
|
|||||||
Reference in New Issue
Block a user