diff --git a/test/JPP_TestUsecases.csv b/test/JPP_TestUsecases.csv index 345ed709..0ffcf96b 100644 --- a/test/JPP_TestUsecases.csv +++ b/test/JPP_TestUsecases.csv @@ -39,6 +39,7 @@ JPP_0371|VALUE_DETECTION|BADCASE|JSON file with expression starting with '${' an JPP_0500|COMPOSITE_EXPRESSIONS|GOODCASE|JSON file with composite data structure (nested lists and dictionaries 1) JPP_0501|COMPOSITE_EXPRESSIONS|GOODCASE|JSON file with composite data structure (nested lists and dictionaries 2) JPP_0502|COMPOSITE_EXPRESSIONS|GOODCASE|JSON file with composite data structure (nested lists and dictionaries 3 / some key names with dots inside) +JPP_0505|COMPOSITE_EXPRESSIONS|GOODCASE|JSON file with composite strings containing several times a colon and a comma (JSON syntax elements) JPP_0506|COMPOSITE_EXPRESSIONS|GOODCASE|JSON file with composite strings containing several combinations of curly brackets and special characters before JPP_0550|COMPOSITE_EXPRESSIONS|BADCASE|JSON file with composite data structure (nested lists and dictionaries / some key names with dots inside) JPP_0900|COMMON_SYNTAX_VIOLATIONS|GOODCASE|JSON file with syntax error, that is commented out @@ -48,3 +49,6 @@ JPP_0952|COMMON_SYNTAX_VIOLATIONS|BADCASE|JSON file with syntax error (3) JPP_0953|COMMON_SYNTAX_VIOLATIONS|BADCASE|JSON file with syntax error (4): file is completely empty JPP_0954|COMMON_SYNTAX_VIOLATIONS|BADCASE|JSON file with syntax error (5): file is empty (multiple pairs of brackets only) JPP_1000|IMPLICIT_CREATION|GOODCASE|JSON file with dictionary keys to be created implicitly +JPP_1150|CYCLIC_IMPORTS|BADCASE|JSON file with cyclic imports (JSON file imports itself) +JPP_1151|CYCLIC_IMPORTS|BADCASE|JSON file with cyclic imports (JSON file imports another file, that is already imported) +JPP_1200|PATH_FORMATS|GOODCASE|Relative path to JSON file diff --git a/test/JPP_TestUsecases.html b/test/JPP_TestUsecases.html index 29042094..42e3616d 100644 --- a/test/JPP_TestUsecases.html +++ b/test/JPP_TestUsecases.html @@ -37,7 +37,7 @@ -JPP_0001 +JPP_0001 @@ -70,7 +70,7 @@ -JPP_0002 +JPP_0002 @@ -103,7 +103,7 @@ -JPP_0003 +JPP_0003 @@ -136,7 +136,7 @@ -JPP_0100 +JPP_0100 @@ -169,7 +169,7 @@ -JPP_0101 +JPP_0101 @@ -202,7 +202,7 @@ -JPP_0102 +JPP_0102 @@ -235,7 +235,7 @@ -JPP_0200 +JPP_0200 @@ -268,7 +268,7 @@ -JPP_0201 +JPP_0201 @@ -301,7 +301,7 @@ -JPP_0202 +JPP_0202 @@ -334,7 +334,7 @@ -JPP_0203 +JPP_0203 @@ -367,7 +367,7 @@ -JPP_0204 +JPP_0204 @@ -400,7 +400,7 @@ -JPP_0250 +JPP_0250 @@ -433,7 +433,7 @@ -JPP_0251 +JPP_0251 @@ -466,7 +466,7 @@ -JPP_0252 +JPP_0252 @@ -499,7 +499,7 @@ -JPP_0253 +JPP_0253 @@ -532,7 +532,7 @@ -JPP_0254 +JPP_0254 @@ -565,7 +565,7 @@ -JPP_0255 +JPP_0255 @@ -598,7 +598,7 @@ -JPP_0257 +JPP_0257 @@ -631,7 +631,7 @@ -JPP_0259 +JPP_0259 @@ -664,7 +664,7 @@ -JPP_0300 +JPP_0300 @@ -698,7 +698,7 @@ -JPP_0301 +JPP_0301 @@ -732,7 +732,7 @@ -JPP_0302 +JPP_0302 @@ -766,7 +766,7 @@ -JPP_0304 +JPP_0304 @@ -800,7 +800,7 @@ -JPP_0350 +JPP_0350 @@ -834,7 +834,7 @@ -JPP_0351 +JPP_0351 @@ -868,7 +868,7 @@ -JPP_0352 +JPP_0352 @@ -902,7 +902,7 @@ -JPP_0353 +JPP_0353 @@ -936,7 +936,7 @@ -JPP_0354 +JPP_0354 @@ -970,7 +970,7 @@ -JPP_0357 +JPP_0357 @@ -1004,7 +1004,7 @@ -JPP_0359 +JPP_0359 @@ -1038,7 +1038,7 @@ -JPP_0361 +JPP_0361 @@ -1072,7 +1072,7 @@ -JPP_0367 +JPP_0367 @@ -1106,7 +1106,7 @@ -JPP_0368 +JPP_0368 @@ -1140,7 +1140,7 @@ -JPP_0369 +JPP_0369 @@ -1174,7 +1174,7 @@ -JPP_0370 +JPP_0370 @@ -1208,7 +1208,7 @@ -JPP_0371 +JPP_0371 @@ -1242,7 +1242,7 @@ -JPP_0500 +JPP_0500 @@ -1276,7 +1276,7 @@ -JPP_0501 +JPP_0501 @@ -1310,7 +1310,7 @@ -JPP_0502 +JPP_0502 @@ -1344,7 +1344,7 @@ -JPP_0506 +JPP_0505 @@ -1359,7 +1359,7 @@ -JSON file with composite strings containing several combinations of curly brackets and special characters before
+JSON file with composite strings containing several times a colon and a comma (JSON syntax elements)
Expected: JsonPreprocessor returns expected value @@ -1377,7 +1377,40 @@ -JPP_0550 +JPP_0506 + + + + +COMPOSITE_EXPRESSIONS + + + + +GOODCASE + + + + +JSON file with composite strings containing several combinations of curly brackets and special characters before
+Expected: JsonPreprocessor returns expected value + + +
+ + + + + + + +42 + + + + + +JPP_0550 @@ -1405,13 +1438,13 @@ -42 +43 -JPP_0900 +JPP_0900 @@ -1438,13 +1471,13 @@ -43 +44 -JPP_0950 +JPP_0950 @@ -1471,13 +1504,13 @@ -44 +45 -JPP_0951 +JPP_0951 @@ -1504,13 +1537,13 @@ -45 +46 -JPP_0952 +JPP_0952 @@ -1537,13 +1570,13 @@ -46 +47 -JPP_0953 +JPP_0953 @@ -1570,13 +1603,13 @@ -47 +48 -JPP_0954 +JPP_0954 @@ -1603,13 +1636,13 @@ -48 +49 -JPP_1000 +JPP_1000 @@ -1631,12 +1664,112 @@
+ + + + + +50 + + + + + +JPP_1150 + + + + +CYCLIC_IMPORTS + + + + +BADCASE + + + + +JSON file with cyclic imports (JSON file imports itself)
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ + + + + + + +51 + + + + + +JPP_1151 + + + + +CYCLIC_IMPORTS + + + + +BADCASE + + + + +JSON file with cyclic imports (JSON file imports another file, that is already imported)
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ + + + + + + +52 + + + + + +JPP_1200 + + + + +PATH_FORMATS + + + + +GOODCASE + + + + +Relative path to JSON file
+Expected: JsonPreprocessor resolves the relative path and returns values from JSON file + +
+Works with raw path to JSON file (path not normalized internally) +
+ +
 

-
Generated: 13.09.2023 - 10:58:36
+
Generated: 29.09.2023 - 15:06:38
 
diff --git a/test/JPP_TestUsecases.rst b/test/JPP_TestUsecases.rst index dec15fc8..2ee51968 100644 --- a/test/JPP_TestUsecases.rst +++ b/test/JPP_TestUsecases.rst @@ -445,6 +445,16 @@ Test Use Cases ---- +* **Test JPP_0505** + + [COMPOSITE_EXPRESSIONS / GOODCASE] + + **JSON file with composite strings containing several times a colon and a comma (JSON syntax elements)** + + Expected: JsonPreprocessor returns expected value + +---- + * **Test JPP_0506** [COMPOSITE_EXPRESSIONS / GOODCASE] @@ -537,5 +547,37 @@ Test Use Cases ---- -Generated: 13.09.2023 - 10:58:36 +* **Test JPP_1150** + + [CYCLIC_IMPORTS / BADCASE] + + **JSON file with cyclic imports (JSON file imports itself)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +* **Test JPP_1151** + + [CYCLIC_IMPORTS / BADCASE] + + **JSON file with cyclic imports (JSON file imports another file, that is already imported)** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +* **Test JPP_1200** + + [PATH_FORMATS / GOODCASE] + + **Relative path to JSON file** + + Expected: JsonPreprocessor resolves the relative path and returns values from JSON file + + *Hint: Works with raw path to JSON file (path not normalized internally)* + +---- + +Generated: 29.09.2023 - 15:06:38 diff --git a/test/JPP_TestUsecases.txt b/test/JPP_TestUsecases.txt index 190200f8..55c3f693 100644 --- a/test/JPP_TestUsecases.txt +++ b/test/JPP_TestUsecases.txt @@ -191,6 +191,10 @@ Description: JSON file with composite data structure (nested lists and dictionar Expectation: JsonPreprocessor returns expected value Hint.......: Standard notation ------------------------------------------------------------------------------------------------------------------------ +Test JPP_0505 / COMPOSITE_EXPRESSIONS / GOODCASE +Description: JSON file with composite strings containing several times a colon and a comma (JSON syntax elements) +Expectation: JsonPreprocessor returns expected value +------------------------------------------------------------------------------------------------------------------------ Test JPP_0506 / COMPOSITE_EXPRESSIONS / GOODCASE Description: JSON file with composite strings containing several combinations of curly brackets and special characters before Expectation: JsonPreprocessor returns expected value @@ -228,5 +232,18 @@ Test JPP_1000 / IMPLICIT_CREATION / GOODCASE Description: JSON file with dictionary keys to be created implicitly Expectation: JsonPreprocessor returns values ------------------------------------------------------------------------------------------------------------------------ -Generated: 13.09.2023 - 10:58:36 +Test JPP_1150 / CYCLIC_IMPORTS / BADCASE +Description: JSON file with cyclic imports (JSON file imports itself) +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Test JPP_1151 / CYCLIC_IMPORTS / BADCASE +Description: JSON file with cyclic imports (JSON file imports another file, that is already imported) +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Test JPP_1200 / PATH_FORMATS / GOODCASE +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: 29.09.2023 - 15:06:38 diff --git a/test/component_test.py b/test/component_test.py index 0a6f89ea..fcc66d8d 100644 --- a/test/component_test.py +++ b/test/component_test.py @@ -22,8 +22,8 @@ # # -------------------------------------------------------------------------------------------------------------- # -VERSION = "0.9.0" -VERSION_DATE = "13.09.2023" +VERSION = "0.12.0" +VERSION_DATE = "29.09.2023" # # -------------------------------------------------------------------------------------------------------------- #TM*** @@ -403,8 +403,6 @@ def AnalyzeExceptions(EXPECTEDEXCEPTION=None, sException=None): EXPECTEDEXCEPTION = dictUsecase['EXPECTEDEXCEPTION'] EXPECTEDRETURN = dictUsecase['EXPECTEDRETURN'] - JSONFILE = CString.NormalizePath(JSONFILE, sReferencePathAbs=TESTCONFIGPATH) - # get optional parameters HINT = None if "HINT" in dictUsecase: @@ -412,6 +410,16 @@ def AnalyzeExceptions(EXPECTEDEXCEPTION=None, sException=None): COMMENT = None if "COMMENT" in dictUsecase: COMMENT = dictUsecase['COMMENT'] + USERAWPATH = False + if "USERAWPATH" in dictUsecase: + USERAWPATH = dictUsecase['USERAWPATH'] + + if USERAWPATH is not True: + # Default is that the path 'JSONFILE' is normalized before the JsonPreprocessor is called. + # The reference for relative paths is the position of the file TestConfig.py (TESTCONFIGPATH). + # In case of USERAWPATH is True, the path 'JSONFILE' is not normalized. + # And the path is relative to the position of the executing script (this script). + JSONFILE = CString.NormalizePath(JSONFILE, sReferencePathAbs=TESTCONFIGPATH) # get derived parameters TESTFULLNAME = f"{TESTID}-({SECTION})-[{SUBSECTION}]" diff --git a/test/libs/CGenCode.py b/test/libs/CGenCode.py index 20f6c2ba..d40d3930 100644 --- a/test/libs/CGenCode.py +++ b/test/libs/CGenCode.py @@ -20,7 +20,7 @@ # # XC-CT/ECA3-Queckenstedt # -# 23.06.2023 +# 27.09.2023 # # -------------------------------------------------------------------------------------------------------------- @@ -185,11 +185,19 @@ def GenCode(self): nCntUsecases = 0 for dictUsecase in listofdictUsecases: nCntUsecases = nCntUsecases + 1 - TESTID = dictUsecase['TESTID'] - DESCRIPTION = dictUsecase['DESCRIPTION'] - EXPECTATION = dictUsecase['EXPECTATION'] - SECTION = dictUsecase['SECTION'] - SUBSECTION = dictUsecase['SUBSECTION'] + TESTID = dictUsecase['TESTID'] + DESCRIPTION = dictUsecase['DESCRIPTION'] + EXPECTATION = dictUsecase['EXPECTATION'] + SECTION = dictUsecase['SECTION'] + SUBSECTION = dictUsecase['SUBSECTION'] + + # prepare web server path to JSON file (will be a link inside the HTML use case list) + JSONFILE = dictUsecase['JSONFILE'] + TESTCONFIGPATH = self.__oConfig.Get('TESTCONFIGPATH') + JSONFILE = CString.NormalizePath(JSONFILE, sReferencePathAbs=TESTCONFIGPATH) + JSONFILEname = os.path.basename(JSONFILE) + JSONFILElink = f"https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/test/testfiles/{JSONFILEname}" + # optional ones COMMENT = None if "COMMENT" in dictUsecase: @@ -231,7 +239,7 @@ def GenCode(self): -####TESTID#### +####TESTID#### @@ -255,6 +263,7 @@ def GenCode(self): """ sOut = sHTMLPattern.replace('####CNTUSECASES####', str(nCntUsecases)) sOut = sOut.replace('####TESTID####', TESTID) + sOut = sOut.replace('####JSONFILELINK####', JSONFILElink) sOut = sOut.replace('####SECTION####', SECTION) sOut = sOut.replace('####SUBSECTION####', SUBSECTION) if SUBSECTION == "GOODCASE": diff --git a/test/pytest/pytestfiles/test_07_COMPOSITE_EXPRESSIONS_GOODCASE.py b/test/pytest/pytestfiles/test_07_COMPOSITE_EXPRESSIONS_GOODCASE.py index c7842aba..10c293ce 100644 --- a/test/pytest/pytestfiles/test_07_COMPOSITE_EXPRESSIONS_GOODCASE.py +++ b/test/pytest/pytestfiles/test_07_COMPOSITE_EXPRESSIONS_GOODCASE.py @@ -18,7 +18,7 @@ # # XC-CT/ECA3-Queckenstedt # -# 13.09.2023 - 10:58:36 +# 28.09.2023 - 11:51:44 # # -------------------------------------------------------------------------------------------------------------- @@ -53,6 +53,14 @@ def test_JPP_0501(self, Description): def test_JPP_0502(self, Description): nReturn = CExecute.Execute("JPP_0502") assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor returns expected value + @pytest.mark.parametrize( + "Description", ["JSON file with composite strings containing several times a colon and a comma (JSON syntax elements)",] + ) + def test_JPP_0505(self, Description): + nReturn = CExecute.Execute("JPP_0505") + assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- # Expected: JsonPreprocessor returns expected value @pytest.mark.parametrize( diff --git a/test/pytest/pytestfiles/test_12_CYCLIC_IMPORTS_BADCASE.py b/test/pytest/pytestfiles/test_12_CYCLIC_IMPORTS_BADCASE.py new file mode 100644 index 00000000..a0d15c9f --- /dev/null +++ b/test/pytest/pytestfiles/test_12_CYCLIC_IMPORTS_BADCASE.py @@ -0,0 +1,48 @@ +# ************************************************************************************************************** +# 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_12_CYCLIC_IMPORTS_BADCASE.py +# +# XC-CT/ECA3-Queckenstedt +# +# 28.09.2023 - 15:28:52 +# +# -------------------------------------------------------------------------------------------------------------- + +import pytest +from pytestlibs.CExecute import CExecute + +# -------------------------------------------------------------------------------------------------------------- + +class Test_CYCLIC_IMPORTS_BADCASE: + +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with cyclic imports (JSON file imports itself)",] + ) + def test_JPP_1150(self, Description): + nReturn = CExecute.Execute("JPP_1150") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: No values are returned, and JsonPreprocessor throws an exception + @pytest.mark.parametrize( + "Description", ["JSON file with cyclic imports (JSON file imports another file, that is already imported)",] + ) + def test_JPP_1151(self, Description): + nReturn = CExecute.Execute("JPP_1151") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- diff --git a/test/pytest/pytestfiles/test_13_PATH_FORMATS_GOODCASE.py b/test/pytest/pytestfiles/test_13_PATH_FORMATS_GOODCASE.py new file mode 100644 index 00000000..d2a9ee68 --- /dev/null +++ b/test/pytest/pytestfiles/test_13_PATH_FORMATS_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_13_PATH_FORMATS_GOODCASE.py +# +# XC-CT/ECA3-Queckenstedt +# +# 29.09.2023 - 15:06:38 +# +# -------------------------------------------------------------------------------------------------------------- + +import pytest +from pytestlibs.CExecute import CExecute + +# -------------------------------------------------------------------------------------------------------------- + +class Test_PATH_FORMATS_GOODCASE: + +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor resolves the relative path and returns values from JSON file + @pytest.mark.parametrize( + "Description", ["Relative path to JSON file",] + ) + def test_JPP_1200(self, Description): + nReturn = CExecute.Execute("JPP_1200") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- diff --git a/test/testconfig/TestConfig.py b/test/testconfig/TestConfig.py index 16b19a59..814d1b00 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -22,7 +22,7 @@ # # -------------------------------------------------------------------------------------------------------------- # -# 13.09.2023 +# 29.09.2023 # # !!! Temporarily tests are deactivated by the following line commented out: # # # listofdictUsecases.append(dictUsecase) @@ -36,6 +36,7 @@ # the following keys are optional, all other keys are mandatory. # dictUsecase['HINT'] = None # dictUsecase['COMMENT'] = None +# dictUsecase['USERAWPATH'] = False # if True, 'JSONFILE' will not be normalized # -------------------------------------------------------------------------------------------------------------- @@ -1821,13 +1822,13 @@ dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0505.jsonp" dictUsecase['EXPECTEDEXCEPTION'] = None dictUsecase['EXPECTEDRETURN'] = """ -[DICT] (5/1) > {param1} [STR] : 'value : 1' -[DICT] (5/2) > {param2} [STR] : 'value : 2' +[DICT] (5/1) > {param1} [STR] : 'value :,: 1' +[DICT] (5/2) > {param2} [STR] : 'value :,: 2' [DICT] (5/3) > {val1} [STR] : 'The values are: 'value :,: 1' and: 'value :,: 2', and so on' [DICT] (5/4) > {val2} [STR] : 'The values are: 'value :,: 1' and: 'value :,: 2', and so on' [DICT] (5/5) > {val3} [STR] : ':'The values are: 'value :,: 1' and: 'value :,: 2', and so on'::,::'The values are: 'value :,: 1' and: 'value :,: 2', and so on':' """ -# # # listofdictUsecases.append(dictUsecase) +listofdictUsecases.append(dictUsecase) del dictUsecase # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} @@ -1989,17 +1990,68 @@ dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1000.jsonp" dictUsecase['EXPECTEDEXCEPTION'] = None dictUsecase['EXPECTEDRETURN'] = """ -[DICT] (2/1) > {dTestDict} [DICT] (3/1) > {kVal_1} [STR] : 'Val_1' -[DICT] (2/1) > {dTestDict} [DICT] (3/2) > {kVal_2} [DICT] (1/1) > {I-am-not-existing-1} [DICT] (1/1) > {I-am-not-existing-2} [STR] : 'Val_1' -[DICT] (2/1) > {dTestDict} [DICT] (3/3) > {kVal_3} [DICT] (1/1) > {I-am-not-existing-3} [DICT] (1/1) > {I-am-not-existing-4} [STR] : 'Val_1' +[DICT] (2/1) > {dTestDict} [DICT] (4/1) > {kVal_1} [STR] : 'Val_1' +[DICT] (2/1) > {dTestDict} [DICT] (4/2) > {kVal_2} [DICT] (1/1) > {I-am-not-existing-1} [DICT] (1/1) > {I-am-not-existing-2} [STR] : 'Val_1' +[DICT] (2/1) > {dTestDict} [DICT] (4/3) > {kVal_3} [DICT] (1/1) > {I-am-not-existing-3} [DICT] (1/1) > {I-am-not-existing-4} [STR] : 'Val_1' +[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (3/1) > {A} [INT] : 1 +[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (3/2) > {B} [LIST] (2/1) > [INT] : 1 +[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (3/2) > {B} [LIST] (2/2) > [INT] : 2 +[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (3/3) > {kVal_4D} [DICT] (1/1) > {kVal_4E} [DICT] (1/1) > {kVal_4F} [DICT] (1/1) > {kVal_4G} [DICT] (2/1) > {C} [INT] : 2 +[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (3/3) > {kVal_4D} [DICT] (1/1) > {kVal_4E} [DICT] (1/1) > {kVal_4F} [DICT] (1/1) > {kVal_4G} [DICT] (2/2) > {D} [LIST] (2/1) > [INT] : 3 +[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (3/3) > {kVal_4D} [DICT] (1/1) > {kVal_4E} [DICT] (1/1) > {kVal_4F} [DICT] (1/1) > {kVal_4G} [DICT] (2/2) > {D} [LIST] (2/2) > [INT] : 4 [DICT] (2/2) > {Val_1} [STR] : 'Val_1' """ listofdictUsecases.append(dictUsecase) del dictUsecase - - - - +# -------------------------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_1150" +dictUsecase['DESCRIPTION'] = "JSON file with cyclic imports (JSON file imports itself)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "CYCLIC_IMPORTS" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1150.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Cyclic imported json file" +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_1151" +dictUsecase['DESCRIPTION'] = "JSON file with cyclic imports (JSON file imports another file, that is already imported)" +dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception" +dictUsecase['SECTION'] = "CYCLIC_IMPORTS" +dictUsecase['SUBSECTION'] = "BADCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1151.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = "Cyclic imported json file" +dictUsecase['EXPECTEDRETURN'] = None +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_1200" +# In all other use cases the path 'JSONFILE' is normalized before the JsonPreprocessor is called. +# The reference for relative paths is the position of this file. +# In this use case the path 'JSONFILE' is not normalized. +# And the path is relative to the position of the executing script (component_test.py). +dictUsecase['DESCRIPTION'] = "Relative path to JSON file" +dictUsecase['EXPECTATION'] = "JsonPreprocessor resolves the relative path and returns values from JSON file" +dictUsecase['SECTION'] = "PATH_FORMATS" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = "Works with raw path to JSON file (path not normalized internally)" +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r".\testfiles\jpp-test_config_1200.jsonp" +dictUsecase['USERAWPATH'] = True +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = "[DICT] (1/1) > {teststring} [STR] : 'relative path teststring value'" +listofdictUsecases.append(dictUsecase) +del dictUsecase # -------------------------------------------------------------------------------------------------------------- diff --git a/test/testfiles/import/cyclic.1/cyclic.2/cyclic.3/jpp-test_config_cyclic.3.jsonp b/test/testfiles/import/cyclic.1/cyclic.2/cyclic.3/jpp-test_config_cyclic.3.jsonp new file mode 100644 index 00000000..33ddf3b7 --- /dev/null +++ b/test/testfiles/import/cyclic.1/cyclic.2/cyclic.3/jpp-test_config_cyclic.3.jsonp @@ -0,0 +1,18 @@ +// 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. +//************************************************************************** + +{ + "[import]" : "../../../../jpp-test_config_1151.jsonp" +} diff --git a/test/testfiles/import/cyclic.1/cyclic.2/jpp-test_config_cyclic.2.jsonp b/test/testfiles/import/cyclic.1/cyclic.2/jpp-test_config_cyclic.2.jsonp new file mode 100644 index 00000000..b999f984 --- /dev/null +++ b/test/testfiles/import/cyclic.1/cyclic.2/jpp-test_config_cyclic.2.jsonp @@ -0,0 +1,18 @@ +// 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. +//************************************************************************** + +{ + "[import]" : "./cyclic.3/jpp-test_config_cyclic.3.jsonp" +} diff --git a/test/testfiles/import/cyclic.1/jpp-test_config_cyclic.1.jsonp b/test/testfiles/import/cyclic.1/jpp-test_config_cyclic.1.jsonp new file mode 100644 index 00000000..27eaa1ea --- /dev/null +++ b/test/testfiles/import/cyclic.1/jpp-test_config_cyclic.1.jsonp @@ -0,0 +1,18 @@ +// 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. +//************************************************************************** + +{ + "[import]" : "./cyclic.2/jpp-test_config_cyclic.2.jsonp" +} diff --git a/test/testfiles/import/import.1/import.1.1/jpp-test_config_implicit_creation.1.1.1.jsonp b/test/testfiles/import/import.1/import.1.1/jpp-test_config_implicit_creation.1.1.1.jsonp index c90a3199..e0ad853a 100644 --- a/test/testfiles/import/import.1/import.1.1/jpp-test_config_implicit_creation.1.1.1.jsonp +++ b/test/testfiles/import/import.1/import.1.1/jpp-test_config_implicit_creation.1.1.1.jsonp @@ -14,5 +14,15 @@ //************************************************************************** { - "${dTestDict.kVal_3.I-am-not-existing-3.I-am-not-existing-4}" : "${dTestDict}['kVal_2']['I-am-not-existing-1']['I-am-not-existing-2']" + // use inside quotes the expression belonging to the data structure that has been created implicitly before: + "${dTestDict.kVal_3.I-am-not-existing-3.I-am-not-existing-4}" : "${dTestDict}['kVal_2']['I-am-not-existing-1']['I-am-not-existing-2']", + // mixture of dotdict and standard notation: + ${dTestDict.kVal_4}['kVal_4B']['kVal_4C'] : {"A" : 1, "B" : [1,2]}, + ${dTestDict.kVal_4.kVal_4B.kVal_4C.kVal_4D.kVal_4E}['kVal_4F']['kVal_4G'] : {"C" : 2, "D" : [3,4]} + // sub key defined by parameter: + // "kVal_5B_name" : "kVal_5B", + // reference: https://github.com/test-fullautomation/python-jsonpreprocessor/issues/153 + // currently not working // ${dTestDict.kVal_5.${kVal_5B_name}} : {"E" : 3, "F" : [5,6]} + // currently not working // ${dTestDict.kVal_5}['${kVal_5B_name}'] : {"G" : 4, "H" : [7,8]} + // currently not working // ${dTestDict.${kVal_5B_name}.${kVal_5B_name}} : {"M" : 5, "N" : [0,9]} } diff --git a/test/testfiles/import/import.1/import.1.1/jpp-test_config_relative_jsonfile_path.jsonp b/test/testfiles/import/import.1/import.1.1/jpp-test_config_relative_jsonfile_path.jsonp new file mode 100644 index 00000000..002061ae --- /dev/null +++ b/test/testfiles/import/import.1/import.1.1/jpp-test_config_relative_jsonfile_path.jsonp @@ -0,0 +1,18 @@ +// 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. +//************************************************************************** + +{ + "teststring" : "relative path teststring value" +} diff --git a/test/testfiles/import/import.1/jpp-test_config_implicit_creation.1.1.jsonp b/test/testfiles/import/import.1/jpp-test_config_implicit_creation.1.1.jsonp index a8d6f60e..6deadfac 100644 --- a/test/testfiles/import/import.1/jpp-test_config_implicit_creation.1.1.jsonp +++ b/test/testfiles/import/import.1/jpp-test_config_implicit_creation.1.1.jsonp @@ -15,6 +15,7 @@ { ${dTestDict}['kVal_2']['I-am-not-existing-1']['I-am-not-existing-2'] : ${dTestDict}['kVal_1'], + // overwrite what has been created implicitly before: ${dTestDict.kVal_3.I-am-not-existing-3.I-am-not-existing-4} : ${dTestDict}['kVal_2']['I-am-not-existing-1']['I-am-not-existing-2'], "[import]" : "./import.1.1/jpp-test_config_implicit_creation.1.1.1.jsonp" } diff --git a/test/testfiles/jpp-test_config_1150.jsonp b/test/testfiles/jpp-test_config_1150.jsonp new file mode 100644 index 00000000..f905bce9 --- /dev/null +++ b/test/testfiles/jpp-test_config_1150.jsonp @@ -0,0 +1,19 @@ +// 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. +//************************************************************************** + +{ + // file imports itself + "[import]" : "./jpp-test_config_1150.jsonp" +} diff --git a/test/testfiles/jpp-test_config_1151.jsonp b/test/testfiles/jpp-test_config_1151.jsonp new file mode 100644 index 00000000..d790f506 --- /dev/null +++ b/test/testfiles/jpp-test_config_1151.jsonp @@ -0,0 +1,18 @@ +// 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. +//************************************************************************** + +{ + "[import]" : "./import/cyclic.1/jpp-test_config_cyclic.1.jsonp" +} diff --git a/test/testfiles/jpp-test_config_1200.jsonp b/test/testfiles/jpp-test_config_1200.jsonp new file mode 100644 index 00000000..15f7f5e1 --- /dev/null +++ b/test/testfiles/jpp-test_config_1200.jsonp @@ -0,0 +1,18 @@ +// 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. +//************************************************************************** + +{ + "[import]" : "./import/import.1/import.1.1/jpp-test_config_relative_jsonfile_path.jsonp" +}