Skip to content

Commit 2d5f8b2

Browse files
Merge pull request #89 from shasibhusanJena/umapi_log_msg_fix
DMESVCS-543 : Umapi log message fix
2 parents 1f217fa + 2c93a91 commit 2d5f8b2

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

tests/test_connections.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,14 @@ def test_get_retry_logging(log_stream):
246246
pytest.raises(UnavailableError, conn.make_call, "")
247247
stream.flush()
248248
log = stream.getvalue() # save as a local so can do pytest -l to see exact log
249-
assert log == """UMAPI timeout...service unavailable (code 429 on try 1)
250-
Next retry in 3 seconds...
251-
UMAPI timeout...service unavailable (code 429 on try 2)
252-
Next retry in 3 seconds...
253-
UMAPI timeout...service unavailable (code 429 on try 3)
249+
assert log == """UMAPI request limit reached (code 429 on try 1)
250+
waiting 3 seconds to continue...
251+
UMAPI request limit reached (code 429 on try 2)
252+
waiting 3 seconds to continue...
253+
UMAPI request limit reached (code 429 on try 3)
254254
UMAPI timeout...giving up after 3 attempts (6 seconds).
255255
"""
256256

257-
258257
# log_stream fixture defined in conftest.py
259258
def test_post_retry_logging(log_stream):
260259
with mock.patch("umapi_client.connection.requests.Session.post") as mock_post:
@@ -266,15 +265,14 @@ def test_post_retry_logging(log_stream):
266265
pytest.raises(UnavailableError, conn.make_call, "", [3, 5])
267266
stream.flush()
268267
log = stream.getvalue() # save as a local so can do pytest -l to see exact log
269-
assert log == """UMAPI timeout...service unavailable (code 429 on try 1)
270-
Next retry in 3 seconds...
271-
UMAPI timeout...service unavailable (code 429 on try 2)
272-
Next retry in 3 seconds...
273-
UMAPI timeout...service unavailable (code 429 on try 3)
268+
assert log == """UMAPI request limit reached (code 429 on try 1)
269+
waiting 3 seconds to continue...
270+
UMAPI request limit reached (code 429 on try 2)
271+
waiting 3 seconds to continue...
272+
UMAPI request limit reached (code 429 on try 3)
274273
UMAPI timeout...giving up after 3 attempts (6 seconds).
275274
"""
276275

277-
278276
def test_get_server_fail():
279277
with mock.patch("umapi_client.connection.requests.Session.get") as mock_get:
280278
mock_get.return_value = MockResponse(500, text="500 test server failure")

umapi_client/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def call():
500500
if checked_result.success:
501501
return result
502502

503-
if self.logger: self.logger.warning("UMAPI timeout...service unavailable (code %s on try %d)",
503+
if self.logger: self.logger.warning("UMAPI request limit reached (code %s on try %d)",
504504
checked_result.status_code, num_attempts)
505505

506506
retry_wait = checked_result.timeout
@@ -511,7 +511,7 @@ def call():
511511

512512
if num_attempts < self.retry_max_attempts:
513513
if retry_wait > 0:
514-
if self.logger: self.logger.warning("Next retry in %d seconds...", retry_wait)
514+
if self.logger: self.logger.warning("waiting %d seconds to continue...", retry_wait)
515515
sleep(retry_wait)
516516
else:
517517
if self.logger: self.logger.warning("Immediate retry...")

0 commit comments

Comments
 (0)