Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
asn1-value-editor
Commits
4c5c2d74
Commit
4c5c2d74
authored
Jul 16, 2016
by
Maxime Perrotin
Browse files
Group tests for a given asn1 file
parent
94ea8d99
Changes
2
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/standalone_editor.py
View file @
4c5c2d74
...
...
@@ -152,7 +152,7 @@ def asn1sccToasn1ValueEditorTypes(dataview, name, asntype):
class
SingleValueEditor
(
QObject
):
''' Main class '''
def
__init__
(
self
,
asnFile
,
paramsAndTypes
=
None
,
parent
=
None
):
def
__init__
(
self
,
asnFile
,
parent
=
None
):
'''
Load the ASN.1 file and create the widgets for all parameters passed
as arguments (once for all).
...
...
@@ -264,6 +264,9 @@ class SingleValueEditor(QObject):
# Create a ctypes instance of the variable and set it to the editor
instance
=
getattr
(
self
.
asn1ctypes
,
asnType
.
replace
(
'-'
,
'_'
))()
widget
[
'editor'
].
asn1Instance
=
instance
logger
.
info
(
'Created instance of '
+
asnType
)
x
=
instance
.
Get
()
if
defValue
:
valueNotationToCTypes
(
gser
=
defValue
,
dest
=
instance
,
...
...
@@ -328,7 +331,7 @@ def main():
app
.
setStyle
(
"cleanlooks"
)
# Initialize the editor with a dictionary of pairs ParamName/ParamType:
s
=
SingleValueEditor
(
options
.
asn
,
paramsAndTypes
=
{
'param'
:
options
.
asnType
}
)
s
=
SingleValueEditor
(
options
.
asn
)
# Open the value editor and retrieve the value, if Cancel has not been pressed
result
=
s
.
editParam
(
options
.
asnType
,
options
.
asnValue
)
...
...
test/pytest/test_standalone.py
View file @
4c5c2d74
...
...
@@ -11,35 +11,30 @@ Use py.test-2.7 to run these tests, and make sure you have installed pytest-qt
pip install --user pytest-qt
'''
def
common
(
asn1File
,
typeName
,
defValue
):
def
common
(
editor
,
typeName
,
defValue
):
''' Set up test case: create asn1 editor and fill with default value '''
s
=
editor
.
SingleValueEditor
(
asn1File
,
paramsAndTypes
=
{
'param'
:
typeName
})
widget
=
s
.
setupEdit
(
typeName
,
defValue
=
defValue
)[
'editor'
]
widget
=
editor
.
setupEdit
(
typeName
,
defValue
=
defValue
)[
'editor'
]
widget
.
getVariable
(
dest
=
widget
.
asn1Instance
)
return
widget
.
asn1Instance
.
GSER
()
def
test_true
(
qtbot
):
''' Most basic test: single boolean type '''
typeName
=
"Ahah"
def
test_manytypes
(
qtbot
):
''' Test all types defined in dv1.asn '''
s
=
editor
.
SingleValueEditor
(
'data/dv1.asn'
)
typeName
=
"Type-SingleBool"
defValue
=
'TRUE'
result
=
common
(
'data/dv2.asn'
,
typeName
,
defValue
)
result
=
common
(
s
,
typeName
,
defValue
)
assert
result
==
defValue
def
test_false
(
qtbot
):
''' Test with a single boolean type '''
typeName
=
"Ahah"
defValue
=
'FALSE'
result
=
common
(
'data/dv2.asn'
,
typeName
,
defValue
)
result
=
common
(
s
,
typeName
,
defValue
)
assert
result
==
defValue
def
test_alltypes
(
qtbot
):
''' More complete test with various types/editors '''
typeName
=
"Type-SingleInt"
defValue
=
'42'
result
=
common
(
'data/dv1.asn'
,
typeName
,
defValue
)
result
=
common
(
s
,
typeName
,
defValue
)
assert
result
==
defValue
if
__name__
==
'__main__'
:
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)'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment