Skip to content

Commit 3fa51ca

Browse files
committed
DOC: additional docstrings
1 parent ebef5ce commit 3fa51ca

File tree

6 files changed

+51
-41
lines changed

6 files changed

+51
-41
lines changed

container/save-and-restore.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
services:
22
saveandrestore:
3-
image: ghcr.io/controlsystemstudio/phoebus/service-save-and-restore:v5.0.2
3+
image: ghcr.io/controlsystemstudio/phoebus/service-save-and-restore:master
4+
# image: ghcr.io/controlsystemstudio/phoebus/service-save-and-restore:v5.0.2
45
network_mode: "host"
56
# ports:
67
# - "8080:8080"

container/start-save-and-restore.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env bash
12
set -x
23

34
python create_env_file.py

ioc/sim_ioc2.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/save_and_restore_api/_api_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async def help(self, what, *, lang=None):
8383
# AUTHENTICATION-CONTROLLER API METHODS
8484
# =============================================================================================
8585

86-
async def login(self, *, username=None, password=None):
86+
async def login(self, *, username, password):
8787
# Reusing docstrings from the threaded version
8888
method, url, body_json = self._prepare_login(username=username, password=password)
8989
return await self.send_request(method, url, body_json=body_json)

src/save_and_restore_api/_api_threads.py

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ def info_get(self):
151151
Returns information about the Save and Restore service.
152152
153153
API: GET /
154+
155+
Returns
156+
-------
157+
dict
158+
Dictionary that contains service information.
154159
"""
155160
method, url = self._prepare_info_get()
156161
return self.send_request(method, url)
@@ -160,6 +165,12 @@ def version_get(self):
160165
Returns information on the name and current version of the service.
161166
162167
API: GET /verson
168+
169+
Returns
170+
-------
171+
str
172+
String that contains service name (``service-save-and-restore``) and the service version
173+
number.
163174
"""
164175
method, url = self._prepare_version_get()
165176
return self.send_request(method, url)
@@ -178,6 +189,18 @@ def search(self, allRequestParams):
178189
``nodes`` - a list of matching nodes (not including data).
179190
180191
API: GET /search
192+
193+
Parameters
194+
----------
195+
allRequestParams : dict
196+
Dictionary with search parameters, e.g. ``{"name": "test config"}`` or
197+
``{"description": "backup pvs"}``.
198+
199+
Returns
200+
-------
201+
dict
202+
Dictionary with the following keys: ``hitCount`` - the number of matching nodes,
203+
``nodes`` - a list of matching nodes (not including data).
181204
"""
182205
method, url, params = self._prepare_search(allRequestParams=allRequestParams)
183206
return self.send_request(method, url, params=params)
@@ -188,9 +211,16 @@ def search(self, allRequestParams):
188211

189212
def help(self, what, *, lang=None):
190213
"""
191-
Download help pages, e.g. /help/SearchHelp
214+
Download help pages, e.g. ``/help/SearchHelp``
192215
193216
API: GET /help/{what}?lang={lang}
217+
218+
Parameters
219+
----------
220+
what : str
221+
Name of the help page, e.g. ``/help/SearchHelp``.
222+
lang : str, optional
223+
Language code.
194224
"""
195225
method, url, params = self._prepare_help(what=what, lang=lang)
196226
return self.send_request(method, url, params=params)
@@ -199,11 +229,23 @@ def help(self, what, *, lang=None):
199229
# AUTHENTICATION-CONTROLLER API METHODS
200230
# =============================================================================================
201231

202-
def login(self, *, username=None, password=None):
232+
def login(self, *, username, password):
203233
"""
204-
Validate user credentials and return user information.
234+
Validate user credentials and return user information. Raises ``HTTPClientError``
235+
if the login fails.
205236
206237
API: POST /login
238+
239+
Parameters
240+
----------
241+
username : str
242+
User name.
243+
password : str
244+
User password.
245+
246+
Returns
247+
-------
248+
None
207249
"""
208250
method, url, body_json = self._prepare_login(username=username, password=password)
209251
return self.send_request(method, url, body_json=body_json)

tests/test_misc.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,19 +239,15 @@ def test_login_01(username, password, roles, library, code):
239239
if not _is_async(library):
240240
with SaveRestoreAPI_Threads(base_url=base_url, timeout=2) as SR:
241241
if code == 200:
242-
response = SR.login(username=username, password=password)
243-
assert response["userName"] == username
244-
assert response["roles"] == roles
242+
SR.login(username=username, password=password)
245243
else:
246244
with pytest.raises(SR.HTTPClientError, match=f"{code}"):
247245
SR.login(username=username, password=password)
248246
else:
249247
async def testing():
250248
async with SaveRestoreAPI_Async(base_url=base_url, timeout=2) as SR:
251249
if code == 200:
252-
response = await SR.login(username=username, password=password)
253-
assert response["userName"] == username
254-
assert response["roles"] == roles
250+
await SR.login(username=username, password=password)
255251
else:
256252
with pytest.raises(SR.HTTPClientError, match=f"{code}"):
257253
await SR.login(username=username, password=password)

0 commit comments

Comments
 (0)