Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/JPP_TestUsecases.csv
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ JPP_0264|PARAMETER_SUBSTITUTION|BADCASE|JSON file with list parameter substituti
JPP_0265|PARAMETER_SUBSTITUTION|BADCASE|JSON file with list parameter substitution in key name (composite data types not allowed in names) / (2)
JPP_0266|PARAMETER_SUBSTITUTION|BADCASE|JSON file with dictionary parameter substitution in key name (composite data types not allowed in names) / (1)
JPP_0267|PARAMETER_SUBSTITUTION|BADCASE|JSON file with dictionary parameter substitution in key name (composite data types not allowed in names) / (2)
JPP_0268|PARAMETER_SUBSTITUTION|BADCASE|JSON file containing a list; list index is defined by a parameter and wrapped in single quotes
JPP_0270|PARAMETER_SUBSTITUTION|BADCASE|JSON file containing a list; list index is defined by a parameter and wrapped in single quotes
JPP_0300|VALUE_DETECTION|GOODCASE|JSON file with parameter of type 'list' / index (in square brackets) defined outside the curly brackets (valid syntax)
JPP_0301|VALUE_DETECTION|GOODCASE|JSON file with expression containing more closing elements '}' than opening elements '${' (valid syntax)
JPP_0302|VALUE_DETECTION|GOODCASE|JSON file with expression starting with '${' and ending with '}' / no further matching '${' and '}' in between (valid syntax)
Expand Down
4 changes: 2 additions & 2 deletions test/JPP_TestUsecases.html
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@
<td colspan="1" valign="center" bgcolor="#F5F5F5" align="middle">
<font size="2" face="Arial" color="#595959">
<b>
<a target="_blank" href="https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/test/testfiles/jpp-test_config_0268.jsonp">JPP_0268</a>
<a target="_blank" href="https://github.com/test-fullautomation/python-jsonpreprocessor/blob/develop/test/testfiles/jpp-test_config_0270.jsonp">JPP_0270</a>
</b></font></td>

<td colspan="1" valign="center" bgcolor="#F5F5F5" align="middle">
Expand Down Expand Up @@ -3662,7 +3662,7 @@
</tbody></table></div>
<div>&nbsp;</div>
<hr width="100%" color="#FF8C00" align="center">
<div align="center"><font size="2" color="#27408B">Generated: 15.03.2024 - 18:49:00</font></div>
<div align="center"><font size="2" color="#27408B">Generated: 20.03.2024 - 17:07:31</font></div>
<div>&nbsp;</div>
</body></html>

4 changes: 2 additions & 2 deletions test/JPP_TestUsecases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ Test Use Cases

----

* **Test JPP_0268**
* **Test JPP_0270**

[PARAMETER_SUBSTITUTION / BADCASE]

Expand Down Expand Up @@ -1173,5 +1173,5 @@ Test Use Cases

----

Generated: 15.03.2024 - 18:49:00
Generated: 20.03.2024 - 17:07:31

4 changes: 2 additions & 2 deletions test/JPP_TestUsecases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Test JPP_0267 / PARAMETER_SUBSTITUTION / BADCASE
Description: JSON file with dictionary parameter substitution in key name (composite data types not allowed in names) / (2)
Expectation: No values are returned, and JsonPreprocessor throws an exception
------------------------------------------------------------------------------------------------------------------------
Test JPP_0268 / PARAMETER_SUBSTITUTION / BADCASE
Test JPP_0270 / PARAMETER_SUBSTITUTION / BADCASE
Description: JSON file containing a list; list index is defined by a parameter and wrapped in single quotes
Expectation: No values are returned, and JsonPreprocessor throws an exception
Hint.......: List indices must be of type 'int'
Expand Down Expand Up @@ -485,5 +485,5 @@ Description: Relative path to JSON file
Expectation: JsonPreprocessor resolves the relative path and returns values from JSON file
Hint.......: Works with raw path to JSON file (path not normalized internally)
------------------------------------------------------------------------------------------------------------------------
Generated: 15.03.2024 - 18:49:00
Generated: 20.03.2024 - 17:07:31

4 changes: 2 additions & 2 deletions test/component_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#
# --------------------------------------------------------------------------------------------------------------
#
VERSION = "0.33.0"
VERSION_DATE = "19.03.2024"
VERSION = "0.34.0"
VERSION_DATE = "20.03.2024"
#
# --------------------------------------------------------------------------------------------------------------
#TM***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# XC-CT/ECA3-Queckenstedt
#
# 14.03.2024 - 15:46:24
# 20.03.2024 - 17:07:31
#
# --------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -178,7 +178,7 @@ def test_JPP_0267(self, Description):
@pytest.mark.parametrize(
"Description", ["JSON file containing a list; list index is defined by a parameter and wrapped in single quotes",]
)
def test_JPP_0268(self, Description):
nReturn = CExecute.Execute("JPP_0268")
def test_JPP_0270(self, Description):
nReturn = CExecute.Execute("JPP_0270")
assert nReturn == 0
# --------------------------------------------------------------------------------------------------------------
33 changes: 31 additions & 2 deletions test/testconfig/TestConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#
# --------------------------------------------------------------------------------------------------------------
#
# 19.03.2024
# 20.03.2024
#
# !!! Temporarily tests are deactivated by the following line commented out:
# # # listofdictUsecases.append(dictUsecase)
Expand Down Expand Up @@ -1305,13 +1305,42 @@
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_0268"
dictUsecase['DESCRIPTION'] = "JSON file with dictionary parameter substitution in parameter value (composite data types not allowed in values)"
dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception"
dictUsecase['SECTION'] = "PARAMETER_SUBSTITUTION"
dictUsecase['SUBSECTION'] = "BADCASE"
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0268.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO !!!
dictUsecase['EXPECTEDRETURN'] = None
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_0269"
dictUsecase['DESCRIPTION'] = "JSON file with list parameter substitution in parameter value (composite data types not allowed in names)"
dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception"
dictUsecase['SECTION'] = "PARAMETER_SUBSTITUTION"
dictUsecase['SUBSECTION'] = "BADCASE"
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0269.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO !!!
dictUsecase['EXPECTEDRETURN'] = None
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
# JPP_0270 does not really belong to PARAMETER_SUBSTITUTION, maybe move to another section
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_0270"
dictUsecase['DESCRIPTION'] = "JSON file containing a list; list index is defined by a parameter and wrapped in single quotes"
dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception"
dictUsecase['SECTION'] = "PARAMETER_SUBSTITUTION"
dictUsecase['SUBSECTION'] = "BADCASE"
dictUsecase['HINT'] = "List indices must be of type 'int'"
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0268.jsonp"
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0270.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "The variable '${listval}['1']' is not available!" # but not the desired one; better: list incices must be of type int
dictUsecase['EXPECTEDRETURN'] = None
listofdictUsecases.append(dictUsecase)
Expand Down
5 changes: 2 additions & 3 deletions test/testfiles/jpp-test_config_0268.jsonp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// limitations under the License.
//**************************************************************************
{
"intval" : 1,
"listval" : ["B", 2],
"param_${listval}['${intval}']}" : 3
"dictParam" : {"A" : 0, "B" : 1},
"param" : "${dictParam}"
}
18 changes: 18 additions & 0 deletions test/testfiles/jpp-test_config_0269.jsonp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2020-2024 Robert Bosch GmbH
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//**************************************************************************
{
"listParam" : ["A", "B"],
"param" : "${listParam}"
}
19 changes: 19 additions & 0 deletions test/testfiles/jpp-test_config_0270.jsonp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2020-2024 Robert Bosch GmbH
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//**************************************************************************
{
"intval" : 1,
"listval" : ["B", 2],
"param_${listval}['${intval}']}" : 3
}
71 changes: 69 additions & 2 deletions test/testtools/GenSnippetsJPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#
# **************************************************************************************************************
#
VERSION = "0.16.0"
VERSION_DATE = "19.03.2024"
VERSION = "0.17.0"
VERSION_DATE = "20.03.2024"
#
# **************************************************************************************************************

Expand Down Expand Up @@ -2010,6 +2010,70 @@ def GetNamingConventions(self):

# eof def GetNamingConventions(self):

# --------------------------------------------------------------------------------------------------------------

def GetBlockedSubstitutions(self):
"""Several snippets containing blocked dollar operator substitutions
"""

sHeadline = "Several snippets containing blocked dollar operator substitutions"

listCodeSnippets = []

listCodeSnippets.append("""{
"dictParam" : {"A" : 0, "B" : 1},
"param" : "${dictParam}"
}
""")

listCodeSnippets.append("""{
"listParam" : ["A", "B"],
"param" : "${listParam}"
}
""")

listCodeSnippets.append("""{
"floatParam" : 1.2,
"param" : "${floatParam}"
}
""")

listCodeSnippets.append("""{
"dictParam" : {"A" : 0, "B" : 1},
"${dictParam}" : 1
}
""")

listCodeSnippets.append("""{
"listParam" : ["A", "B"],
"${listParam}" : 1
}
""")

listCodeSnippets.append("""{
"floatParam" : 1.2,
"${floatParam}" : 1
}
""")

listCodeSnippets.append("""{
"keyA" : "keyA",
"dictParam" : {"${keyA}" : 1}
}
""")

listCodeSnippets.append("""{
"keyA" : "keyA",
"keyB" : "keyB",
"dictParam" : {"keyA" : {}},
${dictParam.keyA}['${keyB}_2'] : 2
}
""")

return sHeadline, listCodeSnippets

# eof def GetBlockedSubstitutions(self):


# eof class CSnippets():

Expand Down Expand Up @@ -2148,6 +2212,9 @@ def GetNamingConventions(self):
sHeadline, listCodeSnippets = oSnippets.GetNamingConventions()
bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP")

sHeadline, listCodeSnippets = oSnippets.GetBlockedSubstitutions()
bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP")

print()
print(COLBG + "done")
print()
Expand Down