Commit e0897e45 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Format testcases to run with py.test

parent db23ae92
#!/usr/bin/env python
import opengeode
from opengeode.ogParser import parser_init
# detect syntax errors (missing semi after "entry")
print('composite_state_body:')
test=opengeode.ogParser.parser_init(string=
'''state ENTRYA;
substructure
procedure entry EXTERNAL;
endsubstructure ENTRYA;
''')
test.composite_state_body()
print('composite_state:')
test=opengeode.ogParser.parser_init(string=
'''state CHECKING;
substructure
state ENTRYA;
substructure
procedure entry EXTERNAL;
endsubstructure ENTRYA;
endsubstructure CHECKING;
''')
test.composite_state()
print('composite_state (should have no error)')
test=opengeode.ogParser.parser_init(string=
'''state CHECKING;
substructure
state ENTRYA;
endstate ENTRYA;
endsubstructure CHECKING;
''')
test.composite_state()
print('composite_state_body 2:')
test=opengeode.ogParser.parser_init(string=
'''state ENTRYA;
endstate;
''')
test.composite_state_body()
print('from rm - reports that start must be before state:')
test=opengeode.ogParser.parser_init(string=
'''
STATE AGGREGATION DemoDeviceDACPStates;
SUBSTRUCTURE
STATE INTERNAL_MAPPINGS;
SUBSTRUCTURE
STATE STATELESS;
ENDSTATE STATELESS;
START;
NEXTSTATE STATELESS;
ENDSUBSTRUCTURE INTERNAL_MAPPINGS;
ENDSUBSTRUCTURE DemoDeviceDACPStates;
''')
test.composite_state()
print('from rm(2) - reports that start must be before state:')
test=opengeode.ogParser.parser_init(string=
'''
process hello;
STATE AGGREGATION DemoDeviceDACPStates;
SUBSTRUCTURE
STATE INTERNAL_MAPPINGS;
SUBSTRUCTURE
STATE STATELESS;
ENDSTATE STATELESS;
START;
NEXTSTATE STATELESS;
ENDSUBSTRUCTURE INTERNAL_MAPPINGS;
ENDSUBSTRUCTURE DemoDeviceDACPStates;
end hello;
''')
def test_composite_state_body_1():
test = parser_init(string=
'''state ENTRYA;
substructure
procedure entry EXTERNAL;
endsubstructure ENTRYA;
''')
test.composite_state_body()
def test_composite_state_1():
test = parser_init(string=
'''state CHECKING;
substructure
state ENTRYA;
substructure
procedure entry EXTERNAL;
endsubstructure ENTRYA;
endsubstructure CHECKING;
''')
test.composite_state()
def test_composite_state_2():
print('composite_state (should have no error)')
test.process_definition()
test=parser_init(string=
'''state CHECKING;
substructure
state ENTRYA;
endstate ENTRYA;
endsubstructure CHECKING;
''')
test.composite_state()
def test_composite_state_body_1():
print('composite_state_body 2:')
test=parser_init(string=
'''state ENTRYA;
endstate;
''')
test.composite_state_body()
def test_composite_state_3():
print('from rm - reports that start must be before state:')
test=parser_init(string=
'''
STATE AGGREGATION DemoDeviceDACPStates;
SUBSTRUCTURE
STATE INTERNAL_MAPPINGS;
SUBSTRUCTURE
STATE STATELESS;
ENDSTATE STATELESS;
START;
NEXTSTATE STATELESS;
ENDSUBSTRUCTURE INTERNAL_MAPPINGS;
ENDSUBSTRUCTURE DemoDeviceDACPStates;
''')
test.composite_state()
def test_composite_state_4():
print('from rm(2) - reports that start must be before state:')
test=parser_init(string=
'''
process hello;
STATE AGGREGATION DemoDeviceDACPStates;
SUBSTRUCTURE
STATE INTERNAL_MAPPINGS;
SUBSTRUCTURE
STATE STATELESS;
ENDSTATE STATELESS;
START;
NEXTSTATE STATELESS;
ENDSUBSTRUCTURE INTERNAL_MAPPINGS;
ENDSUBSTRUCTURE DemoDeviceDACPStates;
end hello;
''')
test.process_definition()
if __name__ == '__main__':
for name, value in dict(globals()).viewitems():
if name.startswith('test_'):
print('---- Executing {} ----'.format(name))
value()
print('---- Done - {} ----\n'.format(name))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment