aboutsummaryrefslogtreecommitdiffstats
path: root/test/mocks/prov-mns-provider
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-04-20 04:01:10 -0700
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-04-20 06:42:58 -0700
commite7aae53c5535a6187c4ad37f4efc4556368ad1bc (patch)
tree55d25eae0376bcdb7b25dc0b73d4ce964e372ec5 /test/mocks/prov-mns-provider
parent9edfcd99affa1ca4b444931070e3b4652c2a80bf (diff)
Refactor test_unauthorized() to leverage pytest parametrize mark
Change-Id: I52079b276332c0bf2ffcea047ab8129066aff185 Issue-ID: INT-1529 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test/mocks/prov-mns-provider')
-rw-r--r--test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py29
1 files changed, 11 insertions, 18 deletions
diff --git a/test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py b/test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py
index 5c77cdcfc..11632bdb6 100644
--- a/test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py
+++ b/test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py
@@ -1,25 +1,18 @@
+import pytest
from common import * # pylint: disable=W0614
-def test_unauthorized():
+@pytest.mark.parametrize(('req_method', 'url', 'req_params'), [
+ (getattr(requests, 'get'), URI_GET_STRING, {"auth": INVALID_AUTH_STRING}),
+ (getattr(requests, 'put'), URI_PUT_STRING, {"auth": INVALID_AUTH_STRING,
+ "json": MOI_DATA_TMPL}),
+ (getattr(requests, 'patch'), URI_PATCH_STRING, {"auth": INVALID_AUTH_STRING,
+ "json": MOI_DATA_PATCH}),
+ (getattr(requests, 'delete'), URI_DELETE_STRING, {"auth": INVALID_AUTH_STRING})
+ ])
+def test_unauthorized(req_method, url, req_params):
'''Check service denies access if
invalid credentials provided'''
-
- req = requests.get('{0}'.format(URI_GET_STRING), auth=INVALID_AUTH_STRING)
- assert req.status_code == requests.codes.unauthorized
- assert UNAUTHORIZED_MSG in req.text
-
- req = requests.put('{0}'.format(URI_PUT_STRING), auth=INVALID_AUTH_STRING,
- json=MOI_DATA_TMPL)
- assert req.status_code == requests.codes.unauthorized
- assert UNAUTHORIZED_MSG in req.text
-
- req = requests.patch('{0}'.format(URI_PATCH_STRING),
- auth=INVALID_AUTH_STRING, json=MOI_DATA_PATCH)
- assert req.status_code == requests.codes.unauthorized
- assert UNAUTHORIZED_MSG in req.text
-
- req = requests.delete('{0}'.format(URI_DELETE_STRING),
- auth=INVALID_AUTH_STRING)
+ req = req_method(url, **req_params)
assert req.status_code == requests.codes.unauthorized
assert UNAUTHORIZED_MSG in req.text