renpho-api 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {renpho_api-0.2.0 → renpho_api-0.2.1}/PKG-INFO +22 -1
- {renpho_api-0.2.0 → renpho_api-0.2.1}/README.md +20 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/pyproject.toml +7 -1
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho/client.py +41 -8
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho/constants.py +18 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho_api.egg-info/PKG-INFO +22 -1
- {renpho_api-0.2.0 → renpho_api-0.2.1}/tests/test_client.py +121 -1
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho/__init__.py +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho/cli.py +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho/crypto.py +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho/export.py +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho/girth.py +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho_api.egg-info/SOURCES.txt +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho_api.egg-info/dependency_links.txt +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho_api.egg-info/entry_points.txt +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho_api.egg-info/requires.txt +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/renpho_api.egg-info/top_level.txt +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/setup.cfg +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/tests/test_constants.py +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/tests/test_crypto.py +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/tests/test_export.py +0 -0
- {renpho_api-0.2.0 → renpho_api-0.2.1}/tests/test_girth.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: renpho-api
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Unofficial Python client for the Renpho Health API — pull body composition data from Renpho smart scales and body girth data from smart tape measures.
|
|
5
5
|
Author: danvaneijck
|
|
6
6
|
License-Expression: MIT
|
|
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
17
|
Classifier: Topic :: Software Development :: Libraries
|
|
17
18
|
Requires-Python: >=3.10
|
|
18
19
|
Description-Content-Type: text/markdown
|
|
@@ -186,6 +187,26 @@ except RenphoAPIError as e:
|
|
|
186
187
|
print(f"API error: {e}")
|
|
187
188
|
```
|
|
188
189
|
|
|
190
|
+
Requests time out after 10 s to connect and 30 s to read by default. Pass
|
|
191
|
+
`RenphoClient(..., timeout=60)` (or a `(connect, read)` pair) to change that.
|
|
192
|
+
|
|
193
|
+
### Troubleshooting login
|
|
194
|
+
|
|
195
|
+
- **`code=-114` ("Decryption failed …").** Renpho's gateway changed in October
|
|
196
|
+
2026 and now needs an `appVersion` header on the login request. Upgrade to
|
|
197
|
+
`renpho-api>=0.2.1`. `APP_VERSION` must stay below `8.0.0`, because the
|
|
198
|
+
bundled AES key only works for app versions before 8.0.0.
|
|
199
|
+
- **`code=104` ("wrong user name or password") with a correct password.**
|
|
200
|
+
Upgrade to 0.2.1 first. If it persists, check whether the account signs in
|
|
201
|
+
with Google or Apple (next point), and if not, report it in
|
|
202
|
+
[#10](https://github.com/danvaneijck/renpho-api/issues/10).
|
|
203
|
+
- **Your account signs in with Google or Apple.** These accounts have no
|
|
204
|
+
password, so they cannot log in through the API.
|
|
205
|
+
- **The phone app logs you out after a sync.** Renpho allows one active
|
|
206
|
+
session per account, so every `login()` ends the app's session. If you run
|
|
207
|
+
scheduled syncs, run them less often or use a separate account
|
|
208
|
+
(see [#14](https://github.com/danvaneijck/renpho-api/issues/14)).
|
|
209
|
+
|
|
189
210
|
## Smart Tape Measure (body girth)
|
|
190
211
|
|
|
191
212
|
The Renpho Smart Tape Measure stores circumference measurements (waist, hip,
|
|
@@ -161,6 +161,26 @@ except RenphoAPIError as e:
|
|
|
161
161
|
print(f"API error: {e}")
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
+
Requests time out after 10 s to connect and 30 s to read by default. Pass
|
|
165
|
+
`RenphoClient(..., timeout=60)` (or a `(connect, read)` pair) to change that.
|
|
166
|
+
|
|
167
|
+
### Troubleshooting login
|
|
168
|
+
|
|
169
|
+
- **`code=-114` ("Decryption failed …").** Renpho's gateway changed in October
|
|
170
|
+
2026 and now needs an `appVersion` header on the login request. Upgrade to
|
|
171
|
+
`renpho-api>=0.2.1`. `APP_VERSION` must stay below `8.0.0`, because the
|
|
172
|
+
bundled AES key only works for app versions before 8.0.0.
|
|
173
|
+
- **`code=104` ("wrong user name or password") with a correct password.**
|
|
174
|
+
Upgrade to 0.2.1 first. If it persists, check whether the account signs in
|
|
175
|
+
with Google or Apple (next point), and if not, report it in
|
|
176
|
+
[#10](https://github.com/danvaneijck/renpho-api/issues/10).
|
|
177
|
+
- **Your account signs in with Google or Apple.** These accounts have no
|
|
178
|
+
password, so they cannot log in through the API.
|
|
179
|
+
- **The phone app logs you out after a sync.** Renpho allows one active
|
|
180
|
+
session per account, so every `login()` ends the app's session. If you run
|
|
181
|
+
scheduled syncs, run them less often or use a separate account
|
|
182
|
+
(see [#14](https://github.com/danvaneijck/renpho-api/issues/14)).
|
|
183
|
+
|
|
164
184
|
## Smart Tape Measure (body girth)
|
|
165
185
|
|
|
166
186
|
The Renpho Smart Tape Measure stores circumference measurements (waist, hip,
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "renpho-api"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.1"
|
|
8
8
|
description = "Unofficial Python client for the Renpho Health API — pull body composition data from Renpho smart scales and body girth data from smart tape measures."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -27,6 +27,7 @@ classifiers = [
|
|
|
27
27
|
"Programming Language :: Python :: 3.11",
|
|
28
28
|
"Programming Language :: Python :: 3.12",
|
|
29
29
|
"Programming Language :: Python :: 3.13",
|
|
30
|
+
"Programming Language :: Python :: 3.14",
|
|
30
31
|
"Topic :: Software Development :: Libraries",
|
|
31
32
|
]
|
|
32
33
|
dependencies = [
|
|
@@ -44,6 +45,11 @@ Repository = "https://github.com/danvaneijck/renpho-api"
|
|
|
44
45
|
[project.scripts]
|
|
45
46
|
renpho = "renpho.cli:main"
|
|
46
47
|
|
|
48
|
+
# Explicit, because flat-layout auto-discovery also picks up the CLI's default
|
|
49
|
+
# output folder (renpho_data/) once it exists and then refuses to build.
|
|
50
|
+
[tool.setuptools]
|
|
51
|
+
packages = ["renpho"]
|
|
52
|
+
|
|
47
53
|
[dependency-groups]
|
|
48
54
|
dev = [
|
|
49
55
|
"pytest-cov>=7.1.0",
|
|
@@ -14,6 +14,7 @@ from .constants import (
|
|
|
14
14
|
MEASUREMENT_TABLE_NAMES,
|
|
15
15
|
MEASUREMENT_TABLE_SHARDS,
|
|
16
16
|
PLATFORM,
|
|
17
|
+
REQUEST_TIMEOUT,
|
|
17
18
|
SUCCESS_CODES,
|
|
18
19
|
SYSTEM_VERSION,
|
|
19
20
|
)
|
|
@@ -38,10 +39,15 @@ class RenphoAPIError(Exception):
|
|
|
38
39
|
def _check_response(result: dict, context: str = "API call") -> None:
|
|
39
40
|
"""Raise :class:`RenphoAPIError` if the response indicates failure."""
|
|
40
41
|
code = result.get("code")
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
# The API is inconsistent about the field holding the human-readable text:
|
|
43
|
+
# the older endpoints answer "msg", the gateway's own errors (-113, -114)
|
|
44
|
+
# answer "message". Reading only one of them silently threw away the
|
|
45
|
+
# diagnostic and left callers with a bare code to go on. Either may also be
|
|
46
|
+
# explicitly null, hence the coalesce to "" rather than a dict default.
|
|
47
|
+
msg = result.get("msg") or result.get("message") or ""
|
|
48
|
+
if str(msg).lower() == "success" or code in SUCCESS_CODES:
|
|
43
49
|
return
|
|
44
|
-
raise RenphoAPIError(context, code, msg)
|
|
50
|
+
raise RenphoAPIError(context, code, str(msg))
|
|
45
51
|
|
|
46
52
|
|
|
47
53
|
class RenphoClient:
|
|
@@ -56,10 +62,28 @@ class RenphoClient:
|
|
|
56
62
|
print(m["weight"], m.get("bodyfat"))
|
|
57
63
|
"""
|
|
58
64
|
|
|
59
|
-
def __init__(
|
|
65
|
+
def __init__(
|
|
66
|
+
self,
|
|
67
|
+
email: str,
|
|
68
|
+
password: str,
|
|
69
|
+
*,
|
|
70
|
+
debug: bool = False,
|
|
71
|
+
timeout: float | tuple[float, float] | None = REQUEST_TIMEOUT,
|
|
72
|
+
):
|
|
73
|
+
"""
|
|
74
|
+
Args:
|
|
75
|
+
email: Renpho account email.
|
|
76
|
+
password: Renpho account password.
|
|
77
|
+
debug: Print request/response details.
|
|
78
|
+
timeout: Per-request timeout in seconds, either one number or a
|
|
79
|
+
``(connect, read)`` pair. Defaults to
|
|
80
|
+
:data:`~renpho.constants.REQUEST_TIMEOUT`. ``None`` disables it
|
|
81
|
+
(not recommended: a stalled server then blocks forever).
|
|
82
|
+
"""
|
|
60
83
|
self.email = email
|
|
61
84
|
self.password = password
|
|
62
85
|
self.debug = debug
|
|
86
|
+
self.timeout = timeout
|
|
63
87
|
self.token: str | None = None
|
|
64
88
|
self.user_id: int | str | None = None
|
|
65
89
|
self.user_info: dict | None = None
|
|
@@ -86,12 +110,19 @@ class RenphoClient:
|
|
|
86
110
|
set than the default reads.
|
|
87
111
|
"""
|
|
88
112
|
url = f"{API_BASE_URL}/{endpoint}"
|
|
89
|
-
|
|
113
|
+
# ``appVersion`` is what the gateway keys payload decryption off, so it
|
|
114
|
+
# has to go out on *every* call — including the unauthenticated login,
|
|
115
|
+
# which used to send no headers at all. Without it the server cannot
|
|
116
|
+
# pick a key and answers code -114 ("Decryption failed, please check
|
|
117
|
+
# the parameters or key, ..."), which reads like a wrong key but is
|
|
118
|
+
# really a missing header. See APP_VERSION in constants.py.
|
|
119
|
+
headers: dict[str, str] = {
|
|
120
|
+
"appVersion": APP_VERSION,
|
|
121
|
+
"platform": PLATFORM,
|
|
122
|
+
}
|
|
90
123
|
if auth and self.token:
|
|
91
124
|
headers["token"] = self.token
|
|
92
125
|
headers["userId"] = str(self.user_id)
|
|
93
|
-
headers["appVersion"] = APP_VERSION
|
|
94
|
-
headers["platform"] = PLATFORM
|
|
95
126
|
if extra_headers:
|
|
96
127
|
headers.update(extra_headers)
|
|
97
128
|
|
|
@@ -100,7 +131,9 @@ class RenphoClient:
|
|
|
100
131
|
if auth and self.token:
|
|
101
132
|
print(f" Headers: token={self.token[:20]}..., userId={self.user_id}")
|
|
102
133
|
|
|
103
|
-
resp = self._session.post(
|
|
134
|
+
resp = self._session.post(
|
|
135
|
+
url, json=body, headers=headers, timeout=self.timeout
|
|
136
|
+
)
|
|
104
137
|
|
|
105
138
|
if self.debug:
|
|
106
139
|
print(f" Status: {resp.status_code}")
|
|
@@ -3,10 +3,28 @@
|
|
|
3
3
|
# API connection
|
|
4
4
|
API_BASE_URL = "https://cloud.renpho.com"
|
|
5
5
|
ENCRYPTION_KEY = "ed*wijdi$h6fe3ew" # 16-byte AES-128 key
|
|
6
|
+
|
|
7
|
+
# APP_VERSION is not cosmetic: the gateway selects the payload decryption key
|
|
8
|
+
# from the ``appVersion`` request header. ENCRYPTION_KEY above is the key for
|
|
9
|
+
# app versions BELOW 8.0.0 — send 8.0.0 or newer (or omit the header) and the
|
|
10
|
+
# server tries a different key and fails with code -114, "Decryption failed,
|
|
11
|
+
# please check the parameters or key, or the data length is too long".
|
|
12
|
+
#
|
|
13
|
+
# Verified against a live account on 2026-10-22: 6.6.0, 6.9.9, 7.0.0 and 7.5.0
|
|
14
|
+
# all authenticate; 8.0.0, 8.5.0, 9.0.0 and 10.0.0 all return -114, as does
|
|
15
|
+
# sending no appVersion header at all.
|
|
16
|
+
#
|
|
17
|
+
# So do NOT bump this to match the current store version without also working
|
|
18
|
+
# out the newer key — that swap is what breaks login.
|
|
6
19
|
APP_VERSION = "6.6.0"
|
|
7
20
|
PLATFORM = "android"
|
|
8
21
|
SYSTEM_VERSION = "11" # systemversion header value (mirrors the login systemType)
|
|
9
22
|
|
|
23
|
+
# Default per-request timeout in seconds, as ``(connect, read)``. Without one a
|
|
24
|
+
# stalled server hangs the caller forever, which for a scheduled sync means a
|
|
25
|
+
# job that never finishes and never reports an error.
|
|
26
|
+
REQUEST_TIMEOUT = (10, 30)
|
|
27
|
+
|
|
10
28
|
# API endpoints (from RenphoApiEndpoints.cs)
|
|
11
29
|
ENDPOINTS = {
|
|
12
30
|
"login": "renpho-aggregation/user/login",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: renpho-api
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Unofficial Python client for the Renpho Health API — pull body composition data from Renpho smart scales and body girth data from smart tape measures.
|
|
5
5
|
Author: danvaneijck
|
|
6
6
|
License-Expression: MIT
|
|
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
17
|
Classifier: Topic :: Software Development :: Libraries
|
|
17
18
|
Requires-Python: >=3.10
|
|
18
19
|
Description-Content-Type: text/markdown
|
|
@@ -186,6 +187,26 @@ except RenphoAPIError as e:
|
|
|
186
187
|
print(f"API error: {e}")
|
|
187
188
|
```
|
|
188
189
|
|
|
190
|
+
Requests time out after 10 s to connect and 30 s to read by default. Pass
|
|
191
|
+
`RenphoClient(..., timeout=60)` (or a `(connect, read)` pair) to change that.
|
|
192
|
+
|
|
193
|
+
### Troubleshooting login
|
|
194
|
+
|
|
195
|
+
- **`code=-114` ("Decryption failed …").** Renpho's gateway changed in October
|
|
196
|
+
2026 and now needs an `appVersion` header on the login request. Upgrade to
|
|
197
|
+
`renpho-api>=0.2.1`. `APP_VERSION` must stay below `8.0.0`, because the
|
|
198
|
+
bundled AES key only works for app versions before 8.0.0.
|
|
199
|
+
- **`code=104` ("wrong user name or password") with a correct password.**
|
|
200
|
+
Upgrade to 0.2.1 first. If it persists, check whether the account signs in
|
|
201
|
+
with Google or Apple (next point), and if not, report it in
|
|
202
|
+
[#10](https://github.com/danvaneijck/renpho-api/issues/10).
|
|
203
|
+
- **Your account signs in with Google or Apple.** These accounts have no
|
|
204
|
+
password, so they cannot log in through the API.
|
|
205
|
+
- **The phone app logs you out after a sync.** Renpho allows one active
|
|
206
|
+
session per account, so every `login()` ends the app's session. If you run
|
|
207
|
+
scheduled syncs, run them less often or use a separate account
|
|
208
|
+
(see [#14](https://github.com/danvaneijck/renpho-api/issues/14)).
|
|
209
|
+
|
|
189
210
|
## Smart Tape Measure (body girth)
|
|
190
211
|
|
|
191
212
|
The Renpho Smart Tape Measure stores circumference measurements (waist, hip,
|
|
@@ -7,7 +7,14 @@ import pytest
|
|
|
7
7
|
import requests
|
|
8
8
|
|
|
9
9
|
from renpho.client import RenphoAPIError, RenphoClient, _check_response
|
|
10
|
-
from renpho.constants import
|
|
10
|
+
from renpho.constants import (
|
|
11
|
+
APP_VERSION,
|
|
12
|
+
ENDPOINTS,
|
|
13
|
+
MEASUREMENT_TABLE_NAMES,
|
|
14
|
+
PLATFORM,
|
|
15
|
+
REQUEST_TIMEOUT,
|
|
16
|
+
SUCCESS_CODES,
|
|
17
|
+
)
|
|
11
18
|
from renpho.crypto import aes_decrypt, encrypt_request
|
|
12
19
|
|
|
13
20
|
|
|
@@ -25,6 +32,94 @@ class TestCheckResponse:
|
|
|
25
32
|
assert exc_info.value.code == 401
|
|
26
33
|
assert "Unauthorized" in str(exc_info.value)
|
|
27
34
|
|
|
35
|
+
def test_success_by_message_field(self):
|
|
36
|
+
_check_response({"code": 999, "message": "success"})
|
|
37
|
+
|
|
38
|
+
def test_surfaces_the_message_field(self):
|
|
39
|
+
"""The gateway reports its own errors under "message", not "msg"."""
|
|
40
|
+
with pytest.raises(RenphoAPIError) as exc_info:
|
|
41
|
+
_check_response({
|
|
42
|
+
"code": -114,
|
|
43
|
+
"message": "Decryption failed, please check the parameters or key",
|
|
44
|
+
})
|
|
45
|
+
assert exc_info.value.code == -114
|
|
46
|
+
assert "Decryption failed" in exc_info.value.msg
|
|
47
|
+
assert "Decryption failed" in str(exc_info.value)
|
|
48
|
+
|
|
49
|
+
def test_msg_wins_when_both_fields_are_present(self):
|
|
50
|
+
with pytest.raises(RenphoAPIError) as exc_info:
|
|
51
|
+
_check_response({"code": 401, "msg": "from msg", "message": "from message"})
|
|
52
|
+
assert exc_info.value.msg == "from msg"
|
|
53
|
+
|
|
54
|
+
@pytest.mark.parametrize(
|
|
55
|
+
"result",
|
|
56
|
+
[
|
|
57
|
+
{"code": 401, "msg": None},
|
|
58
|
+
{"code": 401, "message": None},
|
|
59
|
+
{"code": 401},
|
|
60
|
+
],
|
|
61
|
+
)
|
|
62
|
+
def test_null_or_absent_text_does_not_crash(self, result):
|
|
63
|
+
with pytest.raises(RenphoAPIError) as exc_info:
|
|
64
|
+
_check_response(result)
|
|
65
|
+
assert exc_info.value.msg == ""
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class TestPostHeaders:
|
|
69
|
+
"""``appVersion`` selects the gateway's decryption key, so it must always go out.
|
|
70
|
+
|
|
71
|
+
Omitting it on the unauthenticated login is what made the server answer
|
|
72
|
+
code -114 ("Decryption failed ...") for every caller.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
@staticmethod
|
|
76
|
+
def _captured_headers(*, auth, token=None, extra_headers=None):
|
|
77
|
+
client = RenphoClient("user@example.com", "pw")
|
|
78
|
+
if token:
|
|
79
|
+
client.token = token
|
|
80
|
+
client.user_id = 12345
|
|
81
|
+
with patch.object(client._session, "post") as post:
|
|
82
|
+
post.return_value = MagicMock(
|
|
83
|
+
status_code=200, json=lambda: {"code": 101, "msg": "success"}
|
|
84
|
+
)
|
|
85
|
+
client._post(
|
|
86
|
+
ENDPOINTS["login"], {"encryptData": "x"},
|
|
87
|
+
auth=auth, extra_headers=extra_headers,
|
|
88
|
+
)
|
|
89
|
+
return post.call_args.kwargs["headers"]
|
|
90
|
+
|
|
91
|
+
def test_unauthenticated_login_still_sends_app_version(self):
|
|
92
|
+
headers = self._captured_headers(auth=False)
|
|
93
|
+
assert headers["appVersion"] == APP_VERSION
|
|
94
|
+
assert headers["platform"] == PLATFORM
|
|
95
|
+
|
|
96
|
+
def test_unauthenticated_login_sends_no_credentials(self):
|
|
97
|
+
headers = self._captured_headers(auth=False)
|
|
98
|
+
assert "token" not in headers
|
|
99
|
+
assert "userId" not in headers
|
|
100
|
+
|
|
101
|
+
def test_authenticated_call_sends_app_version_and_credentials(self):
|
|
102
|
+
headers = self._captured_headers(auth=True, token="tok-abc")
|
|
103
|
+
assert headers["appVersion"] == APP_VERSION
|
|
104
|
+
assert headers["platform"] == PLATFORM
|
|
105
|
+
assert headers["token"] == "tok-abc"
|
|
106
|
+
assert headers["userId"] == "12345"
|
|
107
|
+
|
|
108
|
+
def test_app_version_predates_the_key_rotation(self):
|
|
109
|
+
"""The bundled ENCRYPTION_KEY is only accepted below app version 8.0.0."""
|
|
110
|
+
major = int(APP_VERSION.split(".")[0])
|
|
111
|
+
assert major < 8, (
|
|
112
|
+
f"APP_VERSION {APP_VERSION} is at or past the 8.0.0 key rotation; "
|
|
113
|
+
"the bundled ENCRYPTION_KEY will be rejected with code -114"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
def test_extra_headers_can_override_the_defaults(self):
|
|
117
|
+
headers = self._captured_headers(
|
|
118
|
+
auth=True, token="tok-abc", extra_headers={"platform": "ios"}
|
|
119
|
+
)
|
|
120
|
+
assert headers["platform"] == "ios"
|
|
121
|
+
assert headers["appVersion"] == APP_VERSION
|
|
122
|
+
|
|
28
123
|
|
|
29
124
|
class TestExtractRecords:
|
|
30
125
|
def test_list_input(self):
|
|
@@ -71,6 +166,31 @@ class TestRenphoClient:
|
|
|
71
166
|
assert client.debug is True
|
|
72
167
|
|
|
73
168
|
|
|
169
|
+
class TestRequestTimeout:
|
|
170
|
+
"""Every request must carry a timeout, or a stalled server hangs forever."""
|
|
171
|
+
|
|
172
|
+
@staticmethod
|
|
173
|
+
def _sent_timeout(client):
|
|
174
|
+
with patch.object(client._session, "post") as post:
|
|
175
|
+
post.return_value = MagicMock(
|
|
176
|
+
status_code=200, json=lambda: {"code": 101, "msg": "success"}
|
|
177
|
+
)
|
|
178
|
+
client._post(ENDPOINTS["login"], {"encryptData": "x"}, auth=False)
|
|
179
|
+
return post.call_args.kwargs["timeout"]
|
|
180
|
+
|
|
181
|
+
def test_default_timeout_is_sent(self):
|
|
182
|
+
assert self._sent_timeout(RenphoClient("a@b.com", "p")) == REQUEST_TIMEOUT
|
|
183
|
+
|
|
184
|
+
def test_default_timeout_is_bounded(self):
|
|
185
|
+
assert REQUEST_TIMEOUT is not None
|
|
186
|
+
|
|
187
|
+
def test_custom_timeout_is_sent(self):
|
|
188
|
+
assert self._sent_timeout(RenphoClient("a@b.com", "p", timeout=5)) == 5
|
|
189
|
+
|
|
190
|
+
def test_timeout_can_be_disabled(self):
|
|
191
|
+
assert self._sent_timeout(RenphoClient("a@b.com", "p", timeout=None)) is None
|
|
192
|
+
|
|
193
|
+
|
|
74
194
|
class TestGetBodyCompositionMeasurements:
|
|
75
195
|
def _make_client(self):
|
|
76
196
|
client = RenphoClient("a@b.com", "p")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|