File: test_taurusbase.py

package info (click to toggle)
taurus 5.2.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 100,792 kB
  • sloc: python: 51,356; sh: 67; makefile: 12
file content (76 lines) | stat: -rw-r--r-- 2,420 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python

# ###########################################################################
#
# This file is part of Taurus
#
# http://taurus-scada.org
#
# Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
#
# Taurus is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Taurus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Taurus.  If not, see <http://www.gnu.org/licenses/>.
#
# ###########################################################################

"""Unit tests for taurusbase
"""


import pytest
from taurus.qt.qtgui.container import TaurusWidget

from taurus.test.pytest import check_taurus_deprecations

try:
    # The following are Tango-centric imports.
    from taurus.core.tango.test import nodb_dev  # noqa: F401

    _TANGO_MISSING = False
except Exception:
    _TANGO_MISSING = True


@pytest.mark.skipif(_TANGO_MISSING, reason="tango-dependent test")
@pytest.mark.parametrize(
    "model, expected",
    [
        ("/boolean_scalar", "True"),
        ("/short_scalar", "123 mm"),
        ("/double_scalar", "1.23 mm"),
        ("/state", "ON"),
        ("/float_scalar#", "-----"),
        ("/float_scalar#label", "float_scalar"),
        ("/double_scalar#rvalue.magnitude", "1.23"),
        # ("/float_scalar?configuration=label", "float_scalar"),
        ("eval:1+2", "3"),
        ("eval:1+2#label", "1+2"),
        ("eval:1+2#", "-----"),
    ],
)
@pytest.mark.forked
def test_display_value(qtbot, caplog, nodb_dev, model, expected):  # noqa: F811
    """Check the getDisplayValue method"""
    with check_taurus_deprecations(caplog):
        w = TaurusWidget()
        qtbot.addWidget(w)
        if model.startswith("/"):
            model = "{}{}".format(nodb_dev, model)
        with qtbot.waitSignal(w.modelChanged, timeout=3200):
            w.setModel(model)

        def _ok():
            """Check text"""
            assert w.getDisplayValue() == expected

        qtbot.waitUntil(_ok, timeout=3200)