From 457f100dcc6da7ba4dd40498230c712c71517589 Mon Sep 17 00:00:00 2001 From: qth2gi Date: Fri, 18 Jul 2025 16:08:53 +0200 Subject: [PATCH] Added inline Python code self test "JPP_2100" --- test/JPP_TestUsecases.csv | 1 + test/JPP_TestUsecases.html | 37 +++++++++++++- test/JPP_TestUsecases.rst | 16 +++++- test/JPP_TestUsecases.txt | 8 ++- test/component_test.py | 4 +- .../test_27_INLINE_CODE_GOODCASE.py | 40 +++++++++++++++ test/testconfig/TestConfig.py | 51 ++++++++++++++++++- test/testfiles/jpp-test_config_2100.jsonp | 48 +++++++++++++++++ 8 files changed, 199 insertions(+), 6 deletions(-) create mode 100644 test/pytest/pytestfiles/test_27_INLINE_CODE_GOODCASE.py create mode 100644 test/testfiles/jpp-test_config_2100.jsonp diff --git a/test/JPP_TestUsecases.csv b/test/JPP_TestUsecases.csv index 4cbf5d3..89f68e5 100644 --- a/test/JPP_TestUsecases.csv +++ b/test/JPP_TestUsecases.csv @@ -202,3 +202,4 @@ JPP_2055|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing s JPP_2056|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing scope (7) JPP_2057|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing scope (8) JPP_2058|PARAMETER_SCOPE|BADCASE|JSON file containing a parameter with missing scope (9) +JPP_2100|INLINE_CODE|GOODCASE|JSON file containing Python inline code diff --git a/test/JPP_TestUsecases.html b/test/JPP_TestUsecases.html index d201679..5c61962 100644 --- a/test/JPP_TestUsecases.html +++ b/test/JPP_TestUsecases.html @@ -6737,12 +6737,47 @@ + + + + + +203 + + + + + +JPP_2100 + + + + +INLINE_CODE + + + + +GOODCASE + + + + +JSON file containing Python inline code
+Expected: JsonPreprocessor returns expected values +
+https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454 +
+Test needs to be adapted after bugfixing +
+ +
 

-
Generated: 10.04.2025 - 17:21:06
+
Generated: 18.07.2025 - 16:02:56
 
diff --git a/test/JPP_TestUsecases.rst b/test/JPP_TestUsecases.rst index 51ec9ce..3a48202 100644 --- a/test/JPP_TestUsecases.rst +++ b/test/JPP_TestUsecases.rst @@ -2125,5 +2125,19 @@ Test Use Cases ---- -Generated: 10.04.2025 - 17:21:06 +* **Test JPP_2100** + + [INLINE_CODE / GOODCASE] + + **JSON file containing Python inline code** + + Expected: JsonPreprocessor returns expected values + + *Comment: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454* + + *Hint: Test needs to be adapted after bugfixing* + +---- + +Generated: 18.07.2025 - 16:02:56 diff --git a/test/JPP_TestUsecases.txt b/test/JPP_TestUsecases.txt index 73e9a1c..6c7bc27 100644 --- a/test/JPP_TestUsecases.txt +++ b/test/JPP_TestUsecases.txt @@ -868,5 +868,11 @@ Test JPP_2058 / PARAMETER_SCOPE / BADCASE Description: JSON file containing a parameter with missing scope (9) Expectation: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ -Generated: 10.04.2025 - 17:21:06 +Test JPP_2100 / INLINE_CODE / GOODCASE +Description: JSON file containing Python inline code +Expectation: JsonPreprocessor returns expected values +Comment....: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454 +Hint.......: Test needs to be adapted after bugfixing +------------------------------------------------------------------------------------------------------------------------ +Generated: 18.07.2025 - 16:02:56 diff --git a/test/component_test.py b/test/component_test.py index 1ff943a..d198208 100644 --- a/test/component_test.py +++ b/test/component_test.py @@ -22,8 +22,8 @@ # # -------------------------------------------------------------------------------------------------------------- # -VERSION = "0.60.0" -VERSION_DATE = "23.04.2025" +VERSION = "0.61.0" +VERSION_DATE = "18.07.2025" # # -------------------------------------------------------------------------------------------------------------- #TM*** diff --git a/test/pytest/pytestfiles/test_27_INLINE_CODE_GOODCASE.py b/test/pytest/pytestfiles/test_27_INLINE_CODE_GOODCASE.py new file mode 100644 index 0000000..2d0decd --- /dev/null +++ b/test/pytest/pytestfiles/test_27_INLINE_CODE_GOODCASE.py @@ -0,0 +1,40 @@ +# ************************************************************************************************************** +# Copyright 2020-2023 Robert Bosch GmbH +# +# 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. +# -------------------------------------------------------------------------------------------------------------- +# +# test_27_INLINE_CODE_GOODCASE.py +# +# XC-HWP/ESW3-Queckenstedt +# +# 18.07.2025 - 16:02:56 +# +# -------------------------------------------------------------------------------------------------------------- + +import pytest +from pytestlibs.CExecute import CExecute + +# -------------------------------------------------------------------------------------------------------------- + +class Test_INLINE_CODE_GOODCASE: + +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor returns expected values + @pytest.mark.parametrize( + "Description", ["JSON file containing Python inline code",] + ) + def test_JPP_2100(self, Description): + nReturn = CExecute.Execute("JPP_2100") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- diff --git a/test/testconfig/TestConfig.py b/test/testconfig/TestConfig.py index 2dd8b59..ddf952e 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -22,7 +22,7 @@ # # -------------------------------------------------------------------------------------------------------------- # -# 23.04.2025 +# 18.07.2025 # # !!! Temporarily tests are deactivated by the following line commented out: # # # listofdictUsecases.append(dictUsecase) @@ -4425,3 +4425,52 @@ del dictUsecase # -------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_2100" +dictUsecase['DESCRIPTION'] = "JSON file containing Python inline code" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns expected values" +dictUsecase['SECTION'] = "INLINE_CODE" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = "Test needs to be adapted after bugfixing" +dictUsecase['COMMENT'] = "https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454" +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_2100.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +[DOTDICT] (18/1) > {A} [INT] : 0 +[DOTDICT] (18/2) > {B} [INT] : 1 +[DOTDICT] (18/3) > {L1} [LIST] (3/1) > [INT] : 1 +[DOTDICT] (18/3) > {L1} [LIST] (3/2) > [INT] : 2 +[DOTDICT] (18/3) > {L1} [LIST] (3/3) > [INT] : 3 +[DOTDICT] (18/4) > {L2} [LIST] (3/1) > [INT] : 4 +[DOTDICT] (18/4) > {L2} [LIST] (3/2) > [INT] : 5 +[DOTDICT] (18/4) > {L2} [LIST] (3/3) > [INT] : 6 +[DOTDICT] (18/5) > {kA} [STR] : 'kA' +[DOTDICT] (18/6) > {kB} [STR] : 'kB' +[DOTDICT] (18/7) > {D1} [DOTDICT] (2/1) > {kA} [STR] : 'vA' +[DOTDICT] (18/7) > {D1} [DOTDICT] (2/2) > {kB} [STR] : 'vB' +[DOTDICT] (18/8) > {choice} [BOOL] : True +[DOTDICT] (18/9) > {value01} [INT] : 10 +[DOTDICT] (18/10) > {value02} [LIST] (2/1) > [INT] : 1 +[DOTDICT] (18/10) > {value02} [LIST] (2/2) > [INT] : 2 +[DOTDICT] (18/11) > {value04} [INT] : 4 +[DOTDICT] (18/12) > {code04} [STR] : '0 if True else 1' +[DOTDICT] (18/13) > {value04b} [INT] : 4 +[DOTDICT] (18/14) > {value05} [INT] : 5 +[DOTDICT] (18/15) > {code05} [STR] : '0 if not True else 1' +[DOTDICT] (18/16) > {value05b} [INT] : 5 +[DOTDICT] (18/17) > {values01} [DOTDICT] (3/1) > {kA} [STR] : 'A' +[DOTDICT] (18/17) > {values01} [DOTDICT] (3/2) > {kB} [INT] : 0 +[DOTDICT] (18/17) > {values01} [DOTDICT] (3/3) > {kC} [STR] : 'Z' +[DOTDICT] (18/18) > {values02} [LIST] (4/1) > [INT] : 1 +[DOTDICT] (18/18) > {values02} [LIST] (4/2) > [INT] : 2 +[DOTDICT] (18/18) > {values02} [LIST] (4/3) > [INT] : 3 +[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/1) > [INT] : 4 +[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/2) > [INT] : 5 +[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/3) > [INT] : 6 +[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/4) > [INT] : 1 +[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/5) > [INT] : 2 +[DOTDICT] (18/18) > {values02} [LIST] (4/4) > [LIST] (6/6) > [INT] : 3 +""" +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- diff --git a/test/testfiles/jpp-test_config_2100.jsonp b/test/testfiles/jpp-test_config_2100.jsonp new file mode 100644 index 0000000..1fa3aa9 --- /dev/null +++ b/test/testfiles/jpp-test_config_2100.jsonp @@ -0,0 +1,48 @@ +// Copyright 2020-2025 Robert Bosch GmbH +// +// 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. +//************************************************************************** +{ + // Test needs to be adapted after bugfixing + // https://github.com/test-fullautomation/python-jsonpreprocessor/issues/454 + // + "A" : 0, + "B" : 1, + "L1" : [1,2,3], + "L2" : [4,5,6], + "kA" : "kA", + "kB" : "kB", + "D1" : {"kA" : "vA", "kB" : "vB"}, + "choice" : True, + // + "value01" : <>, + "value02" : <>, + // !err! "value03" : <>, + // + "value04" : <>, + "code04" : "${A} if ${choice} else ${B}", + "value04b" : <>, + "value05" : <>, + "code05" : "${A} if not ${choice} else ${B}", + "value05b" : <>, + // + "values01" : {"kA" : "A", + "kB" : <>, + "kC" : "Z"}, + // + "values02" : <> + // + // !err! "value06" : ${L1}[<>] + // + // !err! "value07" : ${D1}[<>] +}