From 9d7995b604a1ff370dc318c820f8814561a8e8d0 Mon Sep 17 00:00:00 2001 From: qth2hi Date: Wed, 27 Sep 2023 10:43:26 +0200 Subject: [PATCH 1/6] Added GitHub link to JSON file in HTML test case list --- test/JPP_TestUsecases.html | 98 +++++++++++++++++++------------------- test/component_test.py | 4 +- test/libs/CGenCode.py | 23 ++++++--- 3 files changed, 67 insertions(+), 58 deletions(-) diff --git a/test/JPP_TestUsecases.html b/test/JPP_TestUsecases.html index 29042094..78965563 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_0506 @@ -1377,7 +1377,7 @@ -JPP_0550 +JPP_0550 @@ -1411,7 +1411,7 @@ -JPP_0900 +JPP_0900 @@ -1444,7 +1444,7 @@ -JPP_0950 +JPP_0950 @@ -1477,7 +1477,7 @@ -JPP_0951 +JPP_0951 @@ -1510,7 +1510,7 @@ -JPP_0952 +JPP_0952 @@ -1543,7 +1543,7 @@ -JPP_0953 +JPP_0953 @@ -1576,7 +1576,7 @@ -JPP_0954 +JPP_0954 @@ -1609,7 +1609,7 @@ -JPP_1000 +JPP_1000 @@ -1636,7 +1636,7 @@
 

-
Generated: 13.09.2023 - 10:58:36
+
Generated: 27.09.2023 - 10:40:30
 
diff --git a/test/component_test.py b/test/component_test.py index 0a6f89ea..3265dd11 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.10.0" +VERSION_DATE = "27.09.2023" # # -------------------------------------------------------------------------------------------------------------- #TM*** 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": From 430dc00ed9f33b0979e6e467aa74ac069907f5b1 Mon Sep 17 00:00:00 2001 From: qth2hi Date: Thu, 28 Sep 2023 11:27:55 +0200 Subject: [PATCH 2/6] JPP_1000 extended (implicit creation combinations) Because of https://github.com/test-fullautomation/python-jsonpreprocessor/issues/153 extensions partially commented out --- test/component_test.py | 2 +- test/testconfig/TestConfig.py | 12 ++++++++---- .../jpp-test_config_implicit_creation.1.1.1.jsonp | 11 ++++++++++- .../jpp-test_config_implicit_creation.1.1.jsonp | 1 + 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/test/component_test.py b/test/component_test.py index 3265dd11..d6d573db 100644 --- a/test/component_test.py +++ b/test/component_test.py @@ -23,7 +23,7 @@ # -------------------------------------------------------------------------------------------------------------- # VERSION = "0.10.0" -VERSION_DATE = "27.09.2023" +VERSION_DATE = "28.09.2023" # # -------------------------------------------------------------------------------------------------------------- #TM*** diff --git a/test/testconfig/TestConfig.py b/test/testconfig/TestConfig.py index 16b19a59..2a019f15 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -22,7 +22,7 @@ # # -------------------------------------------------------------------------------------------------------------- # -# 13.09.2023 +# 28.09.2023 # # !!! Temporarily tests are deactivated by the following line commented out: # # # listofdictUsecases.append(dictUsecase) @@ -1989,9 +1989,13 @@ 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] (2/1) > {A} [INT] : 1 +[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (2/2) > {B} [LIST] (3/1) > [INT] : 1 +[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (2/2) > {B} [LIST] (3/2) > [INT] : 2 +[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (2/2) > {B} [LIST] (3/3) > [INT] : 3 [DICT] (2/2) > {Val_1} [STR] : 'Val_1' """ listofdictUsecases.append(dictUsecase) 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..503ce286 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,14 @@ //************************************************************************** { - "${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,3]} + // 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}} : {"C" : 2, "D" : [4,5,6]} + // currently not working // ${dTestDict.kVal_5}['${kVal_5B_name}'] : {"E" : 3, "F" : [7,8,9]} + // currently not working // ${dTestDict.${kVal_5B_name}.${kVal_5B_name}} : {"G" : 4, "H" : [9,5,1]} } 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" } From 372d4654efff4ac1c282f3e7ffd7a91265e19bdd Mon Sep 17 00:00:00 2001 From: qth2hi Date: Thu, 28 Sep 2023 11:55:33 +0200 Subject: [PATCH 3/6] JPP_0505 activated because of solved issue --- test/JPP_TestUsecases.csv | 1 + test/JPP_TestUsecases.html | 51 +++++++++++++++---- test/JPP_TestUsecases.rst | 12 ++++- test/JPP_TestUsecases.txt | 6 ++- .../test_07_COMPOSITE_EXPRESSIONS_GOODCASE.py | 10 +++- test/testconfig/TestConfig.py | 6 +-- 6 files changed, 71 insertions(+), 15 deletions(-) diff --git a/test/JPP_TestUsecases.csv b/test/JPP_TestUsecases.csv index 345ed709..c195c982 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 diff --git a/test/JPP_TestUsecases.html b/test/JPP_TestUsecases.html index 78965563..178d9ab0 100644 --- a/test/JPP_TestUsecases.html +++ b/test/JPP_TestUsecases.html @@ -1341,6 +1341,39 @@ 40 + + + +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 + + +
+ + + + + + + +41 + + @@ -1371,7 +1404,7 @@ -41 +42 @@ -1405,7 +1438,7 @@ -42 +43 @@ -1438,7 +1471,7 @@ -43 +44 @@ -1471,7 +1504,7 @@ -44 +45 @@ -1504,7 +1537,7 @@ -45 +46 @@ -1537,7 +1570,7 @@ -46 +47 @@ -1570,7 +1603,7 @@ -47 +48 @@ -1603,7 +1636,7 @@ -48 +49 @@ -1636,7 +1669,7 @@
 

-
Generated: 27.09.2023 - 10:40:30
+
Generated: 28.09.2023 - 11:51:44
 
diff --git a/test/JPP_TestUsecases.rst b/test/JPP_TestUsecases.rst index dec15fc8..bb429399 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,5 @@ Test Use Cases ---- -Generated: 13.09.2023 - 10:58:36 +Generated: 28.09.2023 - 11:51:44 diff --git a/test/JPP_TestUsecases.txt b/test/JPP_TestUsecases.txt index 190200f8..7bd2bfcc 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,5 @@ 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 +Generated: 28.09.2023 - 11:51:44 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/testconfig/TestConfig.py b/test/testconfig/TestConfig.py index 2a019f15..3ff34532 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -1821,13 +1821,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 = {} From b263bd2b9c4c06ae4c77012231dc4f5da651d757 Mon Sep 17 00:00:00 2001 From: qth2hi Date: Thu, 28 Sep 2023 12:33:39 +0200 Subject: [PATCH 4/6] JPP_1150 added (cyclic imports) --- test/JPP_TestUsecases.csv | 1 + test/JPP_TestUsecases.html | 35 +++++++++++++++- test/JPP_TestUsecases.rst | 12 +++++- test/JPP_TestUsecases.txt | 6 ++- test/component_test.py | 2 +- .../test_12_CYCLIC_IMPORTS_BADCASE.py | 40 +++++++++++++++++++ test/testconfig/TestConfig.py | 19 +++++++-- .../cyclic.3/jpp-test_config_cyclic.3.jsonp | 18 +++++++++ .../cyclic.2/jpp-test_config_cyclic.2.jsonp | 18 +++++++++ .../cyclic.1/jpp-test_config_cyclic.1.jsonp | 18 +++++++++ test/testfiles/jpp-test_config_1150.jsonp | 18 +++++++++ 11 files changed, 179 insertions(+), 8 deletions(-) create mode 100644 test/pytest/pytestfiles/test_12_CYCLIC_IMPORTS_BADCASE.py create mode 100644 test/testfiles/import/cyclic.1/cyclic.2/cyclic.3/jpp-test_config_cyclic.3.jsonp create mode 100644 test/testfiles/import/cyclic.1/cyclic.2/jpp-test_config_cyclic.2.jsonp create mode 100644 test/testfiles/import/cyclic.1/jpp-test_config_cyclic.1.jsonp create mode 100644 test/testfiles/jpp-test_config_1150.jsonp diff --git a/test/JPP_TestUsecases.csv b/test/JPP_TestUsecases.csv index c195c982..08a85cac 100644 --- a/test/JPP_TestUsecases.csv +++ b/test/JPP_TestUsecases.csv @@ -49,3 +49,4 @@ 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 diff --git a/test/JPP_TestUsecases.html b/test/JPP_TestUsecases.html index 178d9ab0..5a8ccbcb 100644 --- a/test/JPP_TestUsecases.html +++ b/test/JPP_TestUsecases.html @@ -1664,12 +1664,45 @@
+ + + + + +50 + + + + + +JPP_1150 + + + + +CYCLIC_IMPORTS + + + + +BADCASE + + + + +JSON file with cyclic imports
+Expected: No values are returned, and JsonPreprocessor throws an exception + + +
+ +
 

-
Generated: 28.09.2023 - 11:51:44
+
Generated: 28.09.2023 - 12:29:40
 
diff --git a/test/JPP_TestUsecases.rst b/test/JPP_TestUsecases.rst index bb429399..787ca7d7 100644 --- a/test/JPP_TestUsecases.rst +++ b/test/JPP_TestUsecases.rst @@ -547,5 +547,15 @@ Test Use Cases ---- -Generated: 28.09.2023 - 11:51:44 +* **Test JPP_1150** + + [CYCLIC_IMPORTS / BADCASE] + + **JSON file with cyclic imports** + + Expected: No values are returned, and JsonPreprocessor throws an exception + +---- + +Generated: 28.09.2023 - 12:29:40 diff --git a/test/JPP_TestUsecases.txt b/test/JPP_TestUsecases.txt index 7bd2bfcc..d6def89c 100644 --- a/test/JPP_TestUsecases.txt +++ b/test/JPP_TestUsecases.txt @@ -232,5 +232,9 @@ Test JPP_1000 / IMPLICIT_CREATION / GOODCASE Description: JSON file with dictionary keys to be created implicitly Expectation: JsonPreprocessor returns values ------------------------------------------------------------------------------------------------------------------------ -Generated: 28.09.2023 - 11:51:44 +Test JPP_1150 / CYCLIC_IMPORTS / BADCASE +Description: JSON file with cyclic imports +Expectation: No values are returned, and JsonPreprocessor throws an exception +------------------------------------------------------------------------------------------------------------------------ +Generated: 28.09.2023 - 12:29:40 diff --git a/test/component_test.py b/test/component_test.py index d6d573db..f164cb0f 100644 --- a/test/component_test.py +++ b/test/component_test.py @@ -22,7 +22,7 @@ # # -------------------------------------------------------------------------------------------------------------- # -VERSION = "0.10.0" +VERSION = "0.11.0" VERSION_DATE = "28.09.2023" # # -------------------------------------------------------------------------------------------------------------- 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..cd089e72 --- /dev/null +++ b/test/pytest/pytestfiles/test_12_CYCLIC_IMPORTS_BADCASE.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_12_CYCLIC_IMPORTS_BADCASE.py +# +# XC-CT/ECA3-Queckenstedt +# +# 28.09.2023 - 12:29:40 +# +# -------------------------------------------------------------------------------------------------------------- + +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",] + ) + def test_JPP_1150(self, Description): + nReturn = CExecute.Execute("JPP_1150") + assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- diff --git a/test/testconfig/TestConfig.py b/test/testconfig/TestConfig.py index 3ff34532..1dde1fec 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -2000,10 +2000,21 @@ """ listofdictUsecases.append(dictUsecase) del dictUsecase - - - - +# -------------------------------------------------------------------------------------------------------------- +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_1150" +dictUsecase['DESCRIPTION'] = "JSON file with cyclic imports" +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 # -------------------------------------------------------------------------------------------------------------- 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..4cfcc5dc --- /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_1150.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/jpp-test_config_1150.jsonp b/test/testfiles/jpp-test_config_1150.jsonp new file mode 100644 index 00000000..d790f506 --- /dev/null +++ b/test/testfiles/jpp-test_config_1150.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" +} From aaaed795feb82bce8f5dd385fa72a34329d27336 Mon Sep 17 00:00:00 2001 From: qth2hi Date: Thu, 28 Sep 2023 15:31:43 +0200 Subject: [PATCH 5/6] JPP_1151 added (cyclic imports) --- test/JPP_TestUsecases.csv | 3 +- test/JPP_TestUsecases.html | 37 ++++++++++++++++++- test/JPP_TestUsecases.rst | 14 ++++++- test/JPP_TestUsecases.txt | 8 +++- .../test_12_CYCLIC_IMPORTS_BADCASE.py | 12 +++++- test/testconfig/TestConfig.py | 26 ++++++++++--- .../cyclic.3/jpp-test_config_cyclic.3.jsonp | 2 +- ...-test_config_implicit_creation.1.1.1.jsonp | 9 +++-- test/testfiles/jpp-test_config_1150.jsonp | 3 +- test/testfiles/jpp-test_config_1151.jsonp | 18 +++++++++ 10 files changed, 112 insertions(+), 20 deletions(-) create mode 100644 test/testfiles/jpp-test_config_1151.jsonp diff --git a/test/JPP_TestUsecases.csv b/test/JPP_TestUsecases.csv index 08a85cac..8ad1b9b2 100644 --- a/test/JPP_TestUsecases.csv +++ b/test/JPP_TestUsecases.csv @@ -49,4 +49,5 @@ 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 +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) diff --git a/test/JPP_TestUsecases.html b/test/JPP_TestUsecases.html index 5a8ccbcb..274b8002 100644 --- a/test/JPP_TestUsecases.html +++ b/test/JPP_TestUsecases.html @@ -1690,7 +1690,40 @@ -JSON file with cyclic imports
+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 @@ -1702,7 +1735,7 @@
 

-
Generated: 28.09.2023 - 12:29:40
+
Generated: 28.09.2023 - 15:28:52
 
diff --git a/test/JPP_TestUsecases.rst b/test/JPP_TestUsecases.rst index 787ca7d7..33c42440 100644 --- a/test/JPP_TestUsecases.rst +++ b/test/JPP_TestUsecases.rst @@ -551,11 +551,21 @@ Test Use Cases [CYCLIC_IMPORTS / BADCASE] - **JSON file with cyclic imports** + **JSON file with cyclic imports (JSON file imports itself)** Expected: No values are returned, and JsonPreprocessor throws an exception ---- -Generated: 28.09.2023 - 12:29:40 +* **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 + +---- + +Generated: 28.09.2023 - 15:28:52 diff --git a/test/JPP_TestUsecases.txt b/test/JPP_TestUsecases.txt index d6def89c..aa8d917c 100644 --- a/test/JPP_TestUsecases.txt +++ b/test/JPP_TestUsecases.txt @@ -233,8 +233,12 @@ Description: JSON file with dictionary keys to be created implicitly Expectation: JsonPreprocessor returns values ------------------------------------------------------------------------------------------------------------------------ Test JPP_1150 / CYCLIC_IMPORTS / BADCASE -Description: JSON file with cyclic imports +Description: JSON file with cyclic imports (JSON file imports itself) Expectation: No values are returned, and JsonPreprocessor throws an exception ------------------------------------------------------------------------------------------------------------------------ -Generated: 28.09.2023 - 12:29:40 +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 +------------------------------------------------------------------------------------------------------------------------ +Generated: 28.09.2023 - 15:28:52 diff --git a/test/pytest/pytestfiles/test_12_CYCLIC_IMPORTS_BADCASE.py b/test/pytest/pytestfiles/test_12_CYCLIC_IMPORTS_BADCASE.py index cd089e72..a0d15c9f 100644 --- a/test/pytest/pytestfiles/test_12_CYCLIC_IMPORTS_BADCASE.py +++ b/test/pytest/pytestfiles/test_12_CYCLIC_IMPORTS_BADCASE.py @@ -18,7 +18,7 @@ # # XC-CT/ECA3-Queckenstedt # -# 28.09.2023 - 12:29:40 +# 28.09.2023 - 15:28:52 # # -------------------------------------------------------------------------------------------------------------- @@ -32,9 +32,17 @@ class Test_CYCLIC_IMPORTS_BADCASE: # -------------------------------------------------------------------------------------------------------------- # Expected: No values are returned, and JsonPreprocessor throws an exception @pytest.mark.parametrize( - "Description", ["JSON file with cyclic imports",] + "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/testconfig/TestConfig.py b/test/testconfig/TestConfig.py index 1dde1fec..d6d883d6 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -1992,10 +1992,12 @@ [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] (2/1) > {A} [INT] : 1 -[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (2/2) > {B} [LIST] (3/1) > [INT] : 1 -[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (2/2) > {B} [LIST] (3/2) > [INT] : 2 -[DICT] (2/1) > {dTestDict} [DICT] (4/4) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (2/2) > {B} [LIST] (3/3) > [INT] : 3 +[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) @@ -2004,7 +2006,7 @@ # -------------------------------------------------------------------------------------------------------------- dictUsecase = {} dictUsecase['TESTID'] = "JPP_1150" -dictUsecase['DESCRIPTION'] = "JSON file with cyclic imports" +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" @@ -2016,6 +2018,20 @@ 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 +# -------------------------------------------------------------------------------------------------------------- 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 index 4cfcc5dc..33ddf3b7 100644 --- 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 @@ -14,5 +14,5 @@ //************************************************************************** { - "[import]" : "../../../../jpp-test_config_1150.jsonp" + "[import]" : "../../../../jpp-test_config_1151.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 503ce286..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 @@ -17,11 +17,12 @@ // 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,3]} + ${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}} : {"C" : 2, "D" : [4,5,6]} - // currently not working // ${dTestDict.kVal_5}['${kVal_5B_name}'] : {"E" : 3, "F" : [7,8,9]} - // currently not working // ${dTestDict.${kVal_5B_name}.${kVal_5B_name}} : {"G" : 4, "H" : [9,5,1]} + // 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/jpp-test_config_1150.jsonp b/test/testfiles/jpp-test_config_1150.jsonp index d790f506..f905bce9 100644 --- a/test/testfiles/jpp-test_config_1150.jsonp +++ b/test/testfiles/jpp-test_config_1150.jsonp @@ -14,5 +14,6 @@ //************************************************************************** { - "[import]" : "./import/cyclic.1/jpp-test_config_cyclic.1.jsonp" + // 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" +} From 481d67ff9c6d4a381f5e0c53fc076162c67a2ee0 Mon Sep 17 00:00:00 2001 From: qth2hi Date: Fri, 29 Sep 2023 15:18:41 +0200 Subject: [PATCH 6/6] JPP_1200 added (relative path to JSON file) --- test/JPP_TestUsecases.csv | 1 + test/JPP_TestUsecases.html | 36 ++++++++++++++++- test/JPP_TestUsecases.rst | 14 ++++++- test/JPP_TestUsecases.txt | 7 +++- test/component_test.py | 16 ++++++-- .../test_13_PATH_FORMATS_GOODCASE.py | 40 +++++++++++++++++++ test/testconfig/TestConfig.py | 23 ++++++++++- ...p-test_config_relative_jsonfile_path.jsonp | 18 +++++++++ test/testfiles/jpp-test_config_1200.jsonp | 18 +++++++++ 9 files changed, 165 insertions(+), 8 deletions(-) create mode 100644 test/pytest/pytestfiles/test_13_PATH_FORMATS_GOODCASE.py create mode 100644 test/testfiles/import/import.1/import.1.1/jpp-test_config_relative_jsonfile_path.jsonp create mode 100644 test/testfiles/jpp-test_config_1200.jsonp diff --git a/test/JPP_TestUsecases.csv b/test/JPP_TestUsecases.csv index 8ad1b9b2..0ffcf96b 100644 --- a/test/JPP_TestUsecases.csv +++ b/test/JPP_TestUsecases.csv @@ -51,3 +51,4 @@ JPP_0954|COMMON_SYNTAX_VIOLATIONS|BADCASE|JSON file with syntax error (5): file 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 274b8002..42e3616d 100644 --- a/test/JPP_TestUsecases.html +++ b/test/JPP_TestUsecases.html @@ -1730,12 +1730,46 @@
+ + + + + +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: 28.09.2023 - 15:28:52
+
Generated: 29.09.2023 - 15:06:38
 
diff --git a/test/JPP_TestUsecases.rst b/test/JPP_TestUsecases.rst index 33c42440..2ee51968 100644 --- a/test/JPP_TestUsecases.rst +++ b/test/JPP_TestUsecases.rst @@ -567,5 +567,17 @@ Test Use Cases ---- -Generated: 28.09.2023 - 15:28:52 +* **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 aa8d917c..55c3f693 100644 --- a/test/JPP_TestUsecases.txt +++ b/test/JPP_TestUsecases.txt @@ -240,5 +240,10 @@ 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 ------------------------------------------------------------------------------------------------------------------------ -Generated: 28.09.2023 - 15:28:52 +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 f164cb0f..fcc66d8d 100644 --- a/test/component_test.py +++ b/test/component_test.py @@ -22,8 +22,8 @@ # # -------------------------------------------------------------------------------------------------------------- # -VERSION = "0.11.0" -VERSION_DATE = "28.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/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 d6d883d6..814d1b00 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -22,7 +22,7 @@ # # -------------------------------------------------------------------------------------------------------------- # -# 28.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 # -------------------------------------------------------------------------------------------------------------- @@ -2032,6 +2033,26 @@ 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/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/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" +}