Skip to content

Commit 50c1215

Browse files
neovaskyclaude
andcommitted
fix: apply ruff formatting to test_webdav_operations.py
- Fix quote style from single to double quotes - Improve line breaks and spacing for better readability - Address CI formatting requirements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent bf5879d commit 50c1215

File tree

1 file changed

+59
-57
lines changed

1 file changed

+59
-57
lines changed

tests/integration/test_webdav_operations.py

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,28 @@ def test_base_path():
1919
return f"mcp_test_{uuid.uuid4().hex[:8]}"
2020

2121

22-
async def test_create_and_delete_directory(nc_client: NextcloudClient, test_base_path: str):
22+
async def test_create_and_delete_directory(
23+
nc_client: NextcloudClient, test_base_path: str
24+
):
2325
"""Test creating and deleting directories."""
2426
test_dir = f"{test_base_path}/test_directory"
25-
27+
2628
try:
2729
# Create directory
2830
result = await nc_client.webdav.create_directory(test_dir)
2931
assert result["status_code"] == 201 # Created
3032
logger.info(f"Created directory: {test_dir}")
31-
33+
3234
# Verify directory exists by listing parent
3335
parent_listing = await nc_client.webdav.list_directory(test_base_path)
3436
dir_names = [item["name"] for item in parent_listing]
3537
assert "test_directory" in dir_names
36-
38+
3739
# Delete directory
3840
delete_result = await nc_client.webdav.delete_resource(test_dir)
3941
assert delete_result["status_code"] in [204, 404] # No Content or Not Found
4042
logger.info(f"Deleted directory: {test_dir}")
41-
43+
4244
finally:
4345
# Cleanup: ensure directory is deleted
4446
try:
@@ -52,36 +54,34 @@ async def test_write_read_delete_file(nc_client: NextcloudClient, test_base_path
5254
"""Test writing, reading, and deleting files."""
5355
test_file = f"{test_base_path}/test_file.txt"
5456
test_content = f"Test content {uuid.uuid4().hex}"
55-
57+
5658
try:
5759
# Create base directory first
5860
await nc_client.webdav.create_directory(test_base_path)
59-
61+
6062
# Write file
6163
write_result = await nc_client.webdav.write_file(
62-
test_file,
63-
test_content.encode('utf-8'),
64-
content_type="text/plain"
64+
test_file, test_content.encode("utf-8"), content_type="text/plain"
6565
)
6666
assert write_result["status_code"] in [200, 201, 204] # Success codes
6767
logger.info(f"Wrote file: {test_file}")
68-
68+
6969
# Read file back
7070
content, content_type = await nc_client.webdav.read_file(test_file)
71-
assert content.decode('utf-8') == test_content
71+
assert content.decode("utf-8") == test_content
7272
assert content_type == "text/plain"
7373
logger.info(f"Read file: {test_file}")
74-
74+
7575
# Verify file appears in directory listing
7676
listing = await nc_client.webdav.list_directory(test_base_path)
7777
file_names = [item["name"] for item in listing]
7878
assert "test_file.txt" in file_names
79-
79+
8080
# Delete file
8181
delete_result = await nc_client.webdav.delete_resource(test_file)
8282
assert delete_result["status_code"] in [204, 404] # No Content or Not Found
8383
logger.info(f"Deleted file: {test_file}")
84-
84+
8585
finally:
8686
# Cleanup
8787
try:
@@ -91,43 +91,43 @@ async def test_write_read_delete_file(nc_client: NextcloudClient, test_base_path
9191
pass
9292

9393

94-
async def test_list_directory_empty_and_populated(nc_client: NextcloudClient, test_base_path: str):
94+
async def test_list_directory_empty_and_populated(
95+
nc_client: NextcloudClient, test_base_path: str
96+
):
9597
"""Test listing empty and populated directories."""
9698
try:
9799
# Create base directory
98100
await nc_client.webdav.create_directory(test_base_path)
99-
101+
100102
# List empty directory
101103
empty_listing = await nc_client.webdav.list_directory(test_base_path)
102104
assert isinstance(empty_listing, list)
103105
assert len(empty_listing) == 0
104106
logger.info(f"Empty directory listing: {len(empty_listing)} items")
105-
107+
106108
# Add some files and directories
107109
await nc_client.webdav.create_directory(f"{test_base_path}/subdir1")
108110
await nc_client.webdav.create_directory(f"{test_base_path}/subdir2")
109111
await nc_client.webdav.write_file(
110-
f"{test_base_path}/file1.txt",
111-
b"content1",
112-
content_type="text/plain"
112+
f"{test_base_path}/file1.txt", b"content1", content_type="text/plain"
113113
)
114114
await nc_client.webdav.write_file(
115115
f"{test_base_path}/file2.md",
116116
b"# Markdown content",
117-
content_type="text/markdown"
117+
content_type="text/markdown",
118118
)
119-
119+
120120
# List populated directory
121121
populated_listing = await nc_client.webdav.list_directory(test_base_path)
122122
assert len(populated_listing) == 4 # 2 dirs + 2 files
123-
123+
124124
# Check that we have both files and directories
125125
names = [item["name"] for item in populated_listing]
126126
assert "subdir1" in names
127127
assert "subdir2" in names
128128
assert "file1.txt" in names
129129
assert "file2.md" in names
130-
130+
131131
# Check metadata is present
132132
for item in populated_listing:
133133
assert "name" in item
@@ -136,9 +136,9 @@ async def test_list_directory_empty_and_populated(nc_client: NextcloudClient, te
136136
assert "size" in item
137137
assert "content_type" in item
138138
assert "last_modified" in item
139-
139+
140140
logger.info(f"Populated directory listing: {len(populated_listing)} items")
141-
141+
142142
finally:
143143
# Cleanup
144144
try:
@@ -154,45 +154,51 @@ async def test_list_directory_empty_and_populated(nc_client: NextcloudClient, te
154154
async def test_read_nonexistent_file(nc_client: NextcloudClient):
155155
"""Test reading a file that doesn't exist."""
156156
nonexistent_file = f"nonexistent_{uuid.uuid4().hex}.txt"
157-
157+
158158
with pytest.raises(HTTPStatusError) as exc_info:
159159
await nc_client.webdav.read_file(nonexistent_file)
160-
160+
161161
assert exc_info.value.response.status_code == 404
162162
logger.info(f"Correctly got 404 for nonexistent file: {nonexistent_file}")
163163

164164

165165
async def test_delete_nonexistent_resource(nc_client: NextcloudClient):
166166
"""Test deleting a resource that doesn't exist."""
167167
nonexistent_resource = f"nonexistent_{uuid.uuid4().hex}"
168-
168+
169169
result = await nc_client.webdav.delete_resource(nonexistent_resource)
170170
assert result["status_code"] == 404
171171
logger.info(f"Correctly got 404 for nonexistent resource: {nonexistent_resource}")
172172

173173

174-
async def test_create_nested_directories(nc_client: NextcloudClient, test_base_path: str):
174+
async def test_create_nested_directories(
175+
nc_client: NextcloudClient, test_base_path: str
176+
):
175177
"""Test creating nested directory structures."""
176178
nested_path = f"{test_base_path}/level1/level2/level3"
177-
179+
178180
try:
179181
# Create nested directories (should create parent directories automatically)
180182
result = await nc_client.webdav.create_directory(nested_path)
181183
assert result["status_code"] == 201
182-
184+
183185
# Verify the structure was created
184-
level1_listing = await nc_client.webdav.list_directory(f"{test_base_path}/level1")
186+
level1_listing = await nc_client.webdav.list_directory(
187+
f"{test_base_path}/level1"
188+
)
185189
assert len(level1_listing) == 1
186190
assert level1_listing[0]["name"] == "level2"
187191
assert level1_listing[0]["is_directory"] is True
188-
189-
level2_listing = await nc_client.webdav.list_directory(f"{test_base_path}/level1/level2")
192+
193+
level2_listing = await nc_client.webdav.list_directory(
194+
f"{test_base_path}/level1/level2"
195+
)
190196
assert len(level2_listing) == 1
191197
assert level2_listing[0]["name"] == "level3"
192198
assert level2_listing[0]["is_directory"] is True
193-
199+
194200
logger.info(f"Created nested directory structure: {nested_path}")
195-
201+
196202
finally:
197203
# Cleanup - delete from deepest to shallowest
198204
try:
@@ -209,36 +215,32 @@ async def test_overwrite_existing_file(nc_client: NextcloudClient, test_base_pat
209215
test_file = f"{test_base_path}/overwrite_test.txt"
210216
original_content = "Original content"
211217
new_content = "New content after overwrite"
212-
218+
213219
try:
214220
# Create base directory
215221
await nc_client.webdav.create_directory(test_base_path)
216-
222+
217223
# Write original file
218224
await nc_client.webdav.write_file(
219-
test_file,
220-
original_content.encode('utf-8'),
221-
content_type="text/plain"
225+
test_file, original_content.encode("utf-8"), content_type="text/plain"
222226
)
223-
227+
224228
# Verify original content
225229
content, _ = await nc_client.webdav.read_file(test_file)
226-
assert content.decode('utf-8') == original_content
227-
230+
assert content.decode("utf-8") == original_content
231+
228232
# Overwrite with new content
229233
overwrite_result = await nc_client.webdav.write_file(
230-
test_file,
231-
new_content.encode('utf-8'),
232-
content_type="text/plain"
234+
test_file, new_content.encode("utf-8"), content_type="text/plain"
233235
)
234236
assert overwrite_result["status_code"] in [200, 204] # OK or No Content
235-
237+
236238
# Verify new content
237239
content, _ = await nc_client.webdav.read_file(test_file)
238-
assert content.decode('utf-8') == new_content
239-
240+
assert content.decode("utf-8") == new_content
241+
240242
logger.info(f"Successfully overwrote file: {test_file}")
241-
243+
242244
finally:
243245
# Cleanup
244246
try:
@@ -251,12 +253,12 @@ async def test_overwrite_existing_file(nc_client: NextcloudClient, test_base_pat
251253
async def test_list_root_directory(nc_client: NextcloudClient):
252254
"""Test listing the root directory."""
253255
root_listing = await nc_client.webdav.list_directory("")
254-
256+
255257
# Root directory should exist and be listable
256258
assert isinstance(root_listing, list)
257259
# Should have at least some default folders/files
258260
assert len(root_listing) >= 0
259-
261+
260262
# Check structure of items
261263
for item in root_listing:
262264
assert "name" in item
@@ -265,5 +267,5 @@ async def test_list_root_directory(nc_client: NextcloudClient):
265267
assert "size" in item
266268
assert "content_type" in item
267269
assert "last_modified" in item
268-
269-
logger.info(f"Root directory contains {len(root_listing)} items")
270+
271+
logger.info(f"Root directory contains {len(root_listing)} items")

0 commit comments

Comments
 (0)