File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,14 @@ def theme(self) -> ThemingInfo | None:
113
113
"""Returns Theme information."""
114
114
return get_parsed_theme (self .capabilities ["theming" ]) if "theming" in self .capabilities else None
115
115
116
+ def perform_login (self ) -> bool :
117
+ """Performs login into Nextcloud if not already logged in; manual invocation of this method is unnecessary."""
118
+ try :
119
+ self .update_server_info ()
120
+ except Exception : # noqa pylint: disable=broad-exception-caught
121
+ return False
122
+ return True
123
+
116
124
def ocs (
117
125
self ,
118
126
method : str ,
@@ -199,6 +207,14 @@ async def theme(self) -> ThemingInfo | None:
199
207
"""Returns Theme information."""
200
208
return get_parsed_theme ((await self .capabilities )["theming" ]) if "theming" in await self .capabilities else None
201
209
210
+ async def perform_login (self ) -> bool :
211
+ """Performs login into Nextcloud if not already logged in; manual invocation of this method is unnecessary."""
212
+ try :
213
+ await self .update_server_info ()
214
+ except Exception : # noqa pylint: disable=broad-exception-caught
215
+ return False
216
+ return True
217
+
202
218
async def ocs (
203
219
self ,
204
220
method : str ,
Original file line number Diff line number Diff line change @@ -180,3 +180,18 @@ async def test_public_ocs_async(anc_any):
180
180
r = await anc_any .ocs ("GET" , "/ocs/v1.php/cloud/capabilities" )
181
181
assert r == await anc_any .ocs ("GET" , "ocs/v1.php/cloud/capabilities" )
182
182
assert r == await anc_any ._session .ocs ("GET" , "ocs/v1.php/cloud/capabilities" ) # noqa
183
+
184
+
185
+ def test_perform_login (nc_any ):
186
+ new_nc = Nextcloud () if isinstance (nc_any , Nextcloud ) else NextcloudApp ()
187
+ assert not new_nc ._session ._capabilities
188
+ new_nc .perform_login ()
189
+ assert new_nc ._session ._capabilities
190
+
191
+
192
+ @pytest .mark .asyncio (scope = "session" )
193
+ async def test_perform_login_async (anc_any ):
194
+ new_nc = AsyncNextcloud () if isinstance (anc_any , Nextcloud ) else AsyncNextcloudApp ()
195
+ assert not new_nc ._session ._capabilities
196
+ await new_nc .perform_login ()
197
+ assert new_nc ._session ._capabilities
You can’t perform that action at this time.
0 commit comments