diff --git a/synology_api/photos.py b/synology_api/photos.py index 5bb1e9a..bd15468 100755 --- a/synology_api/photos.py +++ b/synology_api/photos.py @@ -54,12 +54,11 @@ def _list_folders(self, folder_id, limit, offset, additional, api_name): return self.request_data(api_name, api_path, req_param) - def count_folders(self, folder_id=0): - return self._count_folders(folder_id, 'SYNO.FotoBrowse.Folder') + return self._count_folders(folder_id, 'SYNO.Foto.Browse.Folder') - def count_team_folders(self, fodler_id=0): - return self._count_folders(folder_id, 'SYNO.FotoTeam.FotoBrowse.Folder') + def count_team_folders(self, folder_id=0): + return self._count_folders(folder_id, 'SYNO.FotoTeam.Browse.Folder') def _count_folders(self, folder_id, api_name): info = self.photos_list[api_name] diff --git a/tests/fixtures.py b/tests/fixtures.py index c9f1c7a..0bdeec2 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -6,6 +6,8 @@ from pytest import fixture +from synology_api.photos import Photos + CREDENTIALS_FILE = 'credentials.json' with path( 'tests', '__init__.py' ) as p: @@ -16,3 +18,7 @@ @fixture def device() -> Dict: return DEVICE + +@fixture +def photos( device ) -> Photos: + return Photos( **device ) diff --git a/tests/test_photos.py b/tests/test_photos.py index cf4cbdf..ae10f18 100644 --- a/tests/test_photos.py +++ b/tests/test_photos.py @@ -4,7 +4,22 @@ from synology_api.photos import Photos from .fixtures import device +from .fixtures import photos def test_login( device: Mapping ): photos = Photos( **device ) assert photos.get_userinfo() is not None and photos.get_userinfo().get( 'success' ) + +def test_count_folders( photos: Photos ): + # find 'root' folder first + parent_id = 0 + response = photos.list_folders( 0 ) + if 'data' in response and response.get( 'success', False ): + for item in response.get( 'data' ).get( 'list', [] ): + parent_id = item['parent'] + break + + assert parent_id > 0 + + response = photos.count_folders( parent_id ) + assert 'data' in response and response.get( 'success' )