From dc266f9e2b2b436923e63809b7dc63475c0ba394 Mon Sep 17 00:00:00 2001 From: qth2hi Date: Thu, 5 Oct 2023 14:34:54 +0200 Subject: [PATCH] Extended self test JPP_1000; added self test JPP_1001 Caution: Self test does not run until the issues are not solved! --- test/JPP_TestUsecases.csv | 1 + test/JPP_TestUsecases.html | 39 +++++++++++++++-- test/JPP_TestUsecases.rst | 12 +++++- test/JPP_TestUsecases.txt | 6 ++- test/component_test.py | 4 +- .../test_11_IMPLICIT_CREATION_GOODCASE.py | 10 ++++- test/testconfig/TestConfig.py | 42 ++++++++++++++----- ...pp-test_config_implicit_creation.1.1.jsonp | 8 +++- test/testfiles/jpp-test_config_0508.jsonp | 2 - test/testfiles/jpp-test_config_1001.jsonp | 33 +++++++++++++++ 10 files changed, 134 insertions(+), 23 deletions(-) create mode 100644 test/testfiles/jpp-test_config_1001.jsonp diff --git a/test/JPP_TestUsecases.csv b/test/JPP_TestUsecases.csv index 1be07bd2..fa3892b8 100644 --- a/test/JPP_TestUsecases.csv +++ b/test/JPP_TestUsecases.csv @@ -52,6 +52,7 @@ 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_1001|IMPLICIT_CREATION|GOODCASE|JSON file with dictionary keys to be created implicitly (same key names at all levels) 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 0aef25be..2031a0d6 100644 --- a/test/JPP_TestUsecases.html +++ b/test/JPP_TestUsecases.html @@ -1771,6 +1771,39 @@ 53 + + + +JPP_1001 + + + + +IMPLICIT_CREATION + + + + +GOODCASE + + + + +JSON file with dictionary keys to be created implicitly (same key names at all levels)
+Expected: JsonPreprocessor returns values + + +
+ + + + + + + +54 + + @@ -1801,7 +1834,7 @@ -54 +55 @@ -1834,7 +1867,7 @@ -55 +56 @@ -1868,7 +1901,7 @@
 

-
Generated: 04.10.2023 - 17:39:40
+
Generated: 05.10.2023 - 14:27:01
 
diff --git a/test/JPP_TestUsecases.rst b/test/JPP_TestUsecases.rst index 728307cc..68288a6f 100644 --- a/test/JPP_TestUsecases.rst +++ b/test/JPP_TestUsecases.rst @@ -577,6 +577,16 @@ Test Use Cases ---- +* **Test JPP_1001** + + [IMPLICIT_CREATION / GOODCASE] + + **JSON file with dictionary keys to be created implicitly (same key names at all levels)** + + Expected: JsonPreprocessor returns values + +---- + * **Test JPP_1150** [CYCLIC_IMPORTS / BADCASE] @@ -609,5 +619,5 @@ Test Use Cases ---- -Generated: 04.10.2023 - 17:39:40 +Generated: 05.10.2023 - 14:27:01 diff --git a/test/JPP_TestUsecases.txt b/test/JPP_TestUsecases.txt index c75bd690..32a31a5f 100644 --- a/test/JPP_TestUsecases.txt +++ b/test/JPP_TestUsecases.txt @@ -244,6 +244,10 @@ Test JPP_1000 / IMPLICIT_CREATION / GOODCASE Description: JSON file with dictionary keys to be created implicitly Expectation: JsonPreprocessor returns values ------------------------------------------------------------------------------------------------------------------------ +Test JPP_1001 / IMPLICIT_CREATION / GOODCASE +Description: JSON file with dictionary keys to be created implicitly (same key names at all levels) +Expectation: JsonPreprocessor returns values +------------------------------------------------------------------------------------------------------------------------ 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 @@ -257,5 +261,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: 04.10.2023 - 17:39:40 +Generated: 05.10.2023 - 14:27:01 diff --git a/test/component_test.py b/test/component_test.py index 9966a4e6..56775a4a 100644 --- a/test/component_test.py +++ b/test/component_test.py @@ -22,8 +22,8 @@ # # -------------------------------------------------------------------------------------------------------------- # -VERSION = "0.13.0" -VERSION_DATE = "04.10.2023" +VERSION = "0.14.0" +VERSION_DATE = "05.10.2023" # # -------------------------------------------------------------------------------------------------------------- #TM*** diff --git a/test/pytest/pytestfiles/test_11_IMPLICIT_CREATION_GOODCASE.py b/test/pytest/pytestfiles/test_11_IMPLICIT_CREATION_GOODCASE.py index 21ea46e1..f4f95f6f 100644 --- a/test/pytest/pytestfiles/test_11_IMPLICIT_CREATION_GOODCASE.py +++ b/test/pytest/pytestfiles/test_11_IMPLICIT_CREATION_GOODCASE.py @@ -18,7 +18,7 @@ # # XC-CT/ECA3-Queckenstedt # -# 13.09.2023 - 10:58:36 +# 05.10.2023 - 14:27:02 # # -------------------------------------------------------------------------------------------------------------- @@ -37,4 +37,12 @@ class Test_IMPLICIT_CREATION_GOODCASE: def test_JPP_1000(self, Description): nReturn = CExecute.Execute("JPP_1000") assert nReturn == 0 +# -------------------------------------------------------------------------------------------------------------- + # Expected: JsonPreprocessor returns values + @pytest.mark.parametrize( + "Description", ["JSON file with dictionary keys to be created implicitly (same key names at all levels)",] + ) + def test_JPP_1001(self, Description): + nReturn = CExecute.Execute("JPP_1001") + assert nReturn == 0 # -------------------------------------------------------------------------------------------------------------- diff --git a/test/testconfig/TestConfig.py b/test/testconfig/TestConfig.py index 697e96d8..ccdd4bf4 100644 --- a/test/testconfig/TestConfig.py +++ b/test/testconfig/TestConfig.py @@ -22,7 +22,7 @@ # # -------------------------------------------------------------------------------------------------------------- # -# 04.10.2023 +# 05.10.2023 # # !!! Temporarily tests are deactivated by the following line commented out: # # # listofdictUsecases.append(dictUsecase) @@ -2039,16 +2039,36 @@ dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1000.jsonp" dictUsecase['EXPECTEDEXCEPTION'] = None dictUsecase['EXPECTEDRETURN'] = """ -[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' +[DICT] (2/1) > {dTestDict} [DICT] (5/1) > {kVal_1} [STR] : 'Val_1' +[DICT] (2/1) > {dTestDict} [DICT] (5/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] (5/3) > {kVal_3} [DICT] (1/1) > {I-am-not-existing-3} [DICT] (1/1) > {I-am-not-existing-4} [STR] : 'Val_1_extended' +[DICT] (2/1) > {dTestDict} [DICT] (5/4) > {kVal_3b} [DICT] (1/1) > {I-am-not-existing-3b} [DICT] (1/1) > {I-am-not-existing-4b} [STR] : 'Val_1' +[DICT] (2/1) > {dTestDict} [DICT] (5/5) > {kVal_4} [DICT] (1/1) > {kVal_4B} [DICT] (1/1) > {kVal_4C} [DICT] (3/1) > {A} [INT] : 1 +[DICT] (2/1) > {dTestDict} [DICT] (5/5) > {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] (5/5) > {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] (5/5) > {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] (5/5) > {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] (5/5) > {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_extended} [STR] : 'Val_1' +""" +listofdictUsecases.append(dictUsecase) +del dictUsecase +# -------------------------------------------------------------------------------------------------------------- +dictUsecase = {} +dictUsecase['TESTID'] = "JPP_1001" +dictUsecase['DESCRIPTION'] = "JSON file with dictionary keys to be created implicitly (same key names at all levels)" +dictUsecase['EXPECTATION'] = "JsonPreprocessor returns values" +dictUsecase['SECTION'] = "IMPLICIT_CREATION" +dictUsecase['SUBSECTION'] = "GOODCASE" +dictUsecase['HINT'] = None +dictUsecase['COMMENT'] = None +dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_1001.jsonp" +dictUsecase['EXPECTEDEXCEPTION'] = None +dictUsecase['EXPECTEDRETURN'] = """ +[DICT] (3/1) > {param1} [DICT] (1/1) > {subkey} [DICT] (1/1) > {subkey} [DICT] (1/1) > {subkey} [STR] : 'subkey value' +[DICT] (3/2) > {param2} [DICT] (1/1) > {subkey} [DICT] (1/1) > {subkey} [DICT] (1/1) > {subkey} [STR] : 'subkey value extended' +[DICT] (3/3) > {param3} [DICT] (1/1) > {subkey} [DICT] (1/1) > {subkey} [DICT] (2/1) > {paramA} [STR] : 'subkey value extended' +[DICT] (3/3) > {param3} [DICT] (1/1) > {subkey} [DICT] (1/1) > {subkey} [DICT] (2/2) > {paramB} [STR] : 'subkey value extended' """ listofdictUsecases.append(dictUsecase) del dictUsecase 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 6deadfac..ffb427aa 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,7 +15,11 @@ { ${dTestDict}['kVal_2']['I-am-not-existing-1']['I-am-not-existing-2'] : ${dTestDict}['kVal_1'], + // use 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'], + ${dTestDict.kVal_3b.I-am-not-existing-3b.I-am-not-existing-4b} : ${dTestDict.kVal_2.I-am-not-existing-1.I-am-not-existing-2}, // 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" + ${dTestDict}['kVal_3']['I-am-not-existing-3']['I-am-not-existing-4'] : "${dTestDict}['kVal_1']_extended", + // further assignments + "[import]" : "./import.1.1/jpp-test_config_implicit_creation.1.1.1.jsonp" } diff --git a/test/testfiles/jpp-test_config_0508.jsonp b/test/testfiles/jpp-test_config_0508.jsonp index b86ccc3f..b0757bdc 100644 --- a/test/testfiles/jpp-test_config_0508.jsonp +++ b/test/testfiles/jpp-test_config_0508.jsonp @@ -13,8 +13,6 @@ // limitations under the License. //************************************************************************** { - // reference: https://github.com/test-fullautomation/robotframework-testsuitesmanagement/issues/225 - // "teststring_1" : "teststring_1.value", "teststring_1" : "${teststring_1}.suffix_1" } diff --git a/test/testfiles/jpp-test_config_1001.jsonp b/test/testfiles/jpp-test_config_1001.jsonp new file mode 100644 index 00000000..bbb17486 --- /dev/null +++ b/test/testfiles/jpp-test_config_1001.jsonp @@ -0,0 +1,33 @@ +// 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. +//************************************************************************** + +{ + "param1" : {}, + ${param1}['subkey']['subkey']['subkey'] : "subkey value", + "param2" : {}, + ${param2.subkey.subkey.subkey} : "${param1.subkey.subkey.subkey} extended", + "param3" : { + "subkey" : { + "subkey" : { + "paramA" : "ABC", + ${param3.subkey.subkey.paramA} : "DEF", + // https://github.com/test-fullautomation/robotframework-testsuitesmanagement/issues/224 + "paramA" : ${param2.subkey.subkey.subkey}, + "paramB" : "XYZ", + ${param3.subkey.subkey.paramB} : ${param2.subkey.subkey.subkey} + } + } + } +}