Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-6569] | root folder issue fix #199

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion addon_imps/storage/owncloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ def _fallback_username(self) -> str | None:
return "default-username"

async def list_root_items(self, page_cursor: str = "") -> storage.ItemSampleResult:
return await self.list_child_items(_owncloud_root_id(), page_cursor)
root_item = storage.ItemResult(
item_id=_owncloud_root_id(),
item_name="Root Directory",
item_type=ItemType.FOLDER,
can_be_root=True,
may_contain_root_candidates=True,
)
return storage.ItemSampleResult(items=[root_item])

async def get_item_info(self, item_id: str) -> storage.ItemResult:
item_type, path = _parse_item_id(item_id)
Expand Down
16 changes: 7 additions & 9 deletions addon_imps/tests/storage/test_owncloud.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import unittest
from unittest.mock import (
AsyncMock,
sentinel,
)
from unittest.mock import AsyncMock

from addon_imps.storage.owncloud import (
_BUILD_PROPFIND_ALLPROPS,
Expand Down Expand Up @@ -81,12 +78,13 @@ async def test_get_external_account_id(self):
self.assertEqual(result, "Test User")

async def test_list_root_items(self):
mock_response = sentinel.result
self.imp.list_child_items = AsyncMock(return_value=mock_response)
result = await self.imp.list_root_items()

self.assertEqual(result, mock_response)
self.imp.list_child_items.assert_awaited_once_with("folder:/", "")
self.assertEqual(len(result.items), 1)
root_item = result.items[0]
self.assertEqual(root_item.item_id, "folder:/")
self.assertEqual(root_item.item_name, "Root Directory")
self.assertEqual(root_item.item_type, ItemType.FOLDER)
self.assertTrue(root_item.can_be_root)

async def test_get_item_info(self):
response_xml = """<?xml version="1.0" encoding="UTF-8"?>
Expand Down
Loading