diff options
-rw-r--r-- | test/mocks/prov-mns-provider/src/tests/test_invalid_requests.py | 34 |
1 files changed, 13 insertions, 21 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 b7bd40741..6240c660a 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 @@ -30,28 +30,20 @@ def test_bad_moi_class(req_method, req_params): assert req.status_code == requests.codes.not_acceptable assert INVALID_CLASS_MSG in req.text -def test_bad_prefix(): + +@pytest.mark.parametrize(('url'), [BAD_PREFIX_URI_BASE_STRING, + BAD_PREFIX1_URI_BASE_STRING]) +@pytest.mark.parametrize(('req_method', 'req_params'), [ + (getattr(requests, 'get'), {"auth": AUTH_STRING}), + (getattr(requests, 'put'), {"auth": AUTH_STRING, "json": MOI_DATA_TMPL}), + (getattr(requests, 'patch'), {"auth": AUTH_STRING, "json": MOI_DATA_PATCH}), + (getattr(requests, 'delete'), {"auth": AUTH_STRING}) + ]) +def test_bad_prefix(url, req_method, req_params): '''Check service returns proper http code and error msg if URI prefix is invalid''' - for url in BAD_PREFIX_URI_BASE_STRING, BAD_PREFIX1_URI_BASE_STRING: - req = requests.get('{0}'.format(url), - auth=AUTH_STRING) - assert req.status_code == requests.codes.not_found - assert INVALID_PREFIX_MSG in req.text - - req = requests.put('{0}'.format(url), - auth=AUTH_STRING, json=MOI_DATA_TMPL) - assert req.status_code == requests.codes.not_found - assert INVALID_PREFIX_MSG in req.text - - req = requests.patch('{0}'.format(url), - auth=AUTH_STRING, json=MOI_DATA_PATCH) - assert req.status_code == requests.codes.not_found - assert INVALID_PREFIX_MSG in req.text - - req = requests.delete('{0}'.format(url), - auth=AUTH_STRING) - assert req.status_code == requests.codes.not_found - assert INVALID_PREFIX_MSG in req.text + req = req_method(url, **req_params) + assert req.status_code == requests.codes.not_found + assert INVALID_PREFIX_MSG in req.text |