Remove all notes resource
This commit is contained in:
@@ -56,19 +56,6 @@ def notes_get_settings():
|
|||||||
return client.notes_get_settings()
|
return client.notes_get_settings()
|
||||||
|
|
||||||
|
|
||||||
@mcp.resource("notes://all")
|
|
||||||
def nc_notes_get_all():
|
|
||||||
"""Get all user notes"""
|
|
||||||
ctx = (
|
|
||||||
mcp.get_context()
|
|
||||||
) # https://github.com/modelcontextprotocol/python-sdk/issues/244
|
|
||||||
client: NextcloudClient = ctx.request_context.lifespan_context.client
|
|
||||||
return client.notes_get_all()
|
|
||||||
|
|
||||||
|
|
||||||
# Removed nc_notes_get_note resource
|
|
||||||
|
|
||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
def nc_get_note(note_id: int, ctx: Context):
|
def nc_get_note(note_id: int, ctx: Context):
|
||||||
"""Get user note using note id"""
|
"""Get user note using note id"""
|
||||||
|
|||||||
+15
-4
@@ -8,6 +8,7 @@ from nextcloud_mcp_server.client import NextcloudClient
|
|||||||
|
|
||||||
# Tests assume NEXTCLOUD_HOST, NEXTCLOUD_USERNAME, NEXTCLOUD_PASSWORD env vars are set
|
# Tests assume NEXTCLOUD_HOST, NEXTCLOUD_USERNAME, NEXTCLOUD_PASSWORD env vars are set
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def nc_client() -> NextcloudClient:
|
def nc_client() -> NextcloudClient:
|
||||||
"""
|
"""
|
||||||
@@ -21,6 +22,7 @@ def nc_client() -> NextcloudClient:
|
|||||||
assert os.getenv("NEXTCLOUD_PASSWORD"), "NEXTCLOUD_PASSWORD env var not set"
|
assert os.getenv("NEXTCLOUD_PASSWORD"), "NEXTCLOUD_PASSWORD env var not set"
|
||||||
return NextcloudClient.from_env()
|
return NextcloudClient.from_env()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.integration
|
@pytest.mark.integration
|
||||||
def test_note_crud_integration(nc_client: NextcloudClient):
|
def test_note_crud_integration(nc_client: NextcloudClient):
|
||||||
"""
|
"""
|
||||||
@@ -33,7 +35,9 @@ def test_note_crud_integration(nc_client: NextcloudClient):
|
|||||||
create_content = f"Content for integration test {unique_id}"
|
create_content = f"Content for integration test {unique_id}"
|
||||||
create_category = "IntegrationTesting"
|
create_category = "IntegrationTesting"
|
||||||
|
|
||||||
created_note = None # Initialize to ensure cleanup happens even if create fails mid-assert
|
created_note = (
|
||||||
|
None # Initialize to ensure cleanup happens even if create fails mid-assert
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
print(f"\nAttempting to create note: {create_title}")
|
print(f"\nAttempting to create note: {create_title}")
|
||||||
created_note = nc_client.notes_create_note(
|
created_note = nc_client.notes_create_note(
|
||||||
@@ -125,7 +129,9 @@ def test_note_crud_integration(nc_client: NextcloudClient):
|
|||||||
with pytest.raises(HTTPStatusError) as excinfo_del:
|
with pytest.raises(HTTPStatusError) as excinfo_del:
|
||||||
nc_client.notes_get_note(note_id=note_id_to_delete)
|
nc_client.notes_get_note(note_id=note_id_to_delete)
|
||||||
assert excinfo_del.value.response.status_code == 404
|
assert excinfo_del.value.response.status_code == 404
|
||||||
print(f"Reading deleted note ID: {note_id_to_delete} correctly failed with 404.")
|
print(
|
||||||
|
f"Reading deleted note ID: {note_id_to_delete} correctly failed with 404."
|
||||||
|
)
|
||||||
|
|
||||||
except HTTPStatusError as e:
|
except HTTPStatusError as e:
|
||||||
# If deletion fails unexpectedly, log it but don't fail the test here
|
# If deletion fails unexpectedly, log it but don't fail the test here
|
||||||
@@ -134,7 +140,10 @@ def test_note_crud_integration(nc_client: NextcloudClient):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Unexpected error during cleanup: {e}")
|
print(f"Unexpected error during cleanup: {e}")
|
||||||
else:
|
else:
|
||||||
print("Skipping delete step as note creation might have failed or ID was not available.")
|
print(
|
||||||
|
"Skipping delete step as note creation might have failed or ID was not available."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.integration
|
@pytest.mark.integration
|
||||||
def test_delete_nonexistent_note(nc_client: NextcloudClient):
|
def test_delete_nonexistent_note(nc_client: NextcloudClient):
|
||||||
@@ -144,4 +153,6 @@ def test_delete_nonexistent_note(nc_client: NextcloudClient):
|
|||||||
with pytest.raises(HTTPStatusError) as excinfo:
|
with pytest.raises(HTTPStatusError) as excinfo:
|
||||||
nc_client.notes_delete_note(note_id=non_existent_id)
|
nc_client.notes_delete_note(note_id=non_existent_id)
|
||||||
assert excinfo.value.response.status_code == 404
|
assert excinfo.value.response.status_code == 404
|
||||||
print(f"Deleting non-existent note ID: {non_existent_id} correctly failed with 404.")
|
print(
|
||||||
|
f"Deleting non-existent note ID: {non_existent_id} correctly failed with 404."
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user