Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos
Commits
f1cbd577
Commit
f1cbd577
authored
Jan 05, 2024
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
f7c25c3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
45 deletions
+46
-45
software/ors-amarisoft/test/test.py
software/ors-amarisoft/test/test.py
+46
-45
No files found.
software/ors-amarisoft/test/test.py
View file @
f1cbd577
...
...
@@ -22,6 +22,7 @@ import io
import
yaml
import
pcpp
import
unittest
from
slapos.testing.testcase
import
makeModuleSetUpAndTestCaseClass
setUpModule
,
AmariTestCase
=
makeModuleSetUpAndTestCaseClass
(
...
...
@@ -257,56 +258,12 @@ class TestENB_SDR(ENBTestCase):
# assertDict asserts that d slice with keys from dok == dok.
# dok[k]=NO means d[k] must be absent.
# XXX -> assertMatch with support for {} and []
class
NOClass
:
def
__repr__
(
self
):
return
'ø'
NO
=
NOClass
()
def
assertDict
(
d
,
dok
):
d_
=
{}
for
k
in
dok
:
d_
[
k
]
=
d
.
get
(
k
,
NO
)
self
.
assertEqual
(
d_
,
dok
)
# assertMatch recursively matches data structure against specified pattern.
#
# - atomic types like int and str match by equality
# - list match by matching all elements individually
# - dict match by verifying v[k] == vok[k] for keys from the pattern
# vok[k]=NO means v[k] must be absent
def
assertMatch
(
v
,
vok
):
v_
=
_matchCollect
(
v
,
vok
)
self
.
assertEqual
(
v_
,
vok
)
def
_matchCollect
(
v
,
vok
):
if
type
(
v
)
is
not
type
(
vok
):
return
v
if
type
(
v
)
is
dict
:
v_
=
{}
for
k
in
vok
:
#v_[k] = v.get(k, NO)
v_
[
k
]
=
_matchCollect
(
v
.
get
(
k
,
NO
),
vok
[
k
])
return
v_
if
type
(
v
)
is
list
:
v_
=
[]
for
i
in
range
(
max
(
len
(
v
),
len
(
vok
))):
e
=
NO
eok
=
NO
if
i
<
len
(
v
):
e
=
v
[
i
]
if
i
<
len
(
vok
):
eok
=
vok
[
i
]
if
e
is
not
NO
:
if
eok
is
not
NO
:
v_
.
append
(
_matchCollect
(
e
,
eok
))
else
:
v_
.
append
(
e
)
return
v_
# other types, e.g. atomic int/str/... - return as is
assert
type
(
v
)
is
not
tuple
,
v
return
v
cell_list
=
conf
[
'cell_list'
]
nr_cell_list
=
conf
[
'nr_cell_list'
]
self
.
assertEqual
(
len
(
cell_list
),
2
)
...
...
@@ -353,7 +310,7 @@ class TestENB_SDR(ENBTestCase):
)})
# Carrier Aggregation
assertMatch
(
cell_list
,
[
assertMatch
(
self
,
cell_list
,
[
{
'scell_list'
:
[{
'cell_id'
:
0x2
}],
# LTE + LTE
'en_dc_scg_cell_list'
:
[{
'cell_id'
:
0x3
},
{
'cell_id'
:
0x4
}],
# LTE + NR
...
...
@@ -537,3 +494,47 @@ class TestUEMonitorGadgetUrl(ORSTestCase):
def test_monitor_gadget_url(self):
test_monitor_gadget_url(self)
"""
# assertMatch recursively matches data structure against specified pattern.
#
# - dict match by verifying v[k] == vok[k] for keys from the pattern.
# vok[k]=NO means v[k] must be absent
# - list match by matching all elements individually
# - atomic types like int and str match by equality
class
NOClass
:
def
__repr__
(
self
):
return
'ø'
NO
=
NOClass
()
def
assertMatch
(
t
:
unittest
.
TestCase
,
v
,
vok
):
v_
=
_matchCollect
(
v
,
vok
)
t
.
assertEqual
(
v_
,
vok
)
def
_matchCollect
(
v
,
vok
):
if
type
(
v
)
is
not
type
(
vok
):
return
v
if
type
(
v
)
is
dict
:
v_
=
{}
for
k
in
vok
:
#v_[k] = v.get(k, NO)
v_
[
k
]
=
_matchCollect
(
v
.
get
(
k
,
NO
),
vok
[
k
])
return
v_
if
type
(
v
)
is
list
:
v_
=
[]
for
i
in
range
(
max
(
len
(
v
),
len
(
vok
))):
e
=
NO
eok
=
NO
if
i
<
len
(
v
):
e
=
v
[
i
]
if
i
<
len
(
vok
):
eok
=
vok
[
i
]
if
e
is
not
NO
:
if
eok
is
not
NO
:
v_
.
append
(
_matchCollect
(
e
,
eok
))
else
:
v_
.
append
(
e
)
return
v_
# other types, e.g. atomic int/str/... - return as is
assert
type
(
v
)
is
not
tuple
,
v
return
v
Write
Preview
Markdown
is supported
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