def test_parse_args_from_query_string(test_flask_client): """Tests for parse_args for URL query strings""" parser = reqparse.RequestParser() parser.add_argument("a", type=str, location="args", required=True) parser.add_argument("b", type=str, location="args", required=False) class Test(Resource): @staticmethod def get(): utils.parse_args(parser) api.FLASK_API.add_resource(Test, "/test") endpoint = endpoint_path("test") resp = test_flask_client.get(endpoint) assert resp.status_code == HTTPStatus.BAD_REQUEST resp = test_flask_client.get(f"{endpoint}?a=") assert resp.status_code == HTTPStatus.OK resp = test_flask_client.get(f"{endpoint}?a=&b=") assert resp.status_code == HTTPStatus.OK
""" Tests for the SHUTDOWN endpoint """ from http import HTTPStatus import mock import bluebird.api.resources.utils.utils as utils from tests.unit.api.resources import endpoint_path from tests.unit.api.resources import patch_utils_path _ENDPOINT = "shutdown" _ENDPOINT_PATH = endpoint_path(_ENDPOINT) def test_shutdown_post(test_flask_client): """Tests the POST method""" with mock.patch(patch_utils_path(_ENDPOINT), wraps=utils) as utils_patch: sim_proxy_mock = mock.Mock() utils_patch.sim_proxy.return_value = sim_proxy_mock # Test error when no shutdown function available sim_proxy_mock.shutdown.return_value = False resp = test_flask_client.post(_ENDPOINT_PATH) assert resp.status_code == HTTPStatus.INTERNAL_SERVER_ERROR assert (