diff options
author | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2020-04-20 06:41:04 -0700 |
---|---|---|
committer | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2020-04-20 06:42:58 -0700 |
commit | d0bbb7aa2a7cd41b86f8d1b8115acf4d9b28dba3 (patch) | |
tree | fc62b191b7cd7568a7c5d2957be89bd7853c1eba /test/mocks | |
parent | 55329d124be43cf9073d33a66e30c8f231e849ec (diff) |
Leverage pytest parametrize mark in test_rest_api_endpoints
Change-Id: Ia29f79227e21e623489a7b340496f18def5f7a52
Issue-ID: INT-1529
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'test/mocks')
-rw-r--r-- | test/mocks/prov-mns-provider/src/tests/test_rest_api_endpoints.py | 51 |
1 files changed, 17 insertions, 34 deletions
diff --git a/test/mocks/prov-mns-provider/src/tests/test_rest_api_endpoints.py b/test/mocks/prov-mns-provider/src/tests/test_rest_api_endpoints.py index 69e66e302..155ed9dd5 100644 --- a/test/mocks/prov-mns-provider/src/tests/test_rest_api_endpoints.py +++ b/test/mocks/prov-mns-provider/src/tests/test_rest_api_endpoints.py @@ -1,3 +1,4 @@ +import pytest from common import * # pylint: disable=W0614 def test_put(): @@ -16,37 +17,19 @@ def test_put(): assert req_put.status_code == requests.codes.created -def test_get(): - '''Validate GET request''' - - req_get = requests.get('{0}'.format(URI_GET_STRING), auth=AUTH_STRING) - - if req_get.status_code != requests.codes.ok: - logger.error('GET request to {0} failed'.format(URI_GET_STRING)) - logger.debug('Response content: {0}'.format(req_get.text)) - - assert req_get.status_code == requests.codes.ok - -def test_patch(): - '''Validate PATCH request''' - - req_patch = requests.patch('{0}'.format(URI_PATCH_STRING), - auth=AUTH_STRING, json=MOI_DATA_PATCH) - - if req_patch.status_code != requests.codes.ok: - logger.error('PATCH request to {0} failed'.format(URI_PATCH_STRING)) - logger.debug('Response content: {0}'.format(req_patch.text)) - - assert req_patch.status_code == requests.codes.ok - -def test_delete(): - '''Validate DELETE request''' - - req_delete = requests.delete('{0}'.format(URI_DELETE_STRING), - auth=AUTH_STRING) - - if req_delete.status_code != requests.codes.ok: - logger.error('DELETE request to {0} failed'.format(URI_DELETE_STRING)) - logger.debug('Response content: {0}'.format(req_delete.text)) - - assert req_delete.status_code == requests.codes.ok +@pytest.mark.parametrize(('url', 'req_method', 'req_params'),[ + (URI_GET_STRING, getattr(requests, 'get'), { "auth": AUTH_STRING }), + (URI_PATCH_STRING, getattr(requests, 'patch'), { "auth": AUTH_STRING, + "json": MOI_DATA_PATCH}), + (URI_DELETE_STRING, getattr(requests, 'delete'), { "auth": AUTH_STRING }) + ]) +def test_api_methods(url, req_method, req_params): + '''Valide request''' + req = req_method(url, **req_params) + + if req.status_code != requests.codes.ok: + logger.error('{0} request to {1} failed'.format( + req_method.__name__.upper(), url)) + logger.debug('Response content: {0}'.format(req.text)) + + assert req.status_code == requests.codes.ok |