From 0a4a7777cb51445a353b53dceb5add00a96f1000 Mon Sep 17 00:00:00 2001 From: qth2hi Date: Wed, 20 Mar 2024 17:28:38 +0100 Subject: [PATCH 1/2] Self test extensions: Self test: added JPP_0268 and JPP_0269 (topic: ${} substitution within strings; tests commented out) --- test/JPP_TestUsecases.csv | 2 +- test/JPP_TestUsecases.html | 4 +-- test/JPP_TestUsecases.rst | 4 +-- test/JPP_TestUsecases.txt | 4 +-- test/component_test.py | 4 +-- .../test_04_PARAMETER_SUBSTITUTION_BADCASE.py | 6 ++-- test/testconfig/TestConfig.py | 33 +++++++++++++++++-- test/testfiles/jpp-test_config_0268.jsonp | 5 ++- test/testfiles/jpp-test_config_0269.jsonp | 18 ++++++++++ test/testfiles/jpp-test_config_0270.jsonp | 19 +++++++++++ 10 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 test/testfiles/jpp-test_config_0269.jsonp create mode 100644 test/testfiles/jpp-test_config_0270.jsonp diff --git a/test/JPP_TestUsecases.csv b/test/JPP_TestUsecases.csv index 7cf98445..f9120837 100644 --- a/test/JPP_TestUsecases.csv +++ b/test/JPP_TestUsecases.csv @@ -37,7 +37,7 @@ JPP_0264|PARAMETER_SUBSTITUTION|BADCASE|JSON file with list parameter substituti JPP_0265|PARAMETER_SUBSTITUTION|BADCASE|JSON file with list parameter substitution in key name (composite data types not allowed in names) / (2) JPP_0266|PARAMETER_SUBSTITUTION|BADCASE|JSON file with dictionary parameter substitution in key name (composite data types not allowed in names) / (1) JPP_0267|PARAMETER_SUBSTITUTION|BADCASE|JSON file with dictionary parameter substitution in key name (composite data types not allowed in names) / (2) -JPP_0268|PARAMETER_SUBSTITUTION|BADCASE|JSON file containing a list; list index is defined by a parameter and wrapped in single quotes +JPP_0270|PARAMETER_SUBSTITUTION|BADCASE|JSON file containing a list; list index is defined by a parameter and wrapped in single quotes JPP_0300|VALUE_DETECTION|GOODCASE|JSON file with parameter of type 'list' / index (in square brackets) defined outside the curly brackets (valid syntax) JPP_0301|VALUE_DETECTION|GOODCASE|JSON file with expression containing more closing elements '}' than opening elements '${' (valid syntax) JPP_0302|VALUE_DETECTION|GOODCASE|JSON file with expression starting with '${' and ending with '}' / no further matching '${' and '}' in between (valid syntax) diff --git a/test/JPP_TestUsecases.html b/test/JPP_TestUsecases.html index 509b7049..911475e8 100644 --- a/test/JPP_TestUsecases.html +++ b/test/JPP_TestUsecases.html @@ -1258,7 +1258,7 @@ -JPP_0268 +JPP_0270 @@ -3662,7 +3662,7 @@
 

-
Generated: 15.03.2024 - 18:49:00
+
Generated: 20.03.2024 - 17:07:31
 
diff --git a/test/JPP_TestUsecases.rst b/test/JPP_TestUsecases.rst index f9d927f7..73b7198b 100644 --- a/test/JPP_TestUsecases.rst +++ b/test/JPP_TestUsecases.rst @@ -385,7 +385,7 @@ Test Use Cases ---- -* **Test JPP_0268** +* **Test JPP_0270** [PARAMETER_SUBSTITUTION / BADCASE] @@ -1173,5 +1173,5 @@ Test Use Cases ---- -Generated: 15.03.2024 - 18:49:00 +Generated: 20.03.2024 - 17:07:31 diff --git a/test/JPP_TestUsecases.txt b/test/JPP_TestUsecases.txt index 2287b394..863570d1 100644 --- a/test/JPP_TestUsecases.txt +++ b/test/JPP_TestUsecases.txt @@ -163,7 +163,7 @@ Test JPP_0267 / PARAMETER_SUBSTITUTION / BADCASE Description: JSON file with dictionary parameter substitution in key name (composite data types not allowed in names) / (2) Expectation: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ -Test JPP_0268 / PARAMETER_SUBSTITUTION / BADCASE +Test JPP_0270 / PARAMETER_SUBSTITUTION / BADCASE Description: JSON file containing a list; list index is defined by a parameter and wrapped in single quotes Expectation: No values are returned, and JsonPreprocessor throws an exception Hint.......: List indices must be of type 'int' @@ -485,5 +485,5 @@ Description: Relative path to JSON file Expectation: JsonPreprocessor resolves the relative path and returns values from JSON file Hint.......: Works with raw path to JSON file (path not normalized internally) ------------------------------------------------------------------------------------------------------------------------ -Generated: 15.03.2024 - 18:49:00 +Generated: 20.03.2024 - 17:07:31 diff --git a/test/component_test.py b/test/component_test.py index 3751f0ae..b337d7a1 100644 --- a/test/component_test.py +++ b/test/component_test.py @@ -22,8 +22,8 @@ # # -------------------------------------------------------------------------------------------------------------- # -VERSION = "0.33.0" -VERSION_DATE = "19.03.2024" +VERSION = "0.34.0" +VERSION_DATE = "20.03.2024" # # -------------------------------------------------------------------------------------------------------------- #TM*** diff --git a/test/pytest/pytestfiles/test_04_PARAMETER_SUBSTITUTION_BADCASE.py b/test/pytest/pytestfiles/test_04_PARAMETER_SUBSTITUTION_BADCASE.py index 94bf9df2..e5b06561 100644 --- a/test/pytest/pytestfiles/test_04_PARAMETER_SUBSTITUTION_BADCASE.py +++ b/test/pytest/pytestfiles/test_04_PARAMETER_SUBSTITUTION_BADCASE.py @@ -18,7 +18,7 @@ # # XC-CT/ECA3-Queckenstedt # -# 14.03.2024 - 15:46:24 +# 20.03.2024 - 17:07:31 # # -------------------------------------------------------------------------------------------------------------- @@ -178,7 +178,7 @@ def test_JPP_0267(self, Description): @pytest.mark.parametrize( "Description", ["JSON file containing a list; list index is defined by a parameter and wrapped in single quotes",] ) - def test_JPP_0268(self, Description): - nReturn = CExecute.Execute("JPP_0268") + def test_JPP_0270(self, Description): + nReturn = CExecute.Execute("JPP_0270") assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- diff --git a/test/testconfig/TestConfig.py b/test/testconfig/TestConfig.py index 7a1837bf..8628e05e 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -22,7 +22,7 @@ # # -------------------------------------------------------------------------------------------------------------- # -# 19.03.2024 +# 20.03.2024 # # !!! Temporarily tests are deactivated by the following line commented out: # # # listofdictUsecases.append(dictUsecase) @@ -1305,13 +1305,42 @@ # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} dictUsecase['TESTID'] = "JPP_0268" +dictUsecase['DESCRIPTION'] = "JSON file with dictionary parameter substitution in parameter value (composite data types not allowed in values)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "PARAMETER_SUBSTITUTION" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0268.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO !!! +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_0269" +dictUsecase['DESCRIPTION'] = "JSON file with list parameter substitution in parameter value (composite data types not allowed in names)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "PARAMETER_SUBSTITUTION" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0269.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO !!! +dictUsecase['EXPECTEDRETURN'] = None +# # # listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +# JPP_0270 does not really belong to PARAMETER_SUBSTITUTION, maybe move to another section +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_0270" dictUsecase['DESCRIPTION'] = "JSON file containing a list; list index is defined by a parameter and wrapped in single quotes" dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" dictUsecase['SECTION'] = "PARAMETER_SUBSTITUTION" dictUsecase['SUBSECTION'] = "BADCASE" dictUsecase['HINT'] = "List indices must be of type 'int'" dictUsecase['COMMENT'] = None -dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0268.jsonp" +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0270.jsonp" dictUsecase['EXPECTEDEXCEPTION'] = "The variable '${listval}['1']' is not available!" # but not the desired one; better: list incices must be of type int dictUsecase['EXPECTEDRETURN'] = None listofdictUsecases.append(dictUsecase) diff --git a/test/testfiles/jpp-test_config_0268.jsonp b/test/testfiles/jpp-test_config_0268.jsonp index 25d3ec64..491efaee 100644 --- a/test/testfiles/jpp-test_config_0268.jsonp +++ b/test/testfiles/jpp-test_config_0268.jsonp @@ -13,7 +13,6 @@ // limitations under the License. //************************************************************************** { - "intval" : 1, - "listval" : ["B", 2], - "param_${listval}['${intval}']}" : 3 + "dictParam" : {"A" : 0, "B" : 1}, + "param" : "${dictParam}" } \ No newline at end of file diff --git a/test/testfiles/jpp-test_config_0269.jsonp b/test/testfiles/jpp-test_config_0269.jsonp new file mode 100644 index 00000000..66b8f2bc --- /dev/null +++ b/test/testfiles/jpp-test_config_0269.jsonp @@ -0,0 +1,18 @@ +// Copyright 2020-2024 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. +//************************************************************************** +{ + "listParam" : ["A", "B"], + "param" : "${listParam}" +} \ No newline at end of file diff --git a/test/testfiles/jpp-test_config_0270.jsonp b/test/testfiles/jpp-test_config_0270.jsonp new file mode 100644 index 00000000..25d3ec64 --- /dev/null +++ b/test/testfiles/jpp-test_config_0270.jsonp @@ -0,0 +1,19 @@ +// Copyright 2020-2024 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. +//************************************************************************** +{ + "intval" : 1, + "listval" : ["B", 2], + "param_${listval}['${intval}']}" : 3 +} \ No newline at end of file From bb4b682281b4a05360e1206f98c31015a4635076 Mon Sep 17 00:00:00 2001 From: qth2hi Date: Wed, 20 Mar 2024 17:29:13 +0100 Subject: [PATCH 2/2] Update of code snippet generator (${} substitution within strings) --- test/testtools/GenSnippetsJPP.py | 71 +++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/test/testtools/GenSnippetsJPP.py b/test/testtools/GenSnippetsJPP.py index 3ffd1a7c..eecdbe82 100644 --- a/test/testtools/GenSnippetsJPP.py +++ b/test/testtools/GenSnippetsJPP.py @@ -22,8 +22,8 @@ # # ************************************************************************************************************** # -VERSION = "0.16.0" -VERSION_DATE = "19.03.2024" +VERSION = "0.17.0" +VERSION_DATE = "20.03.2024" # # ************************************************************************************************************** @@ -2010,6 +2010,70 @@ def GetNamingConventions(self): # eof def GetNamingConventions(self): + # -------------------------------------------------------------------------------------------------------------- + + def GetBlockedSubstitutions(self): + """Several snippets containing blocked dollar operator substitutions + """ + + sHeadline = "Several snippets containing blocked dollar operator substitutions" + + listCodeSnippets = [] + + listCodeSnippets.append("""{ + "dictParam" : {"A" : 0, "B" : 1}, + "param" : "${dictParam}" +} +""") + + listCodeSnippets.append("""{ + "listParam" : ["A", "B"], + "param" : "${listParam}" +} +""") + + listCodeSnippets.append("""{ + "floatParam" : 1.2, + "param" : "${floatParam}" +} +""") + + listCodeSnippets.append("""{ + "dictParam" : {"A" : 0, "B" : 1}, + "${dictParam}" : 1 +} +""") + + listCodeSnippets.append("""{ + "listParam" : ["A", "B"], + "${listParam}" : 1 +} +""") + + listCodeSnippets.append("""{ + "floatParam" : 1.2, + "${floatParam}" : 1 +} +""") + + listCodeSnippets.append("""{ + "keyA" : "keyA", + "dictParam" : {"${keyA}" : 1} +} +""") + + listCodeSnippets.append("""{ + "keyA" : "keyA", + "keyB" : "keyB", + "dictParam" : {"keyA" : {}}, + ${dictParam.keyA}['${keyB}_2'] : 2 +} +""") + + return sHeadline, listCodeSnippets + + # eof def GetBlockedSubstitutions(self): + # eof class CSnippets(): @@ -2148,6 +2212,9 @@ def GetNamingConventions(self): sHeadline, listCodeSnippets = oSnippets.GetNamingConventions() bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP") +sHeadline, listCodeSnippets = oSnippets.GetBlockedSubstitutions() +bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP") + print() print(COLBG + "done") print()