X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=xapp_onboarder%2Ftests%2Ftest_api.py;h=23a50d65602bfeb1eb2f758943d95ecac4d0960d;hb=a9b4e2aca7fdaae20d576805e136a17342f4c625;hp=b50709b0205aac1e6d8ac79e2b1f225a46bec907;hpb=3b56acc14a2308e853612e22738cd44687288149;p=it%2Fdev.git diff --git a/xapp_onboarder/tests/test_api.py b/xapp_onboarder/tests/test_api.py index b50709b..23a50d6 100644 --- a/xapp_onboarder/tests/test_api.py +++ b/xapp_onboarder/tests/test_api.py @@ -15,7 +15,7 @@ ################################################################################ from http import HTTPStatus -from tests.constants import mock_json_body, mock_json_body_url, helm_repo_index_response +from tests.constants import mock_json_body, mock_json_body_url_without_controls, mock_json_body_url, mock_json_body_without_controls, helm_repo_index_response def test_health(client): @@ -52,9 +52,29 @@ def test_onboard_post(client): assert response.content_type == 'application/json', 'Content type error' assert response.json == {'status': 'Created'}, 'Onboard failed' +def test_onboard_without_controls_post(client): + url = '/api/v1/onboard' + response = client.post(url, json=mock_json_body_without_controls) + assert response.status_code == HTTPStatus.BAD_REQUEST, 'Wrong status code' + assert response.content_type == 'application/json', 'Content type error' + assert response.json == {'error_message': "'__empty_control_section__' is a required property", + 'error_source': 'config-file.json', + 'status': 'Input payload validation failed'}, 'Onboard failed' + + def test_onboard_download_post(client): url = '/api/v1/onboard/download' response = client.post(url, json=mock_json_body_url) assert response.status_code == HTTPStatus.CREATED, 'Wrong status code' assert response.content_type == 'application/json', 'Content type error' - assert response.json == {'status': 'Created'}, 'Onboard failed' \ No newline at end of file + assert response.json == {'status': 'Created'}, 'Onboard failed' + + +def test_onboard_download_without_controls_post(client): + url = '/api/v1/onboard/download' + response = client.post(url, json=mock_json_body_url_without_controls) + assert response.status_code == HTTPStatus.BAD_REQUEST, 'Wrong status code' + assert response.content_type == 'application/json', 'Content type error' + assert response.json == {'error_message': "'__empty_control_section__' is a required property", + 'error_source': 'config-file.json', + 'status': 'Input payload validation failed'}, 'Onboard failed'