Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rhosydd
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pkg
rhosydd
Commits
9888891b
Commit
9888891b
authored
4 years ago
by
Padiri Sivanandha Reddy
Browse files
Options
Downloads
Patches
Plain Diff
T5736: Python tests updated as per new VISS change
parent
7d420da9
Branches
apertis/v2021dev3
apertis/v2021pre
Branches containing commit
Tags
apertis/0.2020.3
Tags containing commit
2 merge requests
!27
Rhosysd libcanterbury removal
,
!18
T5736: Python tests updated as per new VISS change
Pipeline
#141859
passed
4 years ago
Stage: build
Stage: upload
Stage: OBS
Pipeline: rhosydd
#141860
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/integration.py
+49
-72
49 additions, 72 deletions
tests/integration.py
with
49 additions
and
72 deletions
tests/integration.py
+
49
−
72
View file @
9888891b
...
...
@@ -212,40 +212,26 @@ class TestWithMockBackend(unittest.TestCase):
return
None
def
test_vehicle_zones
(
self
):
"""
Test that the mock backend’s only vehicle’s zones are listed.
"""
mock_vehicle
=
self
.
__get_vehicle
(
'
mock
'
)
zones
=
mock_vehicle
.
get_zones
()
self
.
assertEqual
(
len
(
zones
),
1
)
root_zone
=
zones
[
0
]
self
.
assertEqual
(
root_zone
.
get_path
(),
'
/
'
)
self
.
assertEqual
(
root_zone
.
get_parent_path
(),
''
)
self
.
assertEqual
(
root_zone
.
get_tags
(),
[])
def
test_vehicle_all_metadata
(
self
):
"""
Test getting all metadata from a vehicle.
"""
mock_vehicle
=
self
.
__get_vehicle
(
'
mock
'
)
root_zone
=
Rhosydd
.
StaticZone
.
new
(
'
/
'
)
mock_vehicle
.
get_
all_
metadata_async
(
zone
=
root_zone
,
mock_vehicle
.
get_metadata_async
(
node_path
=
''
,
callback
=
self
.
_block_on_result_cb
,
user_data
=
self
)
(
metadata
,
current_time
)
=
\
mock_vehicle
.
get_
all_
metadata_finish
(
self
.
_block_on_result
())
mock_vehicle
.
get_metadata_finish
(
self
.
_block_on_result
())
# The mock backend currently exports
70
attributes.
self
.
assertEqual
(
len
(
metadata
),
70
)
# The mock backend currently exports
42
attributes.
self
.
assertEqual
(
len
(
metadata
),
42
)
# Pick a particular attribute to spot-check.
for
meta
in
metadata
:
if
meta
.
name
!=
'
lightStatus.automaticHeadlights
'
:
if
meta
.
name
!=
'
VehicleIdentification.bodyType
'
:
continue
self
.
assertEqual
(
meta
.
name
,
'
lightStatus.automaticHeadlights
'
)
self
.
assertEqual
(
meta
.
zone_path
,
'
/
'
)
self
.
assertEqual
(
meta
.
name
,
'
VehicleIdentification.bodyType
'
)
self
.
assertEqual
(
meta
.
availability
,
Rhosydd
.
AttributeAvailability
.
AVAILABLE
)
self
.
assertEqual
(
meta
.
flags
,
Rhosydd
.
AttributeFlags
.
READABLE
)
...
...
@@ -253,31 +239,28 @@ class TestWithMockBackend(unittest.TestCase):
def
test_vehicle_all_attributes
(
self
):
"""
Test getting all attributes from a vehicle.
"""
mock_vehicle
=
self
.
__get_vehicle
(
'
mock
'
)
root_zone
=
Rhosydd
.
StaticZone
.
new
(
'
/
'
)
mock_vehicle
.
get_
all_
attributes_async
(
zone
=
root_zone
,
mock_vehicle
.
get_attributes_async
(
node_path
=
''
,
callback
=
self
.
_block_on_result_cb
,
user_data
=
self
)
(
attributes
,
current_time
)
=
\
mock_vehicle
.
get_
all_
attributes_finish
(
self
.
_block_on_result
())
mock_vehicle
.
get_attributes_finish
(
self
.
_block_on_result
())
# The mock backend currently exports
70
attributes.
self
.
assertEqual
(
len
(
attributes
),
70
)
# The mock backend currently exports
42
attributes.
self
.
assertEqual
(
len
(
attributes
),
42
)
# Pick a particular attribute to spot-check.
for
attr
in
attributes
:
if
attr
.
metadata
.
name
!=
'
lightStatus.automaticHeadlights
'
:
if
attr
.
metadata
.
name
!=
'
IsMoving
'
:
continue
self
.
assertEqual
(
attr
.
attribute
.
accuracy
,
0.0
)
self
.
assertEqual
(
attr
.
attribute
.
last_updated
,
0
)
self
.
assertLessEqual
(
attr
.
attribute
.
last_updated
,
current_time
)
self
.
assertEqual
(
attr
.
attribute
.
value
,
GLib
.
Variant
(
'
b
'
,
Tru
e
))
self
.
assertEqual
(
attr
.
attribute
.
value
,
GLib
.
Variant
(
'
b
'
,
Fals
e
))
self
.
assertEqual
(
attr
.
metadata
.
name
,
'
lightStatus.automaticHeadlights
'
)
self
.
assertEqual
(
attr
.
metadata
.
zone_path
,
'
/
'
)
'
IsMoving
'
)
self
.
assertEqual
(
attr
.
metadata
.
availability
,
Rhosydd
.
AttributeAvailability
.
AVAILABLE
)
self
.
assertEqual
(
attr
.
metadata
.
flags
,
...
...
@@ -286,46 +269,41 @@ class TestWithMockBackend(unittest.TestCase):
def
test_vehicle_metadata
(
self
):
"""
Test getting metadata for a specific attribute from a vehicle.
"""
mock_vehicle
=
self
.
__get_vehicle
(
'
mock
'
)
root_zone
=
Rhosydd
.
StaticZone
.
new
(
'
/
'
)
mock_vehicle
.
get_metadata_async
(
zone
=
root_zone
,
attribute_name
=
'
lightStatus.automaticHeadlights
'
,
node_path
=
'
VehicleIdentification.bodyType
'
,
callback
=
self
.
_block_on_result_cb
,
user_data
=
self
)
(
metadata
,
current_time
)
=
\
(
metadata
s
,
current_time
)
=
\
mock_vehicle
.
get_metadata_finish
(
self
.
_block_on_result
())
self
.
assertEqual
(
metadata
.
name
,
'
lightStatus.automaticHeadlights
'
)
self
.
assertEqual
(
metadata
.
zone_path
,
'
/
'
)
self
.
assertEqual
(
metadata
.
availability
,
for
metadata
in
metadatas
:
self
.
assertEqual
(
metadata
.
name
,
'
VehicleIdentification.bodyType
'
)
self
.
assertEqual
(
metadata
.
availability
,
Rhosydd
.
AttributeAvailability
.
AVAILABLE
)
self
.
assertEqual
(
metadata
.
flags
,
Rhosydd
.
AttributeFlags
.
READABLE
)
self
.
assertEqual
(
metadata
.
flags
,
Rhosydd
.
AttributeFlags
.
READABLE
)
def
test_vehicle_attribute
(
self
):
"""
Test getting a specific attribute from a vehicle.
"""
mock_vehicle
=
self
.
__get_vehicle
(
'
mock
'
)
root_zone
=
Rhosydd
.
StaticZone
.
new
(
'
/
'
)
mock_vehicle
.
get_attribute_async
(
zone
=
root_zone
,
attribute_name
=
'
lightStatus.automaticHeadlights
'
,
mock_vehicle
.
get_attributes_async
(
node_path
=
'
VehicleIdentification.bodyType
'
,
callback
=
self
.
_block_on_result_cb
,
user_data
=
self
)
(
attribute
,
current_time
)
=
\
mock_vehicle
.
get_attribute_finish
(
self
.
_block_on_result
())
self
.
assertEqual
(
attribute
.
attribute
.
accuracy
,
0.0
)
self
.
assertEqual
(
attribute
.
attribute
.
last_updated
,
0
)
self
.
assertLessEqual
(
attribute
.
attribute
.
last_updated
,
current_time
)
self
.
assertEqual
(
attribute
.
attribute
.
value
,
GLib
.
Variant
(
'
b
'
,
True
))
self
.
assertEqual
(
attribute
.
metadata
.
name
,
'
lightStatus.automaticHeadlights
'
)
self
.
assertEqual
(
attribute
.
metadata
.
zone_path
,
'
/
'
)
self
.
assertEqual
(
attribute
.
metadata
.
availability
,
(
attributes
,
current_time
)
=
\
mock_vehicle
.
get_attributes_finish
(
self
.
_block_on_result
())
for
attribute
in
attributes
:
self
.
assertEqual
(
attribute
.
attribute
.
accuracy
,
0.0
)
self
.
assertLessEqual
(
attribute
.
attribute
.
last_updated
,
current_time
)
self
.
assertEqual
(
attribute
.
attribute
.
value
,
GLib
.
Variant
(
'
s
'
,
'
default
'
))
self
.
assertEqual
(
attribute
.
metadata
.
name
,
'
VehicleIdentification.bodyType
'
)
self
.
assertEqual
(
attribute
.
metadata
.
availability
,
Rhosydd
.
AttributeAvailability
.
AVAILABLE
)
self
.
assertEqual
(
attribute
.
metadata
.
flags
,
self
.
assertEqual
(
attribute
.
metadata
.
flags
,
Rhosydd
.
AttributeFlags
.
READABLE
)
def
test_vehicle_attribute_repeatedly
(
self
):
...
...
@@ -335,18 +313,17 @@ class TestWithMockBackend(unittest.TestCase):
the cache because we haven’t added a subscription (see T2042).
"""
speedo_vehicle
=
self
.
__get_vehicle
(
'
speedo
'
)
root_zone
=
Rhosydd
.
StaticZone
.
new
(
'
/front,left/
'
)
speedo_vehicle
.
get_attribute_async
(
zone
=
root_zone
,
attribute_name
=
'
wheelSpeed.value
'
,
speedo_vehicle
.
get_attributes_async
(
node_path
=
'
Signal.Acceleration.Y
'
,
callback
=
self
.
_block_on_result_cb
,
user_data
=
self
)
(
attribute
,
current_time
)
=
\
speedo_vehicle
.
get_attribute_finish
(
self
.
_block_on_result
())
initial_value
=
attribute
.
attribute
.
value
subsequent_value
=
initial_value
(
attributes
,
current_time
)
=
\
speedo_vehicle
.
get_attributes_finish
(
self
.
_block_on_result
())
for
attribute
in
attributes
:
initial_value
=
attribute
.
attribute
.
value
subsequent_value
=
initial_value
start_time
=
GLib
.
get_monotonic_time
()
...
...
@@ -355,15 +332,15 @@ class TestWithMockBackend(unittest.TestCase):
start_time
+
self
.
timeout_seconds
*
GLib
.
USEC_PER_SEC
):
time
.
sleep
(
0.5
)
# avoid a busy loop
speedo_vehicle
.
get_attribute_async
(
zone
=
root_zone
,
attribute_name
=
'
wheelSpeed.value
'
,
speedo_vehicle
.
get_attributes_async
(
node_path
=
'
Signal.Speed
'
,
callback
=
self
.
_block_on_result_cb
,
user_data
=
self
)
(
attribute
,
current_time
)
=
\
speedo_vehicle
.
get_attribute_finish
(
self
.
_block_on_result
())
(
attribute
s
,
current_time
)
=
\
speedo_vehicle
.
get_attribute
s
_finish
(
self
.
_block_on_result
())
subsequent_value
=
attribute
.
attribute
.
value
for
attribute
in
attributes
:
subsequent_value
=
attribute
.
attribute
.
value
def
test_exported_objects
(
self
):
"""
Test the SDK API only exports the objects we expect.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment