Skip to content

Commit 23dad7d

Browse files
committed
ENH: Implementation of 'info_get' API
1 parent c896beb commit 23dad7d

File tree

4 files changed

+55
-1
lines changed

4 files changed

+55
-1
lines changed

src/save_and_restore_api/_api_async.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ async def send_request(
4040

4141
return response
4242

43+
# =============================================================================================
44+
# INFO-CONTROLLER API METHODS
45+
# =============================================================================================
46+
47+
async def info_get(self):
48+
method, url = self._prepare_info_get()
49+
return await self.send_request(method, url)
50+
4351
# =============================================================================================
4452
# AUTHENTICATION-CONTROLLER API METHODS
4553
# =============================================================================================

src/save_and_restore_api/_api_base.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ def _prepare_request(
159159
kwargs.update({"auth": auth})
160160
return kwargs
161161

162+
# =============================================================================================
163+
# INFO-CONTROLLER API METHODS
164+
# =============================================================================================
165+
166+
def _prepare_info_get(self):
167+
method, url = "GET", "/"
168+
return method, url
169+
170+
# =============================================================================================
171+
# AUTHENTICATION-CONTROLLER API METHODS
172+
# =============================================================================================
173+
162174
def _prepare_login(self, *, username=None, password=None):
163175
method, url = "POST", "/login"
164176
params = {"username": username, "password": password}

src/save_and_restore_api/_api_threads.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ def send_request(
3939

4040
return response
4141

42+
# =============================================================================================
43+
# INFO-CONTROLLER API METHODS
44+
# =============================================================================================
45+
46+
def info_get(self):
47+
method, url = self._prepare_info_get()
48+
return self.send_request(method, url)
49+
4250
# =============================================================================================
4351
# AUTHENTICATION-CONTROLLER API METHODS
4452
# =============================================================================================

tests/test_misc.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,36 @@ def test_version_01():
6666

6767

6868
# =============================================================================================
69-
# TESTS FOR AUTHENTICATION-CONTROLLER API METHODS
69+
# INFO-CONTROLLER API METHODS
7070
# =============================================================================================
7171

7272

73+
# fmt: off
74+
@pytest.mark.parametrize("library", ["THREADS", "ASYNC"])
75+
# fmt: on
76+
def test_info_get_01(library):
77+
"""
78+
Tests for the 'info_get' API.
79+
"""
80+
if not _is_async(library):
81+
with SaveRestoreAPI_Threads(base_url=base_url, timeout=2) as SR:
82+
83+
info = SR.info_get()
84+
assert info["name"] == "service-save-and-restore"
85+
86+
else:
87+
async def testing():
88+
async with SaveRestoreAPI_Async(base_url=base_url, timeout=2) as SR:
89+
90+
info = await SR.info_get()
91+
assert info["name"] == "service-save-and-restore"
92+
93+
asyncio.run(testing())
94+
95+
# =============================================================================================
96+
# TESTS FOR AUTHENTICATION-CONTROLLER API METHODS
97+
# =============================================================================================
98+
7399
# fmt: off
74100
@pytest.mark.parametrize("library", ["THREADS", "ASYNC"])
75101
@pytest.mark.parametrize("username, password, roles, code", [

0 commit comments

Comments
 (0)