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
4 changes: 4 additions & 0 deletions test/JPP_TestUsecases.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -48,3 +49,6 @@ JPP_0952|COMMON_SYNTAX_VIOLATIONS|BADCASE|JSON file with syntax error (3)
JPP_0953|COMMON_SYNTAX_VIOLATIONS|BADCASE|JSON file with syntax error (4): file is completely empty
JPP_0954|COMMON_SYNTAX_VIOLATIONS|BADCASE|JSON file with syntax error (5): file is empty (multiple pairs of brackets only)
JPP_1000|IMPLICIT_CREATION|GOODCASE|JSON file with dictionary keys to be created implicitly
JPP_1150|CYCLIC_IMPORTS|BADCASE|JSON file with cyclic imports (JSON file imports itself)
JPP_1151|CYCLIC_IMPORTS|BADCASE|JSON file with cyclic imports (JSON file imports another file, that is already imported)
JPP_1200|PATH_FORMATS|GOODCASE|Relative path to JSON file
247 changes: 190 additions & 57 deletions test/JPP_TestUsecases.html

Large diffs are not rendered by default.

44 changes: 43 additions & 1 deletion test/JPP_TestUsecases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -537,5 +547,37 @@ Test Use Cases

----

Generated: 13.09.2023 - 10:58:36
* **Test JPP_1150**

[CYCLIC_IMPORTS / BADCASE]

**JSON file with cyclic imports (JSON file imports itself)**

Expected: No values are returned, and JsonPreprocessor throws an exception

----

* **Test JPP_1151**

[CYCLIC_IMPORTS / BADCASE]

**JSON file with cyclic imports (JSON file imports another file, that is already imported)**

Expected: No values are returned, and JsonPreprocessor throws an exception

----

* **Test JPP_1200**

[PATH_FORMATS / GOODCASE]

**Relative path to JSON file**

Expected: JsonPreprocessor resolves the relative path and returns values from JSON file

*Hint: Works with raw path to JSON file (path not normalized internally)*

----

Generated: 29.09.2023 - 15:06:38

19 changes: 18 additions & 1 deletion test/JPP_TestUsecases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -228,5 +232,18 @@ Test JPP_1000 / IMPLICIT_CREATION / GOODCASE
Description: JSON file with dictionary keys to be created implicitly
Expectation: JsonPreprocessor returns values
------------------------------------------------------------------------------------------------------------------------
Generated: 13.09.2023 - 10:58:36
Test JPP_1150 / CYCLIC_IMPORTS / BADCASE
Description: JSON file with cyclic imports (JSON file imports itself)
Expectation: No values are returned, and JsonPreprocessor throws an exception
------------------------------------------------------------------------------------------------------------------------
Test JPP_1151 / CYCLIC_IMPORTS / BADCASE
Description: JSON file with cyclic imports (JSON file imports another file, that is already imported)
Expectation: No values are returned, and JsonPreprocessor throws an exception
------------------------------------------------------------------------------------------------------------------------
Test JPP_1200 / PATH_FORMATS / GOODCASE
Description: Relative path to JSON file
Expectation: JsonPreprocessor resolves the relative path and returns values from JSON file
Hint.......: Works with raw path to JSON file (path not normalized internally)
------------------------------------------------------------------------------------------------------------------------
Generated: 29.09.2023 - 15:06:38

16 changes: 12 additions & 4 deletions test/component_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#
# --------------------------------------------------------------------------------------------------------------
#
VERSION = "0.9.0"
VERSION_DATE = "13.09.2023"
VERSION = "0.12.0"
VERSION_DATE = "29.09.2023"
#
# --------------------------------------------------------------------------------------------------------------
#TM***
Expand Down Expand Up @@ -403,15 +403,23 @@ 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:
HINT = dictUsecase['HINT']
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}]"
Expand Down
23 changes: 16 additions & 7 deletions test/libs/CGenCode.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# XC-CT/ECA3-Queckenstedt
#
# 23.06.2023
# 27.09.2023
#
# --------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -231,7 +239,7 @@ def GenCode(self):
<td colspan="1" valign="center" bgcolor="#F5F5F5" align="middle">
<font size="2" face="Arial" color="#595959">
<b>
####TESTID####
<a target="_blank" href="####JSONFILELINK####">####TESTID####</a>
</b></font></td>

<td colspan="1" valign="center" bgcolor="#F5F5F5" align="middle">
Expand All @@ -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":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
# XC-CT/ECA3-Queckenstedt
#
# 13.09.2023 - 10:58:36
# 28.09.2023 - 11:51:44
#
# --------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -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(
Expand Down
48 changes: 48 additions & 0 deletions test/pytest/pytestfiles/test_12_CYCLIC_IMPORTS_BADCASE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# **************************************************************************************************************
# Copyright 2020-2023 Robert Bosch GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# --------------------------------------------------------------------------------------------------------------
#
# test_12_CYCLIC_IMPORTS_BADCASE.py
#
# XC-CT/ECA3-Queckenstedt
#
# 28.09.2023 - 15:28:52
#
# --------------------------------------------------------------------------------------------------------------

import pytest
from pytestlibs.CExecute import CExecute

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

class Test_CYCLIC_IMPORTS_BADCASE:

# --------------------------------------------------------------------------------------------------------------
# Expected: No values are returned, and JsonPreprocessor throws an exception
@pytest.mark.parametrize(
"Description", ["JSON file with cyclic imports (JSON file imports itself)",]
)
def test_JPP_1150(self, Description):
nReturn = CExecute.Execute("JPP_1150")
assert nReturn == 0
# --------------------------------------------------------------------------------------------------------------
# Expected: No values are returned, and JsonPreprocessor throws an exception
@pytest.mark.parametrize(
"Description", ["JSON file with cyclic imports (JSON file imports another file, that is already imported)",]
)
def test_JPP_1151(self, Description):
nReturn = CExecute.Execute("JPP_1151")
assert nReturn == 0
# --------------------------------------------------------------------------------------------------------------
40 changes: 40 additions & 0 deletions test/pytest/pytestfiles/test_13_PATH_FORMATS_GOODCASE.py
Original file line number Diff line number Diff line change
@@ -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
# --------------------------------------------------------------------------------------------------------------
Loading