def test_post_argument_form(self, patch_config): arg_name = "test-arg" arg_value = "test-value" url = f"/v1/{ETOPO1_DATASET_NAME}" with api.app.test_request_context(url, method="POST", data={arg_name: arg_value}): assert api._find_request_argument(request, arg_name) == arg_value
def test_post_invalid_json(self, patch_config): arg_name = "test-arg" arg_value = "test-value" url = f"/v1/{ETOPO1_DATASET_NAME}" with api.app.test_request_context( url, method="POST", data={arg_name: arg_value}, headers={"content-type": "application/json"}, ): with pytest.raises(api.ClientError): assert api._find_request_argument(request, arg_name) == arg_value
def test_post_query_args_are_ignored(self, patch_config): arg_name = "test-arg" arg_value = "test-value" url = f"/v1/{ETOPO1_DATASET_NAME}?{arg_name}={arg_value}" with api.app.test_request_context(url, method="POST"): assert api._find_request_argument(request, arg_name) is None
def test_get_argument(self, patch_config): arg_name = "test-arg" arg_value = "test-value" url = f"/v1/{ETOPO1_DATASET_NAME}?{arg_name}={arg_value}" with api.app.test_request_context(url): assert api._find_request_argument(request, arg_name) == arg_value
def test_no_argument(self, patch_config): url = f"/v1/{ETOPO1_DATASET_NAME}" with api.app.test_request_context(url): assert api._find_request_argument(request, "no-arg") is None