test_standalone.py 1.19 KB
Newer Older
Maxime Perrotin's avatar
Maxime Perrotin committed
1
2
3
4
5
6
7
8
#!/usr/bin/env python

import sys

sys.path.insert(0, '../..')
from asn1_value_editor import standalone_editor as editor
editor.logger.setLevel(editor.logging.DEBUG)

9
'''
Maxime Perrotin's avatar
Maxime Perrotin committed
10
Use py.test-2.7 to run these tests, and make sure you have installed pytest-qt
11
12
13
pip install --user pytest-qt
'''

14
def common(editor, typeName, defValue):
Maxime Perrotin's avatar
Maxime Perrotin committed
15
    ''' Set up test case: create asn1 editor and fill with default value '''
16
    widget = editor.setupEdit(typeName, defValue=defValue)['editor']
17
    widget.getVariable(dest=widget.asn1Instance)
Maxime Perrotin's avatar
Maxime Perrotin committed
18
19
    return widget.asn1Instance.GSER()

20
21
22
23
24
def test_manytypes(qtbot):
    ''' Test all types defined in dv1.asn '''
    s = editor.SingleValueEditor('data/dv1.asn')

    typeName = "Type-SingleBool"
Maxime Perrotin's avatar
Maxime Perrotin committed
25
    defValue = 'TRUE'
26
    result = common(s, typeName, defValue)
Maxime Perrotin's avatar
Maxime Perrotin committed
27
    assert result == defValue
28

Maxime Perrotin's avatar
Maxime Perrotin committed
29
    defValue = 'FALSE'
30
    result = common(s, typeName, defValue)
Maxime Perrotin's avatar
Maxime Perrotin committed
31
32
33
34
    assert result == defValue

    typeName = "Type-SingleInt"
    defValue = '42'
35
    result = common(s, typeName, defValue)
Maxime Perrotin's avatar
Maxime Perrotin committed
36
    assert result == defValue
Maxime Perrotin's avatar
Maxime Perrotin committed
37
38

if __name__ == '__main__':
Maxime Perrotin's avatar
Maxime Perrotin committed
39
40
41
    print('You must run py.test-2.7 to execute this test script')
    print('Make sure you have pytest-qt (pip install --user pytest-qt)')
    sys.exit(1)