fix handling of StructOf datatype

- change secop.client.SecopClient to use native types instead of
  strings for its setParameter and execCommand methods.
- secop-gui: for now, setParameter accept strings for complex types.
  this should be changed to use native type in an other change
- fix bugs in parser.py

+ SecopClient: make visible in an error message that the error
  was generated on the SEC node
+ fix a bug when a command is called with 0 as argument

Change-Id: Id87d4678311ef8cf43a25153254d36127e16c6d9
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/23299
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2020-06-24 14:15:35 +02:00
parent c16adf38cd
commit 1655e252fc
6 changed files with 54 additions and 42 deletions

View File

@ -23,6 +23,7 @@
from collections import OrderedDict
from ast import literal_eval
import pytest
@ -46,7 +47,7 @@ def test_Parser_parse_number(parser):
def test_Parser_parse_string(parser):
assert parser.parse_string('%') == (None, '%')
assert parser.parse_string('a') == ('a', '')
assert parser.parse_string('Hello World!') == ('Hello', ' World!')
assert parser.parse_string('Hello World!') == ('Hello', 'World!')
assert parser.parse_string('Hello<World!') == ('Hello', '<World!')
assert parser.parse_string('"Hello World!\'') == (None, '"Hello World!\'')
assert parser.parse_string('"Hello World!\\"') == (
@ -75,7 +76,7 @@ def test_Parser_parse(parser):
assert parser.parse('1.23e-04:9') == (1.23e-4, ':9')
assert parser.parse('%') == (None, '%')
assert parser.parse('Hello World!') == ('Hello', ' World!')
assert parser.parse('Hello World!') == ('Hello', 'World!')
assert parser.parse('Hello<World!') == ('Hello', '<World!')
assert parser.parse('"Hello World!\'') == (None, '"Hello World!\'')
assert parser.parse('"Hello World!\\"') == (None, '"Hello World!\\"')
@ -93,3 +94,18 @@ def test_Parser_parse(parser):
assert parser.parse('1, 2,a,c') == ((1, 2, 'a', 'c'), '')
assert parser.parse('"\x09 \r"') == ('\t \r', '')
# valid python syntax must always be valid
@pytest.mark.parametrize('string', [
"{'a': 0, 'b': 1}",
"(1,)",
"{'a': 'x' , 'b': 1}",
"{'a': 'x' , 'b': 1,}",
"{'a':['b' ] ,}",
"(1,[1] ,)",
])
def test_python_literal(parser, string):
literal_eval(string) # prove str is valid
_, remaining = parser.parse(string)
assert remaining == ''