diff --git a/bliss/controllers/tango_attr_as_counter.py b/bliss/controllers/tango_attr_as_counter.py index 68670f6215f0c0a491ebbcfed37857ba686f9bc4..db19cf2deda076545e1afc972e2434cbb00f5afe 100644 --- a/bliss/controllers/tango_attr_as_counter.py +++ b/bliss/controllers/tango_attr_as_counter.py @@ -41,7 +41,7 @@ bliss/tests/test_configuration/tango_attribute_counter.yml import weakref from bliss.common.measurement import SamplingCounter -from bliss.common.tango import DeviceProxy +import tango from bliss import global_map from bliss.common.logtools import * @@ -64,7 +64,7 @@ def get_proxy(tango_uri): get_proxy.proxies = dict() # print (f"get_proxy -- create proxy for {tango_uri}") finally: - get_proxy.proxies[tango_uri] = DeviceProxy(tango_uri) + get_proxy.proxies[tango_uri] = tango.DeviceProxy(tango_uri) return get_proxy.proxies[tango_uri] @@ -116,7 +116,7 @@ class _CtrGroupRead(object): for attr in dev_attrs: error = attr.get_err_stack() if error: - raise PyTango.DevFailed(*error) + raise tango.DevFailed(*error) attr_values = [dev_attr.value for dev_attr in dev_attrs] log_debug(self, f"tango -- {self._tango_uri} -- values: {attr_values}") diff --git a/doc/docs/dev_testing.md b/doc/docs/dev_testing.md index 7eca59238847555ebc594d3ed5ba3a135b692a7e..a858c74c01085fd6fa986f564087d6ef3d6b3a57 100644 --- a/doc/docs/dev_testing.md +++ b/doc/docs/dev_testing.md @@ -79,9 +79,11 @@ Coverage indicates the percentage of lines touched by current tests suite. Example to get a coverage report: - py.test tests/controllers_sw/test_multiple_positions.py - --cov-report=html +```bash +py.test tests/controllers_sw/test_multiple_positions.py \ + --cov-report=html \ --cov bliss.controllers.multiplepositions +``` Coverage report indicating tested lines is in: ./htmlcov/index.html diff --git a/tests/controllers_sw/test_tango_attr_counters.py b/tests/controllers_sw/test_tango_attr_counters.py deleted file mode 100644 index 7059f1dbad2d9abf0dd89237de1cdde6f522434c..0000000000000000000000000000000000000000 --- a/tests/controllers_sw/test_tango_attr_counters.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of the bliss project -# -# Copyright (c) 2015-2019 Beamline Control Unit, ESRF -# Distributed under the GNU LGPLv3. See LICENSE for more info. - -import pytest - - -def test_tac_undu(beacon, dummy_tango_server): - tac_pos = beacon.get("tac_undu_position") - - u23a = beacon.get("u23a") - - assert u23a.position == 1.4 - assert u23a.position == tac_pos.read() diff --git a/tests/test_configuration/tango_attribute_counter.yml b/tests/test_configuration/tango_attribute_counter.yml index 70ee811093aeed7c99f08b6609b41230feb741be..9f97ced5bf1bfc3e2d5d839e2552b95ec1a3029f 100644 --- a/tests/test_configuration/tango_attribute_counter.yml +++ b/tests/test_configuration/tango_attribute_counter.yml @@ -5,3 +5,26 @@ - name: tac_undu_position attr_name: position unit: mm + - name: tac_undu_acceleration + attr_name: acceleration + # no unit for test. + - name: tac_undu_velocity + attr_name: velocity + unit: mm + - name: wrong_counter + attr_name: wrong_attr + unit: mm + - name: tac_undu_cracoucas + attr_name: cracoucas + # wrong attr_name. + + +- class: tango_attr_as_counter + plugin: bliss + counters: + - name: no_uri_counter + attr_name: no_uri_attr + + + + diff --git a/tests/test_counters.py b/tests/test_counters.py index 77a51b3eb6a2e52e306c7b8892a50568cc323be3..e679827995869bb08f540f25492a8dc3ebd62279 100644 --- a/tests/test_counters.py +++ b/tests/test_counters.py @@ -7,8 +7,9 @@ import pytest import gevent -import numpy import h5py +import numpy +import tango from bliss.common.measurement import ( SamplingCounter, IntegratingCounter, @@ -622,3 +623,29 @@ def test_tango_attr_counter(beacon, dummy_tango_server): assert counter.read() == 1.4 assert counter.unit == "mm" + + with pytest.raises(tango.DevFailed): + wrong_counter = beacon.get("wrong_counter") + + # get BLISS counters + tac_pos = beacon.get("tac_undu_position") + tac_vel = beacon.get("tac_undu_velocity") + + # test "no unit" + tac_acc = beacon.get("tac_undu_acceleration") + + with pytest.raises(tango.DevFailed): + tac_cracoucas = beacon.get("tac_undu_cracoucas") + + # get UNDULATOR object + u23a = beacon.get("u23a") + + assert u23a.position == 1.4 + assert u23a.position == tac_pos.read() + + assert u23a.velocity == tac_vel.read() + assert u23a.acceleration == tac_acc.read() + + # Test missing uri + with pytest.raises(KeyError): + no_uri_counter = beacon.get("no_uri_counter")