Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
541a7be2
Commit
541a7be2
authored
3 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-705
: Add test for read_attribute
parent
19fce86c
No related branches found
No related tags found
1 merge request
!274
L2SS-705: Read values directly from the hardware instead of through the proxy
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tangostationcontrol/tangostationcontrol/test/devices/test_lofar_device.py
+54
-0
54 additions, 0 deletions
...rol/tangostationcontrol/test/devices/test_lofar_device.py
with
54 additions
and
0 deletions
tangostationcontrol/tangostationcontrol/test/devices/test_lofar_device.py
0 → 100644
+
54
−
0
View file @
541a7be2
# -*- coding: utf-8 -*-
#
# This file is part of the LOFAR 2.0 Station Software
#
#
#
# Distributed under the terms of the APACHE license.
# See LICENSE.txt for more info.
from
tango.test_context
import
DeviceTestContext
from
tango.server
import
attribute
from
tangostationcontrol.devices
import
lofar_device
import
mock
from
tangostationcontrol.test
import
base
class
TestLofarDevice
(
base
.
TestCase
):
def
setUp
(
self
):
super
(
TestLofarDevice
,
self
).
setUp
()
# Patch DeviceProxy to allow making the proxies during initialisation
# that we otherwise avoid using
for
device
in
[
lofar_device
]:
proxy_patcher
=
mock
.
patch
.
object
(
device
,
'
DeviceProxy
'
)
proxy_patcher
.
start
()
self
.
addCleanup
(
proxy_patcher
.
stop
)
def
test_read_attribute
(
self
):
"""
Test whether read_attribute really returns the attribute.
"""
class
MyLofarDevice
(
lofar_device
.
lofar_device
):
@attribute
(
dtype
=
float
)
def
A
(
self
):
return
42.0
@attribute
(
dtype
=
float
)
def
read_attribute_A
(
self
):
return
self
.
read_attribute
(
"
A
"
)
@attribute
(
dtype
=
(
float
,),
max_dim_x
=
2
)
def
B_array
(
self
):
return
[
42.0
,
43.0
]
@attribute
(
dtype
=
(
float
,),
max_dim_x
=
2
)
def
read_attribute_B_array
(
self
):
return
self
.
read_attribute
(
"
B_array
"
)
with
DeviceTestContext
(
MyLofarDevice
,
process
=
True
,
timeout
=
10
)
as
proxy
:
proxy
.
initialise
()
self
.
assertEqual
(
42.0
,
proxy
.
read_attribute_A
)
self
.
assertListEqual
([
42.0
,
43.0
],
proxy
.
read_attribute_B_array
.
tolist
())
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