Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Update regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xlz-jbleclere committed Jun 4, 2021
1 parent 342709f commit 8a7ba0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
3 changes: 0 additions & 3 deletions tests/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,6 @@ def test_configuration_file_with_bad_authentication(accelize_drm, conf_json, cre
assert "OAuth2 Web Service error 404" in str(excinfo.value)
assert async_handler.get_error_code(str(excinfo.value)) == accelize_drm.exceptions.DRMWSReqError.error_code
async_cb.assert_Error(accelize_drm.exceptions.DRMWSReqError.error_code,"OAuth2 Web Service error 404")
async_cb.assert_Error(accelize_drm.exceptions.DRMWSReqError.error_code, 'The issue could be caused by a networking problem: please verify your internet access')
async_cb.reset()
print('Test when authentication url in configuration file is wrong: PASS')

Expand All @@ -1217,7 +1216,6 @@ def test_configuration_file_with_bad_authentication(accelize_drm, conf_json, cre
assert "invalid_client" in str(excinfo.value)
assert async_handler.get_error_code(str(excinfo.value)) == accelize_drm.exceptions.DRMWSReqError.error_code
async_cb.assert_Error(accelize_drm.exceptions.DRMWSReqError.error_code, 'OAuth2 Web Service error 401')
async_cb.assert_Error(accelize_drm.exceptions.DRMWSReqError.error_code, 'The issue could be caused by a networking problem: please verify your internet access')
async_cb.reset()
print('Test when client_id is wrong: PASS')

Expand All @@ -1242,6 +1240,5 @@ def test_configuration_file_with_bad_authentication(accelize_drm, conf_json, cre
assert "invalid_client" in str(excinfo.value)
assert async_handler.get_error_code(str(excinfo.value)) == accelize_drm.exceptions.DRMWSReqError.error_code
async_cb.assert_Error(accelize_drm.exceptions.DRMWSReqError.error_code, 'OAuth2 Web Service error 401')
async_cb.assert_Error(accelize_drm.exceptions.DRMWSReqError.error_code, 'The issue could be caused by a networking problem: please verify your internet access')
async_cb.reset()
print('Test when client_secret is wrong: PASS')
26 changes: 13 additions & 13 deletions tests/test_retry_mechanism.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_api_retry_enabled(accelize_drm, conf_json, cred_json, async_handler,
nb_attempts_expected = retry_duration / retry_sleep
assert nb_attempts_expected > 1
start = datetime.now()
with pytest.raises(accelize_drm.exceptions.DRMWSError) as excinfo:
with pytest.raises(accelize_drm.exceptions.DRMWSTimedOut) as excinfo:
drm_manager.activate()
end = datetime.now()
del drm_manager
Expand All @@ -104,8 +104,8 @@ def test_api_retry_enabled(accelize_drm, conf_json, cred_json, async_handler,
nb_attempts = int(m.group(1))
assert nb_attempts > 1
assert nb_attempts_expected - 1 <= nb_attempts <= nb_attempts_expected + 1
async_cb.assert_Error(accelize_drm.exceptions.DRMWSError.error_code, 'The issue could be caused by a networking problem: please verify your internet access')
async_cb.assert_Error(accelize_drm.exceptions.DRMWSError.error_code, 'Timeout on License request after')
async_cb.assert_Error(accelize_drm.exceptions.DRMWSTimedOut.error_code, 'Timeout on License request after')
async_cb.assert_Error(accelize_drm.exceptions.DRMWSTimedOut.error_code, 'The issue could be caused by a networking problem: please verify your internet access')
async_cb.reset()
logfile.remove()

Expand Down Expand Up @@ -159,7 +159,7 @@ def test_long_to_short_retry_switch_on_authentication(accelize_drm, conf_json,
assert get_context() == context
drm_manager.deactivate()
assert async_cb.was_called
assert async_cb.errcode == accelize_drm.exceptions.DRMWSError.error_code
assert async_cb.errcode == accelize_drm.exceptions.DRMWSTimedOut.error_code
assert search(r'Timeout on Authentication request after', async_cb.message, IGNORECASE)
context = get_context()
data_list = context['data']
Expand Down Expand Up @@ -222,7 +222,7 @@ def test_long_to_short_retry_switch_on_license(accelize_drm, conf_json, cred_jso
drm_manager.deactivate()
assert async_cb.was_called
assert 'Timeout on License' in async_cb.message
assert async_cb.errcode == accelize_drm.exceptions.DRMWSError.error_code
assert async_cb.errcode == accelize_drm.exceptions.DRMWSTimedOut.error_code
context = get_context()
data_list = context['data']
data = data_list.pop(0)
Expand Down Expand Up @@ -276,12 +276,9 @@ def test_api_retry_on_lost_connection(accelize_drm, conf_json, cred_json, async_
set_context(context)
assert get_context() == context

try:
with pytest.raises(accelize_drm.exceptions.DRMWSError) as excinfo:
drm_manager.activate()
except:
drm_manager.deactivate()
assert async_handler.get_error_code(str(excinfo.value)) == accelize_drm.exceptions.DRMWSError.error_code
with pytest.raises(accelize_drm.exceptions.DRMWSTimedOut) as excinfo:
drm_manager.activate()
assert async_handler.get_error_code(str(excinfo.value)) == accelize_drm.exceptions.DRMWSTimedOut.error_code
m = search(r'Timeout on License request after (\d+) attempts', str(excinfo.value))
assert m is not None
nb_attempts = int(m.group(1))
Expand All @@ -298,7 +295,7 @@ def test_api_retry_on_lost_connection(accelize_drm, conf_json, cred_json, async_
delta = int((parser.parse(time) - prev_time).total_seconds())
assert retry_timeout + retry_sleep - 1 <= delta <= retry_timeout + retry_sleep
prev_time = parser.parse(time)
async_cb.assert_Error(accelize_drm.exceptions.DRMWSError.error_code,
async_cb.assert_Error(accelize_drm.exceptions.DRMWSTimedOut.error_code,
r'The issue could be caused by a networking problem: please verify your internet access')
async_cb.reset()
logfile.remove()
Expand Down Expand Up @@ -355,7 +352,7 @@ def test_thread_retry_on_lost_connection(accelize_drm, conf_json, cred_json, asy
drm_manager.deactivate()
del drm_manager
assert async_cb.was_called
assert async_cb.errcode == accelize_drm.exceptions.DRMWSError.error_code
assert async_cb.errcode == accelize_drm.exceptions.DRMWSTimedOut.error_code
m = search(r'Timeout on License request after (\d+) attempts', async_cb.message)
assert m is not None
nb_attempts = int(m.group(1))
Expand All @@ -365,3 +362,6 @@ def test_thread_retry_on_lost_connection(accelize_drm, conf_json, cred_json, asy
assert len(attempts_list) == nb_retry
assert sorted(list(attempts_list)) == list(range(1,nb_retry+1))
logfile.remove()
async_cb.assert_Error(accelize_drm.exceptions.DRMWSTimedOut.error_code,
r'The issue could be caused by a networking problem: please verify your internet access')
async_cb.reset()

0 comments on commit 8a7ba0f

Please sign in to comment.