Skip to content

Commit

Permalink
Merge pull request #199 from sh-andriy/feature/ENG-6569
Browse files Browse the repository at this point in the history
[ENG-6569] |  root folder issue fix
  • Loading branch information
adlius authored Jan 3, 2025
2 parents dcc19aa + 0a7dd8b commit 9b5b240
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
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

0 comments on commit 9b5b240

Please sign in to comment.