test-fullautomation / python-jsonpreprocessor

A preprocessor for json files
Apache License 2.0
2 stars 2 forks source link

Naming convention for parameter names #157

Closed HolQue closed 2 months ago

HolQue commented 8 months ago

The JSON code

"teststring-1"  : "teststring-1 value",
${teststring-1} : "${teststring-1} extended"

causes

'The variable '${teststring-1}' is not available!'

Reason is the minus character inside the parameter name.

Outcome: We need to define and publish a naming convention for parameter names.

If minus characters are allowed, the expected value is:

{'teststring-1': 'teststring-1 value extended'}

If minus characters are not allowed, the expected result is an error message telling about a naming convention violation.

But that the variable is not available, should not happen.

test-fullautomation commented 8 months ago

Hi Holger,

we should allow

According to this rules "teststring-1" : "teststring-1 value", should raise an error that "-" is not allowed as part of a variable.

Now this brings me really in trouble... On jsonpreprocessor level it is allowed to define a variable with hyphen, json has no limitations for names, even spaces should be allowed as key? But: What is RobotFramework core doing if it reaches there?

Thank you, Thomas

HolQue commented 8 months ago

Hi Thomas,

we should start with a smooth naming convention for stand alone JsonPreprocessor.

If it is necessary to strengthen this in case of the JsonPreprocessor is used in the context of RobotFramework AIO, this would be an issue for the TestsuitesManagement.

HolQue commented 7 months ago

Update:

Now the error message is:

Error: 'The variable '${teststring-11}' is not available!'!

Suddenly '11' instead of '1'. From where does the '11' come from?

HolQue commented 5 months ago

Still open.

namsonx commented 5 months ago

Update:

Now the error message is:

Error: 'The variable '${teststring-11}' is not available!'!

Suddenly '11' instead of '1'. From where does the '11' come from?

Hello Holger, I pushed new commit 2c562386eef to stabi branch to correct the error message issue above.

Hello @test-fullautomation, can we move this naming convention ticket to next release after we have a discussion about this ticket.

Thank you, Son

HolQue commented 5 months ago

'11' issue from

https://github.com/test-fullautomation/python-jsonpreprocessor/issues/157#issuecomment-1822774616

is solved.

HolQue commented 5 months ago

To answer the question in

https://github.com/test-fullautomation/python-jsonpreprocessor/issues/157#issuecomment-1746903631

JSON code passed to JsonPreprocessor:

"teststring-1"  : "teststring-1 value",
${teststring-1} : "teststring-1 value new",
${teststring-1} : "${teststring-1} extended"

Outcome:

Error: 'The variable '${teststring-1} ' is not available!'!

Same JSON code - but with added scope 'params.global' - passed to TestsuitesManagement:

"teststring-1"  : "teststring-1 value",
${params.global.teststring-1} : "teststring-1 value new",
${params.global.teststring-1} : "${params.global.teststring-1} extended",

Works fine. Value of ${teststring-1} is: 'teststring-1 value new extended'

Astonishing that the TestsuitesManagement works properly with code, that is not accepted by the JsonPreprocessor.

Why does the JsonPreprocessor not pass his error to the TestsuitesManagement?

Which behavior is the desired one?

HolQue commented 5 months ago

Cross check with asterisk inside parameter name:

JsonPreprocessor:

"teststring*1"  : "teststring*1 value",
${teststring*1} : "teststring*1 value new",
${teststring*1} : "${teststring*1} extended"

TestsuitesManagement:

"teststring*1"  : "teststring*1 value",
${params.global.teststring*1} : "teststring*1 value new",
${params.global.teststring*1} : "${params.global.teststring*1} extended",

Outcome: Both components react with error: "Invalid parameter format in line: ..."

test-fullautomation commented 5 months ago

Hi Holger, can I close this ticket? Thank you, Thomas

HolQue commented 5 months ago

Hi Thomas,

some questions still not clarified:

Astonishing that the TestsuitesManagement works properly with code, that is not accepted by the JsonPreprocessor.
Why does the JsonPreprocessor not pass his error to the TestsuitesManagement?
Which behavior is the desired one?

https://github.com/test-fullautomation/python-jsonpreprocessor/issues/157#issuecomment-1907774471

HolQue commented 3 months ago

Retest successful.

Both JsonPreprocessor and TestsuitesManagement are able to handle a parameter with name 'teststring-1'

Issue can be closed.

test-fullautomation commented 2 months ago

integrated in RobotFramework AIO 0.11.0