From: Swaraj Kumar Date: Wed, 12 Mar 2025 12:29:33 +0000 (+0530) Subject: Licence header and test case X-Git-Tag: 4.0.0~20^2 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F50%2F14250%2F2;p=aiml-fw%2Fawmf%2Ftm.git Licence header and test case Change-Id: I8ee55995db7c4080e43d751330bd56f93eb920a5 Signed-off-by: Swaraj Kumar --- diff --git a/tests/test_problemdetails.py b/tests/test_problemdetails.py new file mode 100644 index 0000000..c44d5eb --- /dev/null +++ b/tests/test_problemdetails.py @@ -0,0 +1,22 @@ +import json +import pytest +from flask import Flask +from trainingmgr.schemas.problemdetail_schema import ProblemDetails + +@pytest.fixture +def test_app(): + """ + Creates a Flask test app context for testing ProblemDetails JSON response. + """ + app = Flask(__name__) + app.config['TESTING'] = True + return app.test_client() +def test_problem_details_initialization(): + """ + Test that ProblemDetails initializes correctly with provided values. + """ + problem = ProblemDetails(400, "Bad Request", "Invalid input data") + assert problem.status == 400 + assert problem.title == "Bad Request" + assert problem.detail == "Invalid input data" + diff --git a/trainingmgr/schemas/problemdetail_schema.py b/trainingmgr/schemas/problemdetail_schema.py index 0453157..f05defd 100644 --- a/trainingmgr/schemas/problemdetail_schema.py +++ b/trainingmgr/schemas/problemdetail_schema.py @@ -1,3 +1,21 @@ +# ================================================================================== +# +# Copyright (c) 2025 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== + from flask import jsonify class ProblemDetails: