Skip to content

Commit

Permalink
Merge pull request #247 from test-fullautomation/HolQue/task/selftest…
Browse files Browse the repository at this point in the history
…_maintenance

Update of code snippet generator (naming convention snippets)
  • Loading branch information
test-fullautomation authored Mar 20, 2024
2 parents 7c39606 + 1f4f7c6 commit f11e4eb
Show file tree
Hide file tree
Showing 11 changed files with 319 additions and 9 deletions.
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.32.0"
VERSION_DATE = "18.03.2024"
VERSION = "0.33.0"
VERSION_DATE = "19.03.2024"
#
# --------------------------------------------------------------------------------------------------------------
#TM***
Expand Down
118 changes: 115 additions & 3 deletions test/testconfig/TestConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#
# --------------------------------------------------------------------------------------------------------------
#
# 18.03.2024
# 19.03.2024
#
# !!! Temporarily tests are deactivated by the following line commented out:
# # # listofdictUsecases.append(dictUsecase)
Expand Down Expand Up @@ -1757,9 +1757,121 @@
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0450.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = "detected unexpected characters in parameter name (placeholder)"
dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO / something like: "naming convention violation; allowed characters are ... only"!!!
dictUsecase['EXPECTEDRETURN'] = None
# # # listofdictUsecases.append(dictUsecase) # still naming convention issue
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_0451"
dictUsecase['DESCRIPTION'] = "JSON file with parameter name containing single not allowed special character (1)"
dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception"
dictUsecase['SECTION'] = "NAMING_CONVENTION"
dictUsecase['SUBSECTION'] = "BADCASE"
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0451.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO / something like: "naming convention violation; allowed characters are ... only"!!!
dictUsecase['EXPECTEDRETURN'] = None
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_0452"
dictUsecase['DESCRIPTION'] = "JSON file with parameter name containing single not allowed special character (2)"
dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception"
dictUsecase['SECTION'] = "NAMING_CONVENTION"
dictUsecase['SUBSECTION'] = "BADCASE"
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0452.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO / something like: "naming convention violation; allowed characters are ... only"!!!
dictUsecase['EXPECTEDRETURN'] = None
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_0453"
dictUsecase['DESCRIPTION'] = "JSON file with parameter name containing single not allowed special character (3)"
dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception"
dictUsecase['SECTION'] = "NAMING_CONVENTION"
dictUsecase['SUBSECTION'] = "BADCASE"
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0453.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO / something like: "naming convention violation; allowed characters are ... only"!!!
dictUsecase['EXPECTEDRETURN'] = None
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_0454"
dictUsecase['DESCRIPTION'] = "JSON file with parameter name containing single not allowed special character (4)"
dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception"
dictUsecase['SECTION'] = "NAMING_CONVENTION"
dictUsecase['SUBSECTION'] = "BADCASE"
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0454.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO / something like: "naming convention violation; allowed characters are ... only"!!!
dictUsecase['EXPECTEDRETURN'] = None
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_0455"
dictUsecase['DESCRIPTION'] = "JSON file with parameter name containing single not allowed special character (5)"
dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception"
dictUsecase['SECTION'] = "NAMING_CONVENTION"
dictUsecase['SUBSECTION'] = "BADCASE"
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0455.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO / something like: "naming convention violation; allowed characters are ... only"!!!
dictUsecase['EXPECTEDRETURN'] = None
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_0456"
dictUsecase['DESCRIPTION'] = "JSON file with parameter name containing single not allowed special character (6)"
dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception"
dictUsecase['SECTION'] = "NAMING_CONVENTION"
dictUsecase['SUBSECTION'] = "BADCASE"
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0456.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO / something like: "naming convention violation; allowed characters are ... only"!!!
dictUsecase['EXPECTEDRETURN'] = None
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_0457"
dictUsecase['DESCRIPTION'] = "JSON file with parameter name containing single not allowed special character (7)"
dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception"
dictUsecase['SECTION'] = "NAMING_CONVENTION"
dictUsecase['SUBSECTION'] = "BADCASE"
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0457.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO / something like: "naming convention violation; allowed characters are ... only"!!!
dictUsecase['EXPECTEDRETURN'] = None
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
dictUsecase = {}
dictUsecase['TESTID'] = "JPP_0458"
dictUsecase['DESCRIPTION'] = "JSON file with parameter name containing single not allowed special character (8)"
dictUsecase['EXPECTATION'] = "No values are returned, and JsonPreprocessor throws an exception"
dictUsecase['SECTION'] = "NAMING_CONVENTION"
dictUsecase['SUBSECTION'] = "BADCASE"
dictUsecase['HINT'] = None
dictUsecase['COMMENT'] = None
dictUsecase['JSONFILE'] = r"..\testfiles\jpp-test_config_0458.jsonp"
dictUsecase['EXPECTEDEXCEPTION'] = None # # !!! expectation TODO / something like: "naming convention violation; allowed characters are ... only"!!!
dictUsecase['EXPECTEDRETURN'] = None
# # # listofdictUsecases.append(dictUsecase)
del dictUsecase
# --------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------
Expand Down
17 changes: 17 additions & 0 deletions test/testfiles/jpp-test_config_0451.jsonp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.
//**************************************************************************
{
"param-1" : "value"
}
17 changes: 17 additions & 0 deletions test/testfiles/jpp-test_config_0452.jsonp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.
//**************************************************************************
{
"param/1" : "value"
}
17 changes: 17 additions & 0 deletions test/testfiles/jpp-test_config_0453.jsonp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.
//**************************************************************************
{
"param\\1" : "value"
}
17 changes: 17 additions & 0 deletions test/testfiles/jpp-test_config_0454.jsonp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.
//**************************************************************************
{
"param\\\\1" : "value"
}
17 changes: 17 additions & 0 deletions test/testfiles/jpp-test_config_0455.jsonp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.
//**************************************************************************
{
"dictParam" : {"key-A" : 1, "keyB" : 2}
}
17 changes: 17 additions & 0 deletions test/testfiles/jpp-test_config_0456.jsonp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.
//**************************************************************************
{
"dictParam" : {"key/A" : 1, "keyB" : 2}
}
17 changes: 17 additions & 0 deletions test/testfiles/jpp-test_config_0457.jsonp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.
//**************************************************************************
{
"dictParam" : {"key\\A" : 1, "keyB" : 2}
}
17 changes: 17 additions & 0 deletions test/testfiles/jpp-test_config_0458.jsonp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.
//**************************************************************************
{
"dictParam" : {"key\\\\A" : 1, "keyB" : 2}
}
70 changes: 66 additions & 4 deletions test/testtools/GenSnippetsJPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#
# **************************************************************************************************************
#
VERSION = "0.15.0"
VERSION_DATE = "18.03.2024"
VERSION = "0.16.0"
VERSION_DATE = "19.03.2024"
#
# **************************************************************************************************************

Expand Down Expand Up @@ -1888,10 +1888,10 @@ def GetSpecialCharacters(self):
# --------------------------------------------------------------------------------------------------------------

def GetSlicing(self):
"""Several particular snippets containing slicing syntax
"""Several snippets containing slicing syntax
"""

sHeadline = "Several particular snippets containing slicing syntax"
sHeadline = "Several snippets containing slicing syntax"

sDataStructure1 = """ "param1" : ${stringParam}[*01*],
"param2" : ${listParam}[*02*],
Expand Down Expand Up @@ -1952,6 +1952,65 @@ def GetSlicing(self):

# eof def GetSlicing(self):

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

def GetNamingConventions(self):
"""Several snippets containing naming convention issues
"""

sHeadline = "Several snippets containing naming convention issues"

sDataStructure1 = """ "param*01*1" : "value",
"param2" : "val*02*ue",
"${param2}" : 1,
"dictParam" : {"key*03*A" : 2, "keyB" : {"key*04*C" : 3}}"""

sCodeSnippetPattern = """{
####DATASTRUCTURE####
}
"""

# We have a list of expressions and we have a list of placeholders like used in sDataStructure1.
# The followig code runs in a nested loop: Every expression is placed at every placeholder position. Only one single
# expression and placeholder per iteration. All remaining placeholders in current iteration are replaced by elements
# from a list of filler expressions (simple letters) that are only used to complete the code snippet, but are not in focus.

listExpressions = ["-", "+", "*", "|", "/", "$", "%", "#", "\\", "\\\\"]

listPlaceholders = ["*01*", "*02*", "*03*", "*04*"]

listPositions = listPlaceholders[:] # to support a nested iteration of the same list; better readibility of code because of different names

listFiller = ["","","",""] # as much elements as in listPlaceholders

# put all things together

listCodeSnippets = []

# sDataStructure1

for sExpression in listExpressions:
for sPosition in listPositions:
sDataStructure = sDataStructure1 # init a new data structure from pattern sDataStructure1
sCodeSnippet = sCodeSnippetPattern # init a new code snippet from code snippet pattern
oFiller = CListElements(listFiller) # init a new filler object (= content for remaining placeholders)
for sPlaceholder in listPlaceholders:
sFiller = oFiller.GetElement()
if sPosition == sPlaceholder:
sDataStructure = sDataStructure.replace(sPlaceholder, sExpression)
else:
sDataStructure = sDataStructure.replace(sPlaceholder, f"{sFiller}")
# eof for sPlaceholder in listPlaceholders:
sCodeSnippet = sCodeSnippet.replace("####DATASTRUCTURE####", sDataStructure)
listCodeSnippets.append(sCodeSnippet)
# eof for sPosition in listPositions:
# eof for sExpression in listExpressions:

return sHeadline, listCodeSnippets

# eof def GetNamingConventions(self):


# eof class CSnippets():

# --------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2086,6 +2145,9 @@ def GetSlicing(self):
sHeadline, listCodeSnippets = oSnippets.GetSlicing()
bSuccess, sResult = oExecutor.Execute(sHeadline, listCodeSnippets, "JPP")

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

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

0 comments on commit f11e4eb

Please sign in to comment.