diff options
author | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2020-04-20 05:21:20 -0700 |
---|---|---|
committer | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2020-04-20 06:42:58 -0700 |
commit | 55329d124be43cf9073d33a66e30c8f231e849ec (patch) | |
tree | 19a65866d1cac5ced0b0dc8aa09f7a4aa31b6806 /test/mocks/prov-mns-provider/src | |
parent | 738954b053e173129b2c9a88e9cb758638785101 (diff) |
Leverage pytest parametrize mark in test_bad_prefix test
Change-Id: I0c0ea8612e0f0ac6b2198dc78908bd604f5ad61c
Issue-ID: INT-1529
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test/mocks/prov-mns-provider/src')
-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 |