diff --git a/setup.cfg b/setup.cfg index 6922aa224f5116f607274066b04b6963862e134e..aa5d48865bffe9973138c33c97e3fa07d902ad79 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,6 +10,7 @@ testpaths = tests addopts = --verbose --json-report --json-report-file=build/htmlcov/report.json + --cov-config=setup.cfg --cov-report term --cov-report html --cov-report xml:build/reports/code-coverage.xml diff --git a/tests/conftest.py b/tests/conftest.py index a034716a205a0fd9d0362ee8fd504d88a85a4ff2..87da31a373856fb5f6d1386c7c37e005b5af2c31 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -17,7 +17,7 @@ def device_properties(): return {} -@pytest.fixture(scope="class") +@pytest.fixture() def tango_context(device_test_config): """Return a Tango test context object, in which the device under test is running.""" component_manager_patch = device_test_config.pop("component_manager_patch", None) @@ -30,27 +30,29 @@ def tango_context(device_test_config): tango_context.stop() -def pytest_itemcollected(item): - """Make Tango-related tests run in forked mode.""" - if "tango_context" in item.fixturenames: - item.add_marker("forked") +@pytest.fixture() +def device_under_test(tango_context): + """ + Return a device proxy to the device under test. + :param tango_context: a Tango test context with the specified device + running + :type tango_context: :py:class:`tango.DeviceTestContext` -@pytest.fixture(scope="function") -def initialize_device(tango_context): + :return: a proxy to the device under test + :rtype: :py:class:`tango.DeviceProxy` """ - Re-initializes the device. + return tango_context.device - Parameters - ---------- - tango_context: tango.test_context.DeviceTestContext - Context to run a device without a database. - """ - yield tango_context.device.Init() + +def pytest_itemcollected(item): + """Make Tango-related tests run in forked mode.""" + if "device_under_test" in item.fixturenames: + item.add_marker("forked") @pytest.fixture(scope="function") -def tango_change_event_helper(tango_context): +def tango_change_event_helper(device_under_test): """ Return a helper for testing tango change events. @@ -67,17 +69,22 @@ def tango_change_event_helper(tango_context): # Check that we can't turn off a device that isn't on with pytest.raises(DevFailed): - tango_context.device.Off() + device_under_test.Off() state_callback.assert_not_called() # Now turn it on and check that we can turn it off - tango_context.device.On() + device_under_test.On() state_callback.assert_call(DevState.ON) # Or we can test a sequence of events - tango_context.device.Off() - tango_context.device.On() + device_under_test.Off() + device_under_test.On() state_callback.assert_calls([DevState.OFF, DevState.ON]) + + :param device_under_test: a :py:class:`tango.DeviceProxy` to the + device under test, running in a + :py:class:`tango.test_context.DeviceTestContext`. + :type device_under_test: :py:class:`tango.DeviceProxy` """ class _Callback: @@ -119,14 +126,14 @@ def tango_change_event_helper(tango_context): # Subscription will result in an immediate # synchronous callback with the current value, # so keep this as the last step in __init__. - self._id = tango_context.device.subscribe_event( + self._id = device_under_test.subscribe_event( attribute_name, EventType.CHANGE_EVENT, self ) def __del__(self): """Unsubscribe from events before object is destroyed.""" if hasattr(self, "_id"): - tango_context.device.unsubscribe_event(self._id) + device_under_test.unsubscribe_event(self._id) def __call__(self, event_data): """ diff --git a/tests/test_alarm_handler_device.py b/tests/test_alarm_handler_device.py index 5e405db3048bc20c60ebae1895c4c961c629f3e2..3e6c5bf6100220992bce6e881a34af2304a89582 100644 --- a/tests/test_alarm_handler_device.py +++ b/tests/test_alarm_handler_device.py @@ -25,7 +25,6 @@ from ska_tango_base.control_model import AdminMode # PROTECTED REGION END # // SKAAlarmHandler.test_SKAAlarmHandler_decorators -@pytest.mark.usefixtures("tango_context", "initialize_device") class TestSKAAlarmHandler(object): """Test class for tests of the SKAAlarmHander device class.""" @@ -47,137 +46,137 @@ class TestSKAAlarmHandler(object): } @pytest.mark.skip("Not implemented") - def test_properties(self, tango_context): + def test_properties(self, device_under_test): """Test the device properties.""" # PROTECTED REGION ID(SKAAlarmHandler.test_properties) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_properties # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmRule_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmRule_decorators - def test_GetAlarmRule(self, tango_context): + def test_GetAlarmRule(self, device_under_test): """Test for GetAlarmRule.""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmRule) ENABLED START # - assert tango_context.device.GetAlarmRule("") == "" + assert device_under_test.GetAlarmRule("") == "" # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmRule # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmData_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmData_decorators - def test_GetAlarmData(self, tango_context): + def test_GetAlarmData(self, device_under_test): """Test for GetAlarmData.""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmData) ENABLED START # - assert tango_context.device.GetAlarmData("") == "" + assert device_under_test.GetAlarmData("") == "" # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmData # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmAdditionalInfo_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmAdditionalInfo_decorators - def test_GetAlarmAdditionalInfo(self, tango_context): + def test_GetAlarmAdditionalInfo(self, device_under_test): """Test for GetAlarmAdditionalInfo.""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmAdditionalInfo) ENABLED START # - assert tango_context.device.GetAlarmAdditionalInfo("") == "" + assert device_under_test.GetAlarmAdditionalInfo("") == "" # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmAdditionalInfo # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmStats_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmStats_decorators - def test_GetAlarmStats(self, tango_context): + def test_GetAlarmStats(self, device_under_test): """Test for GetAlarmStats.""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlarmStats) ENABLED START # - assert tango_context.device.GetAlarmStats() == "" + assert device_under_test.GetAlarmStats() == "" # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlarmStats # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlertStats_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlertStats_decorators - def test_GetAlertStats(self, tango_context): + def test_GetAlertStats(self, device_under_test): """Test for GetAlertStats.""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetAlertStats) ENABLED START # - assert tango_context.device.GetAlertStats() == "" + assert device_under_test.GetAlertStats() == "" # PROTECTED REGION END # // SKAAlarmHandler.test_GetAlertStats # PROTECTED REGION ID(SKAAlarmHandler.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_GetVersionInfo_decorators - def test_GetVersionInfo(self, tango_context): + def test_GetVersionInfo(self, device_under_test): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{tango_context.device.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " "A set of generic base devices for SKA Telescope." ) - versionInfo = tango_context.device.GetVersionInfo() + versionInfo = device_under_test.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None # PROTECTED REGION END # // SKAAlarmHandler.test_GetVersionInfo # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrAlerts_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrAlerts_decorators - def test_statsNrAlerts(self, tango_context): + def test_statsNrAlerts(self, device_under_test): """Test for statsNrAlerts.""" # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrAlerts) ENABLED START # - assert tango_context.device.statsNrAlerts == 0 + assert device_under_test.statsNrAlerts == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrAlerts # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrAlarms_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrAlarms_decorators - def test_statsNrAlarms(self, tango_context): + def test_statsNrAlarms(self, device_under_test): """Test for statsNrAlarms.""" # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrAlarms) ENABLED START # - assert tango_context.device.statsNrAlarms == 0 + assert device_under_test.statsNrAlarms == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrAlarms # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrNewAlarms_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrNewAlarms_decorators - def test_statsNrNewAlarms(self, tango_context): + def test_statsNrNewAlarms(self, device_under_test): """Test for statsNrNewAlarms.""" # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrNewAlarms) ENABLED START # - assert tango_context.device.statsNrNewAlarms == 0 + assert device_under_test.statsNrNewAlarms == 0 # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrNewAlarms # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrUnackAlarms_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrUnackAlarms_decorators - def test_statsNrUnackAlarms(self, tango_context): + def test_statsNrUnackAlarms(self, device_under_test): """Test for statsNrUnackAlarms.""" # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrUnackAlarms) ENABLED START # - assert tango_context.device.statsNrUnackAlarms == 0.0 + assert device_under_test.statsNrUnackAlarms == 0.0 # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrUnackAlarms # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrRtnAlarms_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrRtnAlarms_decorators - def test_statsNrRtnAlarms(self, tango_context): + def test_statsNrRtnAlarms(self, device_under_test): """Test for statsNrRtnAlarms.""" # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrRtnAlarms) ENABLED START # - assert tango_context.device.statsNrRtnAlarms == 0.0 + assert device_under_test.statsNrRtnAlarms == 0.0 # PROTECTED REGION END # // SKAAlarmHandler.test_statsNrRtnAlarms # PROTECTED REGION ID(SKAAlarmHandler.test_buildState_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_buildState_decorators - def test_buildState(self, tango_context): + def test_buildState(self, device_under_test): """Test for buildState.""" # PROTECTED REGION ID(SKAAlarmHandler.test_buildState) ENABLED START # buildPattern = re.compile( r"ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " r"A set of generic base devices for SKA Telescope" ) - assert (re.match(buildPattern, tango_context.device.buildState)) is not None + assert (re.match(buildPattern, device_under_test.buildState)) is not None # PROTECTED REGION END # // SKAAlarmHandler.test_buildState # PROTECTED REGION ID(SKAAlarmHandler.test_versionId_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_versionId_decorators - def test_versionId(self, tango_context): + def test_versionId(self, device_under_test): """Test for versionId.""" # PROTECTED REGION ID(SKAAlarmHandler.test_versionId) ENABLED START # versionIdPattern = re.compile(r"[0-9]+.[0-9]+.[0-9]+") - assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None + assert (re.match(versionIdPattern, device_under_test.versionId)) is not None # PROTECTED REGION END # // SKAAlarmHandler.test_versionId # PROTECTED REGION ID(SKAAlarmHandler.test_activeAlerts_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_activeAlerts_decorators - def test_activeAlerts(self, tango_context): + def test_activeAlerts(self, device_under_test): """Test for activeAlerts.""" # PROTECTED REGION ID(SKAAlarmHandler.test_activeAlerts) ENABLED START # - assert tango_context.device.activeAlerts == ("",) + assert device_under_test.activeAlerts == ("",) # PROTECTED REGION END # // SKAAlarmHandler.test_activeAlerts # PROTECTED REGION ID(SKAAlarmHandler.test_activeAlarms_decorators) ENABLED START # # PROTECTED REGION END # // SKAAlarmHandler.test_activeAlarms_decorators - def test_activeAlarms(self, tango_context): + def test_activeAlarms(self, device_under_test): """Test for activeAlarms.""" # PROTECTED REGION ID(SKAAlarmHandler.test_activeAlarms) ENABLED START # - assert tango_context.device.activeAlarms == ("",) + assert device_under_test.activeAlarms == ("",) # PROTECTED REGION END # // SKAAlarmHandler.test_activeAlarms diff --git a/tests/test_base_device.py b/tests/test_base_device.py index 2f1847ef3dec516b02558ed004b6e69634af76d2..c16219c5d85c3f9b6da50d1b8ea3b0696b4cc931 100644 --- a/tests/test_base_device.py +++ b/tests/test_base_device.py @@ -404,14 +404,15 @@ class TestSKABaseDevice(object): } @pytest.mark.skip("Not implemented") - def test_properties(self, tango_context): + def test_properties(self, device_under_test): """Test device properties.""" # PROTECTED REGION ID(SKABaseDevice.test_properties) ENABLED START # """ Test device properties. - :param tango_context: Object - Tango device object + :param device_under_test: a DeviceProxy to the device under + test, running in a tango.DeviceTestContext + :type device_under_test: :py:class:`tango.DeviceProxy` :return: None """ @@ -420,45 +421,45 @@ class TestSKABaseDevice(object): # PROTECTED REGION ID(SKABaseDevice.test_State_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_State_decorators - def test_State(self, tango_context): + def test_State(self, device_under_test): """Test for State.""" # PROTECTED REGION ID(SKABaseDevice.test_State) ENABLED START # - assert tango_context.device.State() == DevState.OFF + assert device_under_test.State() == DevState.OFF # PROTECTED REGION END # // SKABaseDevice.test_State # PROTECTED REGION ID(SKABaseDevice.test_Status_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_Status_decorators - def test_Status(self, tango_context): + def test_Status(self, device_under_test): """Test for Status.""" # PROTECTED REGION ID(SKABaseDevice.test_Status) ENABLED START # - assert tango_context.device.Status() == "The device is in OFF state." + assert device_under_test.Status() == "The device is in OFF state." # PROTECTED REGION END # // SKABaseDevice.test_Status # PROTECTED REGION ID(SKABaseDevice.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_GetVersionInfo_decorators - def test_GetVersionInfo(self, tango_context): + def test_GetVersionInfo(self, device_under_test): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKABaseDevice.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{tango_context.device.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " "A set of generic base devices for SKA Telescope." ) - versionInfo = tango_context.device.GetVersionInfo() + versionInfo = device_under_test.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None # PROTECTED REGION END # // SKABaseDevice.test_GetVersionInfo # PROTECTED REGION ID(SKABaseDevice.test_Reset_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_Reset_decorators - def test_Reset(self, tango_context): + def test_Reset(self, device_under_test): """Test for Reset.""" # PROTECTED REGION ID(SKABaseDevice.test_Reset) ENABLED START # # The main test of this command is # TestSKABaseDevice_commands::test_ResetCommand with pytest.raises(DevFailed): - tango_context.device.Reset() + device_under_test.Reset() # PROTECTED REGION END # // SKABaseDevice.test_Reset - def test_On(self, tango_context, tango_change_event_helper): + def test_On(self, device_under_test, tango_change_event_helper): """Test for On command.""" state_callback = tango_change_event_helper.subscribe("state") status_callback = tango_change_event_helper.subscribe("status") @@ -466,25 +467,25 @@ class TestSKABaseDevice(object): status_callback.assert_call("The device is in OFF state.") # Check that we can turn a freshly initialised device on - tango_context.device.On() + device_under_test.On() state_callback.assert_call(DevState.ON) status_callback.assert_call("The device is in ON state.") # Check that we can turn it on when it is already on - tango_context.device.On() + device_under_test.On() state_callback.assert_not_called() status_callback.assert_not_called() - def test_Standby(self, tango_context): + def test_Standby(self, device_under_test): """Test for Standby command.""" # Check that we can put it on standby - tango_context.device.Standby() - assert tango_context.device.state() == DevState.STANDBY + device_under_test.Standby() + assert device_under_test.state() == DevState.STANDBY # Check that we can put it on standby when it is already on standby - tango_context.device.Standby() + device_under_test.Standby() - def test_Off(self, tango_context, tango_change_event_helper): + def test_Off(self, device_under_test, tango_change_event_helper): """Test for Off command.""" state_callback = tango_change_event_helper.subscribe("state") status_callback = tango_change_event_helper.subscribe("status") @@ -492,54 +493,54 @@ class TestSKABaseDevice(object): status_callback.assert_call("The device is in OFF state.") # Check that we can turn off a device that is already off - tango_context.device.Off() + device_under_test.Off() state_callback.assert_not_called() status_callback.assert_not_called() # PROTECTED REGION ID(SKABaseDevice.test_buildState_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_buildState_decorators - def test_buildState(self, tango_context): + def test_buildState(self, device_under_test): """Test for buildState.""" # PROTECTED REGION ID(SKABaseDevice.test_buildState) ENABLED START # buildPattern = re.compile( r"ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " r"A set of generic base devices for SKA Telescope" ) - assert (re.match(buildPattern, tango_context.device.buildState)) is not None + assert (re.match(buildPattern, device_under_test.buildState)) is not None # PROTECTED REGION END # // SKABaseDevice.test_buildState # PROTECTED REGION ID(SKABaseDevice.test_versionId_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_versionId_decorators - def test_versionId(self, tango_context): + def test_versionId(self, device_under_test): """Test for versionId.""" # PROTECTED REGION ID(SKABaseDevice.test_versionId) ENABLED START # versionIdPattern = re.compile(r"[0-9]+.[0-9]+.[0-9]+") - assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None + assert (re.match(versionIdPattern, device_under_test.versionId)) is not None # PROTECTED REGION END # // SKABaseDevice.test_versionId # PROTECTED REGION ID(SKABaseDevice.test_loggingLevel_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_loggingLevel_decorators - def test_loggingLevel(self, tango_context): + def test_loggingLevel(self, device_under_test): """Test for loggingLevel.""" # PROTECTED REGION ID(SKABaseDevice.test_loggingLevel) ENABLED START # - assert tango_context.device.loggingLevel == LoggingLevel.INFO + assert device_under_test.loggingLevel == LoggingLevel.INFO for level in LoggingLevel: - tango_context.device.loggingLevel = level - assert tango_context.device.loggingLevel == level - assert tango_context.device.get_logging_level() == level + device_under_test.loggingLevel = level + assert device_under_test.loggingLevel == level + assert device_under_test.get_logging_level() == level with pytest.raises(DevFailed): - tango_context.device.loggingLevel = LoggingLevel.FATAL + 100 + device_under_test.loggingLevel = LoggingLevel.FATAL + 100 # PROTECTED REGION END # // SKABaseDevice.test_loggingLevel # PROTECTED REGION ID(SKABaseDevice.test_loggingTargets_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_loggingTargets_decorators - def test_loggingTargets(self, tango_context): + def test_loggingTargets(self, device_under_test): """Test for loggingTargets.""" # PROTECTED REGION ID(SKABaseDevice.test_loggingTargets) ENABLED START # # tango logging target must be enabled by default - assert tango_context.device.loggingTargets == ("tango::logger",) + assert device_under_test.loggingTargets == ("tango::logger",) with mock.patch( "ska_tango_base.base.base_device.LoggingUtils.create_logging_handler" @@ -554,18 +555,18 @@ class TestSKABaseDevice(object): mocked_creator.side_effect = null_creator # test console target - tango_context.device.loggingTargets = ["console::cout"] - assert tango_context.device.loggingTargets == ("console::cout",) + device_under_test.loggingTargets = ["console::cout"] + assert device_under_test.loggingTargets == ("console::cout",) mocked_creator.assert_called_once_with("console::cout", mock.ANY) # test adding file and syslog targets (already have console) mocked_creator.reset_mock() - tango_context.device.loggingTargets = [ + device_under_test.loggingTargets = [ "console::cout", "file::/tmp/dummy", "syslog::udp://localhost:514", ] - assert tango_context.device.loggingTargets == ( + assert device_under_test.loggingTargets == ( "console::cout", "file::/tmp/dummy", "syslog::udp://localhost:514", @@ -582,109 +583,109 @@ class TestSKABaseDevice(object): # test adding tango logging again, now that mock is active # (it wasn't active when device was initialised) mocked_creator.reset_mock() - tango_context.device.loggingTargets = ["tango::logger"] - assert tango_context.device.loggingTargets == ("tango::logger",) + device_under_test.loggingTargets = ["tango::logger"] + assert device_under_test.loggingTargets == ("tango::logger",) mocked_creator.assert_called_once_with("tango::logger", mock.ANY) # test clearing all targets (note: PyTango returns None for empty spectrum attribute) - tango_context.device.loggingTargets = [] - assert tango_context.device.loggingTargets is None + device_under_test.loggingTargets = [] + assert device_under_test.loggingTargets is None mocked_creator.reset_mock() with pytest.raises(DevFailed): - tango_context.device.loggingTargets = ["invalid::type"] + device_under_test.loggingTargets = ["invalid::type"] mocked_creator.assert_not_called() # PROTECTED REGION END # // SKABaseDevice.test_loggingTargets # PROTECTED REGION ID(SKABaseDevice.test_healthState_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_healthState_decorators - def test_healthState(self, tango_context): + def test_healthState(self, device_under_test): """Test for healthState.""" # PROTECTED REGION ID(SKABaseDevice.test_healthState) ENABLED START # - assert tango_context.device.healthState == HealthState.OK + assert device_under_test.healthState == HealthState.OK # PROTECTED REGION END # // SKABaseDevice.test_healthState # PROTECTED REGION ID(SKABaseDevice.test_adminMode_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_adminMode_decorators - def test_adminMode(self, tango_context, tango_change_event_helper): + def test_adminMode(self, device_under_test, tango_change_event_helper): """Test for adminMode.""" # PROTECTED REGION ID(SKABaseDevice.test_adminMode) ENABLED START # - assert tango_context.device.adminMode == AdminMode.ONLINE - assert tango_context.device.state() == DevState.OFF + assert device_under_test.adminMode == AdminMode.ONLINE + assert device_under_test.state() == DevState.OFF admin_mode_callback = tango_change_event_helper.subscribe("adminMode") admin_mode_callback.assert_call(AdminMode.ONLINE) - tango_context.device.adminMode = AdminMode.OFFLINE - assert tango_context.device.adminMode == AdminMode.OFFLINE + device_under_test.adminMode = AdminMode.OFFLINE + assert device_under_test.adminMode == AdminMode.OFFLINE admin_mode_callback.assert_call(AdminMode.OFFLINE) - assert tango_context.device.state() == DevState.DISABLE + assert device_under_test.state() == DevState.DISABLE - tango_context.device.adminMode = AdminMode.MAINTENANCE - assert tango_context.device.adminMode == AdminMode.MAINTENANCE + device_under_test.adminMode = AdminMode.MAINTENANCE + assert device_under_test.adminMode == AdminMode.MAINTENANCE admin_mode_callback.assert_call(AdminMode.MAINTENANCE) - assert tango_context.device.state() == DevState.OFF + assert device_under_test.state() == DevState.OFF - tango_context.device.adminMode = AdminMode.ONLINE - assert tango_context.device.adminMode == AdminMode.ONLINE + device_under_test.adminMode = AdminMode.ONLINE + assert device_under_test.adminMode == AdminMode.ONLINE admin_mode_callback.assert_call(AdminMode.ONLINE) - assert tango_context.device.state() == DevState.OFF + assert device_under_test.state() == DevState.OFF # PROTECTED REGION END # // SKABaseDevice.test_adminMode # PROTECTED REGION ID(SKABaseDevice.test_controlMode_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_controlMode_decorators - def test_controlMode(self, tango_context): + def test_controlMode(self, device_under_test): """Test for controlMode.""" # PROTECTED REGION ID(SKABaseDevice.test_controlMode) ENABLED START # - assert tango_context.device.controlMode == ControlMode.REMOTE + assert device_under_test.controlMode == ControlMode.REMOTE # PROTECTED REGION END # // SKABaseDevice.test_controlMode # PROTECTED REGION ID(SKABaseDevice.test_simulationMode_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_simulationMode_decorators - def test_simulationMode(self, tango_context): + def test_simulationMode(self, device_under_test): """Test for simulationMode.""" # PROTECTED REGION ID(SKABaseDevice.test_simulationMode) ENABLED START # - assert tango_context.device.simulationMode == SimulationMode.FALSE + assert device_under_test.simulationMode == SimulationMode.FALSE # PROTECTED REGION END # // SKABaseDevice.test_simulationMode # PROTECTED REGION ID(SKABaseDevice.test_testMode_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_testMode_decorators - def test_testMode(self, tango_context): + def test_testMode(self, device_under_test): """Test for testMode.""" # PROTECTED REGION ID(SKABaseDevice.test_testMode) ENABLED START # - assert tango_context.device.testMode == TestMode.NONE + assert device_under_test.testMode == TestMode.NONE # PROTECTED REGION END # // SKABaseDevice.test_testMode - def test_debugger_not_listening_by_default(self, tango_context): + def test_debugger_not_listening_by_default(self, device_under_test): """Test that DebugDevice is not active until enabled.""" assert not SKABaseDevice._global_debugger_listening with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: with pytest.raises(ConnectionRefusedError): s.connect(("localhost", _DEBUGGER_PORT)) - def test_DebugDevice_starts_listening_on_default_port(self, tango_context): + def test_DebugDevice_starts_listening_on_default_port(self, device_under_test): """Test that enabling DebugDevice makes it listen on its default port.""" - port = tango_context.device.DebugDevice() + port = device_under_test.DebugDevice() assert port == _DEBUGGER_PORT assert SKABaseDevice._global_debugger_listening with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect(("localhost", _DEBUGGER_PORT)) - assert tango_context.device.state + assert device_under_test.state @pytest.mark.usefixtures("patch_debugger_to_start_on_ephemeral_port") - def test_DebugDevice_twice_does_not_raise(self, tango_context): + def test_DebugDevice_twice_does_not_raise(self, device_under_test): """Test that it is safe to enable the DebugDevice when it is already enabled.""" - tango_context.device.DebugDevice() - tango_context.device.DebugDevice() + device_under_test.DebugDevice() + device_under_test.DebugDevice() assert SKABaseDevice._global_debugger_listening @pytest.mark.usefixtures("patch_debugger_to_start_on_ephemeral_port") - def test_DebugDevice_does_not_break_a_command(self, tango_context): + def test_DebugDevice_does_not_break_a_command(self, device_under_test): """Test that enabling the DebugDevice feature does not break device commands.""" - tango_context.device.DebugDevice() - assert tango_context.device.State() == DevState.OFF - tango_context.device.On() - assert tango_context.device.State() == DevState.ON + device_under_test.DebugDevice() + assert device_under_test.State() == DevState.OFF + device_under_test.On() + assert device_under_test.State() == DevState.ON @pytest.fixture() diff --git a/tests/test_capability_device.py b/tests/test_capability_device.py index ee824fafab6ebd0dd2f1b85ad21b1c0eb0358165..52ec1c241ad3517cac8c20354ea9d266bc7aa5b1 100644 --- a/tests/test_capability_device.py +++ b/tests/test_capability_device.py @@ -19,7 +19,6 @@ from ska_tango_base.control_model import AdminMode # PROTECTED REGION END # // SKACapability.test_additional_imports # Device test case # PROTECTED REGION ID(SKACapability.test_SKACapability_decorators) ENABLED START # -@pytest.mark.usefixtures("tango_context", "initialize_device") # PROTECTED REGION END # // SKACapability.test_SKACapability_decorators class TestSKACapability(object): """Test case for packet generation.""" @@ -42,83 +41,83 @@ class TestSKACapability(object): } @pytest.mark.skip("Not implemented") - def test_properties(self, tango_context): + def test_properties(self, device_under_test): """Test device properties.""" # PROTECTED REGION ID(SKACapability.test_properties) ENABLED START # # PROTECTED REGION END # // SKACapability.test_properties - def test_ConfigureInstances(self, tango_context): + def test_ConfigureInstances(self, device_under_test): """Test for ConfigureInstances.""" # PROTECTED REGION ID(SKACapability.test_ConfigureInstances) ENABLED START # - tango_context.device.ConfigureInstances(1) - assert tango_context.device.configuredInstances == 1 + device_under_test.ConfigureInstances(1) + assert device_under_test.configuredInstances == 1 # PROTECTED REGION END # // SKACapability.test_ConfigureInstances # # PROTECTED REGION ID(SKACapability.test_Reset_decorators) ENABLED START # # # PROTECTED REGION END # // SKACapability.test_Reset_decorators - # def test_Reset(self, tango_context): + # def test_Reset(self, device_under_test): # """Test for Reset""" # # PROTECTED REGION ID(SKACapability.test_Reset) ENABLED START # - # assert tango_context.device.Reset() == None + # assert device_under_test.Reset() == None # # PROTECTED REGION END # // SKACapability.test_Reset # PROTECTED REGION ID(SKACapability.test_activationTime_decorators) ENABLED START # # PROTECTED REGION END # // SKACapability.test_activationTime_decorators - def test_activationTime(self, tango_context): + def test_activationTime(self, device_under_test): """Test for activationTime.""" # PROTECTED REGION ID(SKACapability.test_activationTime) ENABLED START # - assert tango_context.device.activationTime == 0.0 + assert device_under_test.activationTime == 0.0 # PROTECTED REGION END # // SKACapability.test_activationTime # PROTECTED REGION ID(SKACapability.test_configurationProgress_decorators) ENABLED START # # PROTECTED REGION END # // SKACapability.test_configurationProgress_decorators - # def test_configurationProgress(self, tango_context): + # def test_configurationProgress(self, device_under_test): # """Test for configurationProgress""" # # PROTECTED REGION ID(SKACapability.test_configurationProgress) ENABLED START # - # assert tango_context.device.configurationProgress == 0 + # assert device_under_test.configurationProgress == 0 # # PROTECTED REGION END # // SKACapability.test_configurationProgress # PROTECTED REGION ID(SKACapability.test_configurationDelayExpected_decorators) ENABLED START # # PROTECTED REGION END # // SKACapability.test_configurationDelayExpected_decorators - # def test_configurationDelayExpected(self, tango_context): + # def test_configurationDelayExpected(self, device_under_test): # """Test for configurationDelayExpected""" # # PROTECTED REGION ID(SKACapability.test_configurationDelayExpected) ENABLED START # - # assert tango_context.device.configurationDelayExpected == 0 + # assert device_under_test.configurationDelayExpected == 0 # # PROTECTED REGION END # // SKACapability.test_configurationDelayExpected # PROTECTED REGION ID(SKACapability.test_buildState_decorators) ENABLED START # # PROTECTED REGION END # // SKACapability.test_buildState_decorators - def test_buildState(self, tango_context): + def test_buildState(self, device_under_test): """Test for buildState.""" # PROTECTED REGION ID(SKACapability.test_buildState) ENABLED START # buildPattern = re.compile( r"ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " r"A set of generic base devices for SKA Telescope" ) - assert (re.match(buildPattern, tango_context.device.buildState)) is not None + assert (re.match(buildPattern, device_under_test.buildState)) is not None # PROTECTED REGION END # // SKACapability.test_buildState # PROTECTED REGION ID(SKACapability.test_versionId_decorators) ENABLED START # # PROTECTED REGION END # // SKACapability.test_versionId_decorators - def test_versionId(self, tango_context): + def test_versionId(self, device_under_test): """Test for versionId.""" # PROTECTED REGION ID(SKACapability.test_versionId) ENABLED START # versionIdPattern = re.compile(r"[0-9]+.[0-9]+.[0-9]+") - assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None + assert (re.match(versionIdPattern, device_under_test.versionId)) is not None # PROTECTED REGION END # // SKACapability.test_versionId # PROTECTED REGION ID(SKACapability.test_configuredInstances_decorators) ENABLED START # # PROTECTED REGION END # // SKACapability.test_configuredInstances_decorators - def test_configuredInstances(self, tango_context): + def test_configuredInstances(self, device_under_test): """Test for configuredInstances.""" # PROTECTED REGION ID(SKACapability.test_configuredInstances) ENABLED START # - assert tango_context.device.configuredInstances == 0 + assert device_under_test.configuredInstances == 0 # PROTECTED REGION END # // SKACapability.test_configuredInstances # PROTECTED REGION ID(SKACapability.test_usedComponents_decorators) ENABLED START # # PROTECTED REGION END # // SKACapability.test_usedComponents_decorators - def test_usedComponents(self, tango_context): + def test_usedComponents(self, device_under_test): """Test for usedComponents.""" # PROTECTED REGION ID(SKACapability.test_usedComponents) ENABLED START # - assert tango_context.device.usedComponents == ("",) + assert device_under_test.usedComponents == ("",) # PROTECTED REGION END # // SKACapability.test_usedComponents diff --git a/tests/test_controller_device.py b/tests/test_controller_device.py index 40e366b7a7f99ef55de090c0339b4fc6d6b55313..6999b808dc440366d41691cce6f5290a79845fcb 100644 --- a/tests/test_controller_device.py +++ b/tests/test_controller_device.py @@ -27,7 +27,6 @@ from ska_tango_base.control_model import ( # PROTECTED REGION ID(SKAController.test_SKAController_decorators) ENABLED START # -@pytest.mark.usefixtures("tango_context") # PROTECTED REGION END # // SKAController.test_SKAController_decorators class TestSKAController(object): """Test class for tests of the SKAController device class.""" @@ -68,7 +67,7 @@ class TestSKAController(object): } @pytest.mark.skip("Not implemented") - def test_properties(self, tango_context): + def test_properties(self, device_under_test): """Test device properties.""" # PROTECTED REGION ID(SKAController.test_properties) ENABLED START # # PROTECTED REGION END # // SKAController.test_properties @@ -76,155 +75,155 @@ class TestSKAController(object): # PROTECTED REGION ID(SKAController.test_State_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_State_decorators - def test_State(self, tango_context): + def test_State(self, device_under_test): """Test for State.""" # PROTECTED REGION ID(SKAController.test_State) ENABLED START # - assert tango_context.device.State() == DevState.OFF + assert device_under_test.State() == DevState.OFF # PROTECTED REGION END # // SKAController.test_State # PROTECTED REGION ID(SKAController.test_Status_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_Status_decorators - def test_Status(self, tango_context): + def test_Status(self, device_under_test): """Test for Status.""" # PROTECTED REGION ID(SKAController.test_Status) ENABLED START # - assert tango_context.device.Status() == "The device is in OFF state." + assert device_under_test.Status() == "The device is in OFF state." # PROTECTED REGION END # // SKAController.test_Status # PROTECTED REGION ID(SKAController.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_GetVersionInfo_decorators - def test_GetVersionInfo(self, tango_context): + def test_GetVersionInfo(self, device_under_test): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKAController.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{tango_context.device.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " "A set of generic base devices for SKA Telescope." ) - versionInfo = tango_context.device.GetVersionInfo() + versionInfo = device_under_test.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None # PROTECTED REGION END # // SKAController.test_GetVersionInfo # PROTECTED REGION ID(SKAController.test_isCapabilityAchievable_failure_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_isCapabilityAchievable_failure_decorators - def test_isCapabilityAchievable_failure(self, tango_context): + def test_isCapabilityAchievable_failure(self, device_under_test): """Test for isCapabilityAchievable to test failure condition.""" # PROTECTED REGION ID(SKAController.test_isCapabilityAchievable_failure) ENABLED START # - assert tango_context.device.isCapabilityAchievable([[2], ["BAND1"]]) is False + assert device_under_test.isCapabilityAchievable([[2], ["BAND1"]]) is False # PROTECTED REGION END # // SKAController.test_isCapabilityAchievable_failure # PROTECTED REGION ID(SKAController.test_isCapabilityAchievable_success_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_isCapabilityAchievable_success_decorators - def test_isCapabilityAchievable_success(self, tango_context): + def test_isCapabilityAchievable_success(self, device_under_test): """Test for isCapabilityAchievable to test success condition.""" # PROTECTED REGION ID(SKAController.test_isCapabilityAchievable_success) ENABLED START # - assert tango_context.device.isCapabilityAchievable([[1], ["BAND1"]]) is True + assert device_under_test.isCapabilityAchievable([[1], ["BAND1"]]) is True # PROTECTED REGION END # // SKAController.test_isCapabilityAchievable_success # PROTECTED REGION ID(SKAController.test_elementLoggerAddress_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_elementLoggerAddress_decorators - def test_elementLoggerAddress(self, tango_context): + def test_elementLoggerAddress(self, device_under_test): """Test for elementLoggerAddress.""" # PROTECTED REGION ID(SKAController.test_elementLoggerAddress) ENABLED START # - assert tango_context.device.elementLoggerAddress == "" + assert device_under_test.elementLoggerAddress == "" # PROTECTED REGION END # // SKAController.test_elementLoggerAddress # PROTECTED REGION ID(SKAController.test_elementAlarmAddress_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_elementAlarmAddress_decorators - def test_elementAlarmAddress(self, tango_context): + def test_elementAlarmAddress(self, device_under_test): """Test for elementAlarmAddress.""" # PROTECTED REGION ID(SKAController.test_elementAlarmAddress) ENABLED START # - assert tango_context.device.elementAlarmAddress == "" + assert device_under_test.elementAlarmAddress == "" # PROTECTED REGION END # // SKAController.test_elementAlarmAddress # PROTECTED REGION ID(SKAController.test_elementTelStateAddress_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_elementTelStateAddress_decorators - def test_elementTelStateAddress(self, tango_context): + def test_elementTelStateAddress(self, device_under_test): """Test for elementTelStateAddress.""" # PROTECTED REGION ID(SKAController.test_elementTelStateAddress) ENABLED START # - assert tango_context.device.elementTelStateAddress == "" + assert device_under_test.elementTelStateAddress == "" # PROTECTED REGION END # // SKAController.test_elementTelStateAddress # PROTECTED REGION ID(SKAController.test_elementDatabaseAddress_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_elementDatabaseAddress_decorators - def test_elementDatabaseAddress(self, tango_context): + def test_elementDatabaseAddress(self, device_under_test): """Test for elementDatabaseAddress.""" # PROTECTED REGION ID(SKAController.test_elementDatabaseAddress) ENABLED START # - assert tango_context.device.elementDatabaseAddress == "" + assert device_under_test.elementDatabaseAddress == "" # PROTECTED REGION END # // SKAController.test_elementDatabaseAddress # PROTECTED REGION ID(SKAController.test_buildState_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_buildState_decorators - def test_buildState(self, tango_context): + def test_buildState(self, device_under_test): """Test for buildState.""" # PROTECTED REGION ID(SKAController.test_buildState) ENABLED START # buildPattern = re.compile( r"ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " r"A set of generic base devices for SKA Telescope" ) - assert (re.match(buildPattern, tango_context.device.buildState)) is not None + assert (re.match(buildPattern, device_under_test.buildState)) is not None # PROTECTED REGION END # // SKAController.test_buildState # PROTECTED REGION ID(SKAController.test_versionId_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_versionId_decorators - def test_versionId(self, tango_context): + def test_versionId(self, device_under_test): """Test for versionId.""" # PROTECTED REGION ID(SKAController.test_versionId) ENABLED START # versionIdPattern = re.compile(r"[0-9]+.[0-9]+.[0-9]+") - assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None + assert (re.match(versionIdPattern, device_under_test.versionId)) is not None # PROTECTED REGION END # // SKAController.test_versionId # PROTECTED REGION ID(SKAController.test_healthState_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_healthState_decorators - def test_healthState(self, tango_context): + def test_healthState(self, device_under_test): """Test for healthState.""" # PROTECTED REGION ID(SKAController.test_healthState) ENABLED START # - assert tango_context.device.healthState == HealthState.OK + assert device_under_test.healthState == HealthState.OK # PROTECTED REGION END # // SKAController.test_healthState # PROTECTED REGION ID(SKAController.test_adminMode_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_adminMode_decorators - def test_adminMode(self, tango_context): + def test_adminMode(self, device_under_test): """Test for adminMode.""" # PROTECTED REGION ID(SKAController.test_adminMode) ENABLED START # - assert tango_context.device.adminMode == AdminMode.ONLINE + assert device_under_test.adminMode == AdminMode.ONLINE # PROTECTED REGION END # // SKAController.test_adminMode # PROTECTED REGION ID(SKAController.test_controlMode_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_controlMode_decorators - def test_controlMode(self, tango_context): + def test_controlMode(self, device_under_test): """Test for controlMode.""" # PROTECTED REGION ID(SKAController.test_controlMode) ENABLED START # - assert tango_context.device.controlMode == ControlMode.REMOTE + assert device_under_test.controlMode == ControlMode.REMOTE # PROTECTED REGION END # // SKAController.test_controlMode # PROTECTED REGION ID(SKAController.test_simulationMode_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_simulationMode_decorators - def test_simulationMode(self, tango_context): + def test_simulationMode(self, device_under_test): """Test for simulationMode.""" # PROTECTED REGION ID(SKAController.test_simulationMode) ENABLED START # - assert tango_context.device.simulationMode == SimulationMode.FALSE + assert device_under_test.simulationMode == SimulationMode.FALSE # PROTECTED REGION END # // SKAController.test_simulationMode # PROTECTED REGION ID(SKAController.test_testMode_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_testMode_decorators - def test_testMode(self, tango_context): + def test_testMode(self, device_under_test): """Test for testMode.""" # PROTECTED REGION ID(SKAController.test_testMode) ENABLED START # - assert tango_context.device.testMode == TestMode.NONE + assert device_under_test.testMode == TestMode.NONE # PROTECTED REGION END # // SKAController.test_testMode # PROTECTED REGION ID(SKAController.test_maxCapabilities_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_maxCapabilities_decorators - def test_maxCapabilities(self, tango_context): + def test_maxCapabilities(self, device_under_test): """Test for maxCapabilities.""" # PROTECTED REGION ID(SKAController.test_maxCapabilities) ENABLED START # - assert tango_context.device.maxCapabilities == ("BAND1:1", "BAND2:1") + assert device_under_test.maxCapabilities == ("BAND1:1", "BAND2:1") # PROTECTED REGION END # // SKAController.test_maxCapabilities # PROTECTED REGION ID(SKAController.test_availableCapabilities_decorators) ENABLED START # # PROTECTED REGION END # // SKAController.test_availableCapabilities_decorators - def test_availableCapabilities(self, tango_context): + def test_availableCapabilities(self, device_under_test): """Test for availableCapabilities.""" # PROTECTED REGION ID(SKAController.test_availableCapabilities) ENABLED START # - assert tango_context.device.availableCapabilities == ("BAND1:1", "BAND2:1") + assert device_under_test.availableCapabilities == ("BAND1:1", "BAND2:1") # PROTECTED REGION END # // SKAController.test_availableCapabilities diff --git a/tests/test_csp_controller.py b/tests/test_csp_controller.py index a4e12cfc63d40624069d8d9709fe350e7d7d34b9..55aab228a9f13d9eb3643510b3ebe68480f12ff6 100644 --- a/tests/test_csp_controller.py +++ b/tests/test_csp_controller.py @@ -60,7 +60,7 @@ class TestCspSubElementController(object): } @pytest.mark.skip("Not implemented") - def test_properties(self, tango_context): + def test_properties(self, device_under_test): """Test device properties.""" # PROTECTED REGION ID(CspSubelementController.test_properties) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_properties @@ -68,249 +68,249 @@ class TestCspSubElementController(object): # PROTECTED REGION ID(CspSubelementController.test_State_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_State_decorators - def test_State(self, tango_context): + def test_State(self, device_under_test): """Test for State.""" # PROTECTED REGION ID(CspSubelementController.test_State) ENABLED START # - assert tango_context.device.State() == DevState.OFF + assert device_under_test.State() == DevState.OFF # PROTECTED REGION END # // CspSubelementController.test_State # PROTECTED REGION ID(CspSubelementController.test_Status_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_Status_decorators - def test_Status(self, tango_context): + def test_Status(self, device_under_test): """Test for Status.""" # PROTECTED REGION ID(CspSubelementController.test_Status) ENABLED START # - assert tango_context.device.Status() == "The device is in OFF state." + assert device_under_test.Status() == "The device is in OFF state." # PROTECTED REGION END # // CspSubelementController.test_Status # PROTECTED REGION ID(CspSubelementController.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_GetVersionInfo_decorators - def test_GetVersionInfo(self, tango_context): + def test_GetVersionInfo(self, device_under_test): """Test for GetVersionInfo.""" # PROTECTED REGION ID(CspSubelementController.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{tango_context.device.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " "A set of generic base devices for SKA Telescope." ) - versionInfo = tango_context.device.GetVersionInfo() + versionInfo = device_under_test.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None # PROTECTED REGION END # // CspSubelementController.test_GetVersionInfo # PROTECTED REGION ID(CspSubelementController.test_configurationProgress_decorators) ENABLED START # - def test_buildState(self, tango_context): + def test_buildState(self, device_under_test): """Test for buildState.""" # PROTECTED REGION ID(CspSubelementController.test_buildState) ENABLED START # buildPattern = re.compile( r"ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " r"A set of generic base devices for SKA Telescope" ) - assert (re.match(buildPattern, tango_context.device.buildState)) is not None + assert (re.match(buildPattern, device_under_test.buildState)) is not None # PROTECTED REGION END # // CspSubelementController.test_buildState # PROTECTED REGION ID(CspSubelementController.test_versionId_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_versionId_decorators - def test_versionId(self, tango_context): + def test_versionId(self, device_under_test): """Test for versionId.""" # PROTECTED REGION ID(CspSubelementController.test_versionId) ENABLED START # versionIdPattern = re.compile(r"[0-9]+.[0-9]+.[0-9]+") - assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None + assert (re.match(versionIdPattern, device_under_test.versionId)) is not None # PROTECTED REGION END # // CspSubelementController.test_versionId # PROTECTED REGION ID(CspSubelementController.test_healthState_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_healthState_decorators - def test_healthState(self, tango_context): + def test_healthState(self, device_under_test): """Test for healthState.""" # PROTECTED REGION ID(CspSubelementController.test_healthState) ENABLED START # - assert tango_context.device.healthState == HealthState.OK + assert device_under_test.healthState == HealthState.OK # PROTECTED REGION END # // CspSubelementController.test_healthState # PROTECTED REGION ID(CspSubelementController.test_adminMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_adminMode_decorators - def test_adminMode(self, tango_context): + def test_adminMode(self, device_under_test): """Test for adminMode.""" # PROTECTED REGION ID(CspSubelementController.test_adminMode) ENABLED START # - assert tango_context.device.adminMode == AdminMode.ONLINE + assert device_under_test.adminMode == AdminMode.ONLINE # PROTECTED REGION END # // CspSubelementController.test_adminMode # PROTECTED REGION ID(CspSubelementController.test_controlMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_controlMode_decorators - def test_controlMode(self, tango_context): + def test_controlMode(self, device_under_test): """Test for controlMode.""" # PROTECTED REGION ID(CspSubelementController.test_controlMode) ENABLED START # - assert tango_context.device.controlMode == ControlMode.REMOTE + assert device_under_test.controlMode == ControlMode.REMOTE # PROTECTED REGION END # // CspSubelementController.test_controlMode # PROTECTED REGION ID(CspSubelementController.test_simulationMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_simulationMode_decorators - def test_simulationMode(self, tango_context): + def test_simulationMode(self, device_under_test): """Test for simulationMode.""" # PROTECTED REGION ID(CspSubelementController.test_simulationMode) ENABLED START # - assert tango_context.device.simulationMode == SimulationMode.FALSE + assert device_under_test.simulationMode == SimulationMode.FALSE # PROTECTED REGION END # // CspSubelementController.test_simulationMode # PROTECTED REGION ID(CspSubelementController.test_testMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_testMode_decorators - def test_testMode(self, tango_context): + def test_testMode(self, device_under_test): """Test for testMode.""" # PROTECTED REGION ID(CspSubelementController.test_testMode) ENABLED START # - assert tango_context.device.testMode == TestMode.NONE + assert device_under_test.testMode == TestMode.NONE # PROTECTED REGION END # // CspSubelementController.test_testMode # PROTECTED REGION ID(CspSubelementController.test_powerDelayStandbyOn_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_powerDelayStandbyOn_decorators - def test_powerDelayStandbyOn(self, tango_context, device_properties): + def test_powerDelayStandbyOn(self, device_under_test, device_properties): """Test for powerDelayStandbyOn.""" # PROTECTED REGION ID(CspSubelementController.test_testMode) ENABLED START # - assert tango_context.device.powerDelayStandbyOn == pytest.approx( + assert device_under_test.powerDelayStandbyOn == pytest.approx( float(device_properties["PowerDelayStandbyOn"]) ) - tango_context.device.powerDelayStandbyOn = 3 - assert tango_context.device.powerDelayStandbyOn == 3 + device_under_test.powerDelayStandbyOn = 3 + assert device_under_test.powerDelayStandbyOn == 3 # PROTECTED REGION END # // CspSubelementController.test_powerDelayStandbyOn # PROTECTED REGION ID(CspSubelementController.test_powerDelayStandbyOff_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_powerDelayStandbyOff_decorators - def test_powerDelayStandbyOff(self, tango_context, device_properties): + def test_powerDelayStandbyOff(self, device_under_test, device_properties): """Test for powerDelayStandbyOff.""" # PROTECTED REGION ID(CspSubelementController.test_testMode) ENABLED START # - assert tango_context.device.powerDelayStandbyOff == pytest.approx( + assert device_under_test.powerDelayStandbyOff == pytest.approx( float(device_properties["PowerDelayStandbyOff"]) ) - tango_context.device.powerDelayStandbyOff = 2 - assert tango_context.device.powerDelayStandbyOff == 2 + device_under_test.powerDelayStandbyOff = 2 + assert device_under_test.powerDelayStandbyOff == 2 # PROTECTED REGION END # // CspSubelementController.test_powerDelayStandbyOff # PROTECTED REGION ID(CspSubelementController.test_onProgress_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_onProgress_decorators - def test_onProgress(self, tango_context): + def test_onProgress(self, device_under_test): """Test for onProgress.""" # PROTECTED REGION ID(CspSubelementController.test_onProgress) ENABLED START # - assert tango_context.device.onProgress == 0 + assert device_under_test.onProgress == 0 # PROTECTED REGION END # // CspSubelementController.test_onProgress # PROTECTED REGION ID(CspSubelementController.test_onMaximumDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_onMaximumDuration_decorators - def test_onMaximumDuration(self, tango_context): + def test_onMaximumDuration(self, device_under_test): """Test for onMaximumDuration.""" # PROTECTED REGION ID(CspSubelementController.test_onMaximumDuration) ENABLED START # - tango_context.device.onMaximumDuration = 5 - assert tango_context.device.onMaximumDuration == 5 + device_under_test.onMaximumDuration = 5 + assert device_under_test.onMaximumDuration == 5 # PROTECTED REGION END # // CspSubelementController.test_onMaximumDuration # PROTECTED REGION ID(CspSubelementController.test_onMeasuredDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_onMeasuredDuration_decorators - def test_onMeasuredDuration(self, tango_context): + def test_onMeasuredDuration(self, device_under_test): """Test for onMeasuredDuration.""" # PROTECTED REGION ID(CspSubelementController.test_onMeasuredDuration) ENABLED START # - assert tango_context.device.onMeasuredDuration == 0 + assert device_under_test.onMeasuredDuration == 0 # PROTECTED REGION END # // CspSubelementController.test_onMeasuredDuration # PROTECTED REGION ID(CspSubelementController.test_standbyProgress_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_standbyProgress_decorators - def test_standbyProgress(self, tango_context): + def test_standbyProgress(self, device_under_test): """Test for standbyProgress.""" # PROTECTED REGION ID(CspSubelementController.test_standbyProgress) ENABLED START # - assert tango_context.device.standbyProgress == 0 + assert device_under_test.standbyProgress == 0 # PROTECTED REGION END # // CspSubelementController.test_standbyProgress # PROTECTED REGION ID(CspSubelementController.test_standbyMaximumDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_standbyMaximumDuration_decorators - def test_standbyMaximumDuration(self, tango_context): + def test_standbyMaximumDuration(self, device_under_test): """Test for standbyMaximumDuration.""" # PROTECTED REGION ID(CspSubelementController.test_standbyMaximumDuration) ENABLED START # - tango_context.device.standbyMaximumDuration = 5 - assert tango_context.device.standbyMaximumDuration == 5 + device_under_test.standbyMaximumDuration = 5 + assert device_under_test.standbyMaximumDuration == 5 # PROTECTED REGION END # // CspSubelementController.test_standbyMaximumDuration # PROTECTED REGION ID(CspSubelementController.test_standbyMeasuredDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_standbyMeasuredDuration_decorators - def test_standbyMeasuredDuration(self, tango_context): + def test_standbyMeasuredDuration(self, device_under_test): """Test for standbyMeasuredDuration.""" # PROTECTED REGION ID(CspSubelementController.test_standbyMeasuredDuration) ENABLED START # - assert tango_context.device.standbyMeasuredDuration == 0 + assert device_under_test.standbyMeasuredDuration == 0 # PROTECTED REGION END # // CspSubelementController.test_standbyMeasuredDuration # PROTECTED REGION ID(CspSubelementController.test_offProgress_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_offProgress_decorators - def test_offProgress(self, tango_context): + def test_offProgress(self, device_under_test): """Test for offProgress.""" # PROTECTED REGION ID(CspSubelementController.test_offProgress) ENABLED START # - assert tango_context.device.offProgress == 0 + assert device_under_test.offProgress == 0 # PROTECTED REGION END # // CspSubelementController.test_offProgress # PROTECTED REGION ID(CspSubelementController.test_offMaximumDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_offMaximumDuration_decorators - def test_offMaximumDuration(self, tango_context): + def test_offMaximumDuration(self, device_under_test): """Test for offMaximumDuration.""" # PROTECTED REGION ID(CspSubelementController.test_offMaximumDuration) ENABLED START # - tango_context.device.offMaximumDuration = 5 - assert tango_context.device.offMaximumDuration == 5 + device_under_test.offMaximumDuration = 5 + assert device_under_test.offMaximumDuration == 5 # PROTECTED REGION END # // CspSubelementController.test_offMaximumDuration # PROTECTED REGION ID(CspSubelementController.test_offMeasuredDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_offMeasuredDuration_decorators - def test_offMeasuredDuration(self, tango_context): + def test_offMeasuredDuration(self, device_under_test): """Test for offMeasuredDuration.""" # PROTECTED REGION ID(CspSubelementController.test_offMeasuredDuration) ENABLED START # - assert tango_context.device.offMeasuredDuration == 0 + assert device_under_test.offMeasuredDuration == 0 # PROTECTED REGION END # // CspSubelementController.test_offMeasuredDuration # PROTECTED REGION ID(CspSubelementController.test_loadFirmwareProgress_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_loadFirmwareProgress_decorators - def test_loadFirmwareProgress(self, tango_context): + def test_loadFirmwareProgress(self, device_under_test): """Test for loadFirmwareProgress.""" # PROTECTED REGION ID(CspSubelementController.test_loadFirmwareProgress) ENABLED START # - assert tango_context.device.loadFirmwareProgress == 0 + assert device_under_test.loadFirmwareProgress == 0 # PROTECTED REGION END # // CspSubelementController.test_loadFirmwareProgress # PROTECTED REGION ID(CspSubelementController.test_loadFirmwareMaximumDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_loadFirmwareMaximumDuration_decorators - def test_loadFirmwareMaximumDuration(self, tango_context): + def test_loadFirmwareMaximumDuration(self, device_under_test): """Test for loadFirmwareMaximumDuration.""" # PROTECTED REGION ID(CspSubelementController.test_loadFirmwareMaximumDuration) ENABLED START # - tango_context.device.loadFirmwareMaximumDuration = 5 - assert tango_context.device.loadFirmwareMaximumDuration == 5 + device_under_test.loadFirmwareMaximumDuration = 5 + assert device_under_test.loadFirmwareMaximumDuration == 5 # PROTECTED REGION END # // CspSubelementController.test_loadFirmwareMaximumDuration # PROTECTED REGION ID(CspSubelementController.test_loadFirmwareMeasuredDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_loadFirmwareMeasuredDuration_decorators - def test_loadFirmwareMeasuredDuration(self, tango_context): + def test_loadFirmwareMeasuredDuration(self, device_under_test): """Test for loadFirmwareMeasuredDuration.""" # PROTECTED REGION ID(CspSubelementController.test_loadFirmwareMeasuredDuration) ENABLED START # - assert tango_context.device.loadFirmwareMeasuredDuration == 0 + assert device_under_test.loadFirmwareMeasuredDuration == 0 # PROTECTED REGION END # // CspSubelementController.test_loadFirmwareMeasuredDuration # PROTECTED REGION ID(CspSubelementController.test_LoadFirmware_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_LoadFirmware_decorators - def test_LoadFirmware(self, tango_context): + def test_LoadFirmware(self, device_under_test): """Test for LoadFirmware.""" # PROTECTED REGION ID(CspSubelementController.test_LoadFirmware) ENABLED START # # After initialization the device is in the right state (OFF/MAINTENANCE) to # execute the command. - tango_context.device.adminMode = AdminMode.MAINTENANCE - assert tango_context.device.LoadFirmware( + device_under_test.adminMode = AdminMode.MAINTENANCE + assert device_under_test.LoadFirmware( ["file", "test/dev/b", "918698a7fea3"] ) == [[ResultCode.OK], ["LoadFirmware command completed OK"]] # PROTECTED REGION END # // CspSubelementController.test_LoadFirmware # PROTECTED REGION ID(CspSubelementController.test_LoadFirmware_when_in_wrong_state_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_LoadFirmware_wrong_state_decorators - def test_LoadFirmware_when_in_wrong_state(self, tango_context): + def test_LoadFirmware_when_in_wrong_state(self, device_under_test): """Test for LoadFirmware when the device is in wrong state.""" # PROTECTED REGION ID(CspSubelementController.test_LoadFirmware_when_in_wrong_state) ENABLED START # # Set the device in ON/ONLINE state - tango_context.device.On() + device_under_test.On() with pytest.raises(DevFailed, match="LoadFirmwareCommand not allowed"): - tango_context.device.LoadFirmware(["file", "test/dev/b", "918698a7fea3"]) + device_under_test.LoadFirmware(["file", "test/dev/b", "918698a7fea3"]) # PROTECTED REGION END # // CspSubelementController.test_LoadFirmware_when_in_wrong_state # PROTECTED REGION ID(CspSubelementController.test_PowerOnDevices_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_PowerOnDevices_decorators - def test_PowerOnDevices(self, tango_context): + def test_PowerOnDevices(self, device_under_test): """Test for PowerOnDevices.""" # PROTECTED REGION ID(CspSubelementController.test_PowerOnDevices) ENABLED START # # put it in ON state - tango_context.device.On() - assert tango_context.device.PowerOnDevices(["test/dev/1", "test/dev/2"]) == [ + device_under_test.On() + assert device_under_test.PowerOnDevices(["test/dev/1", "test/dev/2"]) == [ [ResultCode.OK], ["PowerOnDevices command completed OK"], ] @@ -318,21 +318,21 @@ class TestCspSubElementController(object): # PROTECTED REGION ID(CspSubelementController.test_PowerOnDevices_when_in_wrong_state_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_PowerOnDevices_decorators - def test_PowerOnDevices_when_in_wrong_state(self, tango_context): + def test_PowerOnDevices_when_in_wrong_state(self, device_under_test): """Test for PowerOnDevices when the Controller is in wrong state.""" # PROTECTED REGION ID(CspSubelementController.test_PowerOnDevices_when_in_wrong_state) ENABLED START # with pytest.raises(DevFailed, match="PowerOnDevicesCommand not allowed"): - tango_context.device.PowerOnDevices(["test/dev/1", "test/dev/2"]) + device_under_test.PowerOnDevices(["test/dev/1", "test/dev/2"]) # PROTECTED REGION END # // CspSubelementController.test_PowerOnDevices_when_in_wrong_state # PROTECTED REGION ID(CspSubelementController.test_PowerOffDevices_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_PowerOffDevices_decorators - def test_PowerOffDevices(self, tango_context): + def test_PowerOffDevices(self, device_under_test): """Test for PowerOffDEvices.""" # PROTECTED REGION ID(CspSubelementController.test_PowerOffDevices) ENABLED START # # put it in ON state - tango_context.device.On() - assert tango_context.device.PowerOffDevices(["test/dev/1", "test/dev/2"]) == [ + device_under_test.On() + assert device_under_test.PowerOffDevices(["test/dev/1", "test/dev/2"]) == [ [ResultCode.OK], ["PowerOffDevices command completed OK"], ] @@ -340,21 +340,21 @@ class TestCspSubElementController(object): # PROTECTED REGION ID(CspSubelementController.test_PowerOffDevices_when_in_wrong_state_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_PowerOffDevices_decorators - def test_PowerOffDevices_when_in_wrong_state(self, tango_context): + def test_PowerOffDevices_when_in_wrong_state(self, device_under_test): """Test for PowerOffDevices when the Controller is in wrong state.""" # PROTECTED REGION ID(CspSubelementController.test_PowerOffDevices_when_in_wrong_state) ENABLED START # with pytest.raises(DevFailed, match="PowerOffDevicesCommand not allowed"): - tango_context.device.PowerOffDevices(["test/dev/1", "test/dev/2"]) + device_under_test.PowerOffDevices(["test/dev/1", "test/dev/2"]) # PROTECTED REGION END # // CspSubelementController.test_PowerOffDevices_when_in_wrong_state # PROTECTED REGION ID(CspSubelementController.test_ReInitDevices_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_ReInitDevices_decorators - def test_ReInitDevices(self, tango_context): + def test_ReInitDevices(self, device_under_test): """Test for ReInitDevices.""" # PROTECTED REGION ID(CspSubelementController.test_ReInitDevices) ENABLED START # # put it in ON state - tango_context.device.On() - assert tango_context.device.ReInitDevices(["test/dev/1", "test/dev/2"]) == [ + device_under_test.On() + assert device_under_test.ReInitDevices(["test/dev/1", "test/dev/2"]) == [ [ResultCode.OK], ["ReInitDevices command completed OK"], ] @@ -362,12 +362,12 @@ class TestCspSubElementController(object): # PROTECTED REGION ID(CspSubelementController.test_ReInitDevices_when_in_wrong_state_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementController.test_ReInitDevices_when_in_wrong_state_decorators - def test_ReInitDevices_when_in_wrong_state(self, tango_context): + def test_ReInitDevices_when_in_wrong_state(self, device_under_test): """Test for ReInitDevices whe the device is in a wrong state.""" # PROTECTED REGION ID(CspSubelementController.test_ReInitDevices_when_in_wrong_state) ENABLED START # # put it in ON state with pytest.raises(DevFailed, match="ReInitDevicesCommand not allowed"): - tango_context.device.ReInitDevices(["test/dev/1", "test/dev/2"]) + device_under_test.ReInitDevices(["test/dev/1", "test/dev/2"]) # PROTECTED REGION END # // CspSubelementController.test_ReInitDevices_when_in_wrong_state diff --git a/tests/test_csp_obs_device.py b/tests/test_csp_obs_device.py index 1c37743139527cb6d64b3de69c13b28627358bf0..3aa5d0e685fd385e43cc6ea851f9a1d233cdce58 100644 --- a/tests/test_csp_obs_device.py +++ b/tests/test_csp_obs_device.py @@ -77,100 +77,99 @@ class TestCspSubElementObsDevice(object): # PROTECTED REGION ID(CspSubelementObsDevice.test_State_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_State_decorators - def test_State(self, tango_context): + def test_State(self, device_under_test): """Test for State.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_State) ENABLED START # - assert tango_context.device.State() == DevState.OFF + assert device_under_test.State() == DevState.OFF # PROTECTED REGION END # // CspSubelementObsDevice.test_State # PROTECTED REGION ID(CspSubelementObsDevice.test_Status_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_Status_decorators - def test_Status(self, tango_context): + def test_Status(self, device_under_test): """Test for Status.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_Status) ENABLED START # - assert tango_context.device.Status() == "The device is in OFF state." + assert device_under_test.Status() == "The device is in OFF state." # PROTECTED REGION END # // CspSubelementObsDevice.test_Status # PROTECTED REGION ID(CspSubelementObsDevice.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_GetVersionInfo_decorators - def test_GetVersionInfo(self, tango_context): + def test_GetVersionInfo(self, device_under_test): """Test for GetVersionInfo.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{tango_context.device.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " "A set of generic base devices for SKA Telescope." ) - versionInfo = tango_context.device.GetVersionInfo() + versionInfo = device_under_test.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None # PROTECTED REGION END # // CspSubelementObsDevice.test_GetVersionInfo # PROTECTED REGION ID(CspSubelementObsDevice.test_buildState_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_buildState_decorators - def test_buildState(self, tango_context): + def test_buildState(self, device_under_test): """Test for buildState.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_buildState) ENABLED START # buildPattern = re.compile( r"ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " r"A set of generic base devices for SKA Telescope" ) - assert (re.match(buildPattern, tango_context.device.buildState)) is not None + assert (re.match(buildPattern, device_under_test.buildState)) is not None # PROTECTED REGION END # // CspSubelementObsDevice.test_buildState # PROTECTED REGION ID(CspSubelementObsDevice.test_versionId_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_versionId_decorators - def test_versionId(self, tango_context): + def test_versionId(self, device_under_test): """Test for versionId.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_versionId) ENABLED START # versionIdPattern = re.compile(r"[0-9]+.[0-9]+.[0-9]+") - assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None + assert (re.match(versionIdPattern, device_under_test.versionId)) is not None # PROTECTED REGION END # // CspSubelementObsDevice.test_versionId # PROTECTED REGION ID(CspSubelementObsDevice.test_healthState_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_healthState_decorators - def test_healthState(self, tango_context): + def test_healthState(self, device_under_test): """Test for healthState.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_healthState) ENABLED START # - assert tango_context.device.healthState == HealthState.OK + assert device_under_test.healthState == HealthState.OK # PROTECTED REGION END # // CspSubelementObsDevice.test_healthState # PROTECTED REGION ID(CspSubelementObsDevice.test_adminMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_adminMode_decorators - def test_adminMode(self, tango_context): + def test_adminMode(self, device_under_test): """Test for adminMode.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_adminMode) ENABLED START # - assert tango_context.device.adminMode == AdminMode.ONLINE + assert device_under_test.adminMode == AdminMode.ONLINE # PROTECTED REGION END # // CspSubelementObsDevice.test_adminMode # PROTECTED REGION ID(CspSubelementObsDevice.test_controlMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_controlMode_decorators - def test_controlMode(self, tango_context): + def test_controlMode(self, device_under_test): """Test for controlMode.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_controlMode) ENABLED START # - assert tango_context.device.controlMode == ControlMode.REMOTE + assert device_under_test.controlMode == ControlMode.REMOTE # PROTECTED REGION END # // CspSubelementObsDevice.test_controlMode # PROTECTED REGION ID(CspSubelementObsDevice.test_simulationMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_simulationMode_decorators - def test_simulationMode(self, tango_context): + def test_simulationMode(self, device_under_test): """Test for simulationMode.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_simulationMode) ENABLED START # - assert tango_context.device.simulationMode == SimulationMode.FALSE + assert device_under_test.simulationMode == SimulationMode.FALSE # PROTECTED REGION END # // CspSubelementObsDevice.test_simulationMode # PROTECTED REGION ID(CspSubelementObsDevice.test_testMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_testMode_decorators - def test_testMode(self, tango_context): + def test_testMode(self, device_under_test): """Test for testMode.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_testMode) ENABLED START # - assert tango_context.device.testMode == TestMode.NONE + assert device_under_test.testMode == TestMode.NONE # PROTECTED REGION END # // CspSubelementObsDevice.test_testMode # PROTECTED REGION ID(CspSubelementObsDevice.test_scanID_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_scanID_decorators - def test_scanID(self, tango_context): + def test_scanID(self, device_under_test): """Test for scanID.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_scanID) ENABLED START # - device_under_test = tango_context.device device_under_test.On() assert device_under_test.scanID == 0 @@ -178,29 +177,27 @@ class TestCspSubElementObsDevice(object): # PROTECTED REGION ID(CspSubelementObsDevice.test_deviceID_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_deviceID_decorators - def test_deviceID(self, tango_context, device_properties): + def test_deviceID(self, device_under_test, device_properties): """Test for deviceID.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_scanID) ENABLED START # - assert tango_context.device.deviceID == int(device_properties["DeviceID"]) + assert device_under_test.deviceID == int(device_properties["DeviceID"]) # PROTECTED REGION END # // CspSubelementObsDevice.test_scanID # PROTECTED REGION ID(CspSubelementObsDevice.test_sdpDestinationAddresses_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_sdpDestinationAddresses_decorators - def test_sdpDestinationAddresses(self, tango_context): + def test_sdpDestinationAddresses(self, device_under_test): """Test for sdpDestinationAddresses.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_sdpDestinationAddresses) ENABLED START # addresses_dict = {"outputHost": [], "outputMac": [], "outputPort": []} - assert tango_context.device.sdpDestinationAddresses == json.dumps( - addresses_dict - ) + assert device_under_test.sdpDestinationAddresses == json.dumps(addresses_dict) # PROTECTED REGION END # // CspSubelementObsDevice.test_sdpDestinationAddresses # PROTECTED REGION ID(CspSubelementObsDevice.test_sdpLinkActive_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_sdpLinkActive_decorators - def test_sdpLinkActivity(self, tango_context): + def test_sdpLinkActivity(self, device_under_test): """Test for sdpLinkActive.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_sdpLinkActive) ENABLED START # - actual = tango_context.device.sdpLinkActive + actual = device_under_test.sdpLinkActive n_links = len(actual) expected = [False for i in range(0, n_links)] assert all([a == b for a, b in zip(actual, expected)]) @@ -208,26 +205,25 @@ class TestCspSubElementObsDevice(object): # PROTECTED REGION ID(CspSubelementObsDevice.test_sdpLinkCapacity_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_sdpLinkCapacity_decorators - def test_sdpLinkCapacity(self, tango_context): + def test_sdpLinkCapacity(self, device_under_test): """Test for sdpLinkCapacity.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_sdpLinkCapacity) ENABLED START # - assert tango_context.device.sdpLinkCapacity == 0 + assert device_under_test.sdpLinkCapacity == 0 # PROTECTED REGION END # // CspSubelementObsDevice.test_sdpLinkCapacity # PROTECTED REGION ID(CspSubelementObsDevice.test_healthFailureMessage_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_healthFailureMessage_decorators - def test_healthFailureMessage(self, tango_context): + def test_healthFailureMessage(self, device_under_test): """Test for healthFailureMessage.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_healthFailureMessage) ENABLED START # - assert tango_context.device.healthFailureMessage == "" + assert device_under_test.healthFailureMessage == "" # PROTECTED REGION END # // CspSubelementObsDevice.test_healthFailureMessage # PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_decorators - def test_ConfigureScan(self, tango_context, tango_change_event_helper): + def test_ConfigureScan(self, device_under_test, tango_change_event_helper): """Test for ConfigureScan.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan) ENABLED START # - device_under_test = tango_context.device device_under_test.On() assert device_under_test.obsState == ObsState.IDLE @@ -244,11 +240,10 @@ class TestCspSubElementObsDevice(object): # PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_when_in_wrong_state_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_when_in_wrong_state_decorators - def test_ConfigureScan_when_in_wrong_state(self, tango_context): + def test_ConfigureScan_when_in_wrong_state(self, device_under_test): """Test for ConfigureScan when the device is in wrong state.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_when_in_wrong_state) ENABLED START # # The device in in OFF/IDLE state, not valid to invoke ConfigureScan. - device_under_test = tango_context.device with pytest.raises(DevFailed, match="Component is not ON"): device_under_test.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') @@ -256,7 +251,7 @@ class TestCspSubElementObsDevice(object): # PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_decorators - def test_ConfigureScan_with_wrong_input_args(self, tango_context): + def test_ConfigureScan_with_wrong_input_args(self, device_under_test): """ Test ConfigureScan's handling of wrong input arguments. @@ -264,157 +259,157 @@ class TestCspSubElementObsDevice(object): configuration and the device is in IDLE state. """ # PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_when_idle) ENABLED START # - tango_context.device.On() + device_under_test.On() # wrong configurationID key - assert tango_context.device.obsState == ObsState.IDLE + assert device_under_test.obsState == ObsState.IDLE wrong_configuration = '{"subid":"sbi-mvp01-20200325-00002"}' - (result_code, _) = tango_context.device.ConfigureScan(wrong_configuration) + (result_code, _) = device_under_test.ConfigureScan(wrong_configuration) assert result_code == ResultCode.FAILED - assert tango_context.device.obsState == ObsState.IDLE + assert device_under_test.obsState == ObsState.IDLE # PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args # PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_json_syntax_error) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_json_syntax_error_decorators - def test_ConfigureScan_with_json_syntax_error(self, tango_context): + def test_ConfigureScan_with_json_syntax_error(self, device_under_test): """Test for ConfigureScan when syntax error in json configuration.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_json_syntax_error) ENABLED START # - tango_context.device.On() - assert tango_context.device.obsState == ObsState.IDLE + device_under_test.On() + assert device_under_test.obsState == ObsState.IDLE - (result_code, _) = tango_context.device.ConfigureScan('{"foo": 1,}') + (result_code, _) = device_under_test.ConfigureScan('{"foo": 1,}') assert result_code == ResultCode.FAILED - assert tango_context.device.obsState == ObsState.IDLE + assert device_under_test.obsState == ObsState.IDLE # PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_json_syntax_error # PROTECTED REGION ID(CspSubelementObsDevice.test_GoToIdle_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_GoToIdle_decorators - def test_GoToIdle(self, tango_context, tango_change_event_helper): + def test_GoToIdle(self, device_under_test, tango_change_event_helper): """Test for GoToIdle.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_GoToIdle) ENABLED START # - tango_context.device.On() + device_under_test.On() obs_state_callback = tango_change_event_helper.subscribe("obsState") - tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') + device_under_test.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') obs_state_callback.assert_calls( [ObsState.IDLE, ObsState.CONFIGURING, ObsState.READY] ) - tango_context.device.GoToIdle() + device_under_test.GoToIdle() obs_state_callback.assert_call(ObsState.IDLE) - assert tango_context.device.scanID == 0 - assert tango_context.device.configurationID == "" + assert device_under_test.scanID == 0 + assert device_under_test.configurationID == "" # PROTECTED REGION END # // CspSubelementObsDevice.test_GoToIdle # PROTECTED REGION ID(CspSubelementObsDevice.test_GoToIdle_when_in_wrong_state_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_GoToIdle_when_in_wrong_state_decorators - def test_GoToIdle_when_in_wrong_state(self, tango_context): + def test_GoToIdle_when_in_wrong_state(self, device_under_test): """Test for GoToIdle when the device is in wrong state.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_GoToIdle_when_in_wrong_state) ENABLED START # # The device in in OFF/IDLE state, not valid to invoke GoToIdle. with pytest.raises(DevFailed, match="Command not permitted by state model."): - tango_context.device.GoToIdle() + device_under_test.GoToIdle() # PROTECTED REGION END # // CspSubelementObsDevice.test_GoToIdle_when_in_wrong_state # PROTECTED REGION ID(CspSubelementObsDevice.test_Scan_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_Scan_decorators - def test_Scan(self, tango_context, tango_change_event_helper): + def test_Scan(self, device_under_test, tango_change_event_helper): """Test for Scan.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_Scan) ENABLED START # - tango_context.device.On() - tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') + device_under_test.On() + device_under_test.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') obs_state_callback = tango_change_event_helper.subscribe("obsState") - tango_context.device.Scan("1") + device_under_test.Scan("1") obs_state_callback.assert_calls([ObsState.READY, ObsState.SCANNING]) - assert tango_context.device.scanID == 1 + assert device_under_test.scanID == 1 # PROTECTED REGION END # // CspSubelementObsDevice.test_Scan # PROTECTED REGION ID(CspSubelementObsDevice.test_Scan_when_in_wrong_state_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_Scan_when_in_wrong_state_decorators - def test_Scan_when_in_wrong_state(self, tango_context): + def test_Scan_when_in_wrong_state(self, device_under_test): """Test for Scan when the device is in wrong state.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_Scan_when_in_wrong_state) ENABLED START # # Set the device in ON/IDLE state - tango_context.device.On() + device_under_test.On() with pytest.raises(DevFailed, match="Command not permitted by state model."): - tango_context.device.Scan("32") + device_under_test.Scan("32") # PROTECTED REGION END # // CspSubelementObsDevice.test_Scan_when_in_wrong_state # PROTECTED REGION ID(CspSubelementObsDevice.test_Scan_with_wrong_argument_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_Scan_with_wrong_argument_decorators - def test_Scan_with_wrong_argument(self, tango_context): + def test_Scan_with_wrong_argument(self, device_under_test): """Test for Scan when a wrong input argument is passed.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_Scan_with_wrong_argument) ENABLED START # # Set the device in ON/IDLE state - tango_context.device.On() - tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') - (result_code, _) = tango_context.device.Scan("abc") + device_under_test.On() + device_under_test.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') + (result_code, _) = device_under_test.Scan("abc") assert result_code == ResultCode.FAILED - assert tango_context.device.obsState == ObsState.READY + assert device_under_test.obsState == ObsState.READY # PROTECTED REGION END # // CspSubelementObsDevice.test_Scan_with_wrong_argument # PROTECTED REGION ID(CspSubelementObsDevice.test_EndScan_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_EndScan_decorators - def test_EndScan(self, tango_context, tango_change_event_helper): + def test_EndScan(self, device_under_test, tango_change_event_helper): """Test for EndScan.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_EndScan) ENABLED START # - tango_context.device.On() - tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') + device_under_test.On() + device_under_test.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.READY) - tango_context.device.Scan("1") + device_under_test.Scan("1") obs_state_callback.assert_call(ObsState.SCANNING) - tango_context.device.EndScan() + device_under_test.EndScan() obs_state_callback.assert_call(ObsState.READY) # PROTECTED REGION END # // CspSubelementObsDevice.test_EndScan # PROTECTED REGION ID(CspSubelementObsDevice.test_EndScan_when_in_wrong_state_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_EndScan_when_in_wrong_state_decorators - def test_EndScan_when_in_wrong_state(self, tango_context): + def test_EndScan_when_in_wrong_state(self, device_under_test): """Test for EndScan when the device is in wrong state.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_EndScan_when_in_wrong_state) ENABLED START # # Set the device in ON/READY state - tango_context.device.On() - tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') + device_under_test.On() + device_under_test.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') with pytest.raises(DevFailed, match="Command not permitted by state model."): - tango_context.device.EndScan() + device_under_test.EndScan() # PROTECTED REGION END # // CspSubelementObsDevice.test_EndScan_when_in_wrong_state # PROTECTED REGION ID(CspSubelementObsDevice.test_ObsReset_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_ObsReset_decorators - def test_ObsReset(self, tango_context, tango_change_event_helper): + def test_ObsReset(self, device_under_test, tango_change_event_helper): """Test for ObsReset.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_ObsReset) ENABLED START # - tango_context.device.On() - tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') + device_under_test.On() + device_under_test.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.READY) - tango_context.device.Abort() + device_under_test.Abort() obs_state_callback.assert_calls([ObsState.ABORTING, ObsState.ABORTED]) - tango_context.device.ObsReset() + device_under_test.ObsReset() obs_state_callback.assert_calls([ObsState.RESETTING, ObsState.IDLE]) # PROTECTED REGION END # // CspSubelementObsDevice.test_ObsReset # PROTECTED REGION ID(CspSubelementObsDevice.test_ObsReset_when_in_wrong_state_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_ObsReset_when_in_wrong_state_decorators - def test_ObsReset_when_in_wrong_state(self, tango_context): + def test_ObsReset_when_in_wrong_state(self, device_under_test): """Test for ObsReset when the device is in wrong state.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_ObsReset_when_in_wrong_state) ENABLED START # # Set the device in ON/IDLE state - tango_context.device.On() + device_under_test.On() with pytest.raises(DevFailed, match="Command not permitted by state model."): - tango_context.device.ObsReset() + device_under_test.ObsReset() # PROTECTED REGION END # // CspSubelementObsDevice.test_ObsReset_when_in_wrong_state # PROTECTED REGION ID(CspSubelementObsDevice.test_Abort_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementObsDevice.test_Abort_decorators - def test_Abort(self, tango_context, tango_change_event_helper): + def test_Abort(self, device_under_test, tango_change_event_helper): """Test for Abort.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_Abort) ENABLED START # - tango_context.device.On() - tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') + device_under_test.On() + device_under_test.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') obs_state_callback = tango_change_event_helper.subscribe("obsState") - tango_context.device.Abort() + device_under_test.Abort() obs_state_callback.assert_calls( [ObsState.READY, ObsState.ABORTING, ObsState.ABORTED] ) diff --git a/tests/test_csp_subarray.py b/tests/test_csp_subarray.py index d844a2b8ac8a98b25671026a00f8064a446392f2..37a4d0b465a69359c1b7c0988c8f084f2ac12865 100644 --- a/tests/test_csp_subarray.py +++ b/tests/test_csp_subarray.py @@ -70,7 +70,7 @@ class TestCspSubElementSubarray(object): } @pytest.mark.skip(reason="Not implemented") - def test_properties(self, tango_context): + def test_properties(self, device_under_test): """Test the device properties.""" # PROTECTED REGION ID(CspSubelementSubarray.test_properties) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_properties @@ -78,121 +78,118 @@ class TestCspSubElementSubarray(object): # PROTECTED REGION ID(CspSubelementSubarray.test_State_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_State_decorators - def test_State(self, tango_context): + def test_State(self, device_under_test): """Test for State.""" # PROTECTED REGION ID(CspSubelementSubarray.test_State) ENABLED START # - assert tango_context.device.State() == DevState.OFF + assert device_under_test.State() == DevState.OFF # PROTECTED REGION END # // CspSubelementSubarray.test_State # PROTECTED REGION ID(CspSubelementSubarray.test_Status_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_Status_decorators - def test_Status(self, tango_context): + def test_Status(self, device_under_test): """Test for Status.""" # PROTECTED REGION ID(CspSubelementSubarray.test_Status) ENABLED START # - assert tango_context.device.Status() == "The device is in OFF state." + assert device_under_test.Status() == "The device is in OFF state." # PROTECTED REGION END # // CspSubelementSubarray.test_Status # PROTECTED REGION ID(CspSubelementSubarray.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_GetVersionInfo_decorators - def test_GetVersionInfo(self, tango_context): + def test_GetVersionInfo(self, device_under_test): """Test for GetVersionInfo.""" # PROTECTED REGION ID(CspSubelementSubarray.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{tango_context.device.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " "A set of generic base devices for SKA Telescope." ) - versionInfo = tango_context.device.GetVersionInfo() + versionInfo = device_under_test.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None # PROTECTED REGION END # // CspSubelementSubarray.test_GetVersionInfo # PROTECTED REGION ID(CspSubelementSubarray.test_configurationProgress_decorators) ENABLED START # - def test_buildState(self, tango_context): + def test_buildState(self, device_under_test): """Test for buildState.""" # PROTECTED REGION ID(CspSubelementSubarray.test_buildState) ENABLED START # buildPattern = re.compile( r"ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " r"A set of generic base devices for SKA Telescope" ) - assert (re.match(buildPattern, tango_context.device.buildState)) is not None + assert (re.match(buildPattern, device_under_test.buildState)) is not None # PROTECTED REGION END # // CspSubelementSubarray.test_buildState # PROTECTED REGION ID(CspSubelementSubarray.test_versionId_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_versionId_decorators - def test_versionId(self, tango_context): + def test_versionId(self, device_under_test): """Test for versionId.""" # PROTECTED REGION ID(CspSubelementSubarray.test_versionId) ENABLED START # versionIdPattern = re.compile(r"[0-9]+.[0-9]+.[0-9]+") - assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None + assert (re.match(versionIdPattern, device_under_test.versionId)) is not None # PROTECTED REGION END # // CspSubelementSubarray.test_versionId # PROTECTED REGION ID(CspSubelementSubarray.test_healthState_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_healthState_decorators - def test_healthState(self, tango_context): + def test_healthState(self, device_under_test): """Test for healthState.""" # PROTECTED REGION ID(CspSubelementSubarray.test_healthState) ENABLED START # - assert tango_context.device.healthState == HealthState.OK + assert device_under_test.healthState == HealthState.OK # PROTECTED REGION END # // CspSubelementSubarray.test_healthState # PROTECTED REGION ID(CspSubelementSubarray.test_adminMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_adminMode_decorators - def test_adminMode(self, tango_context): + def test_adminMode(self, device_under_test): """Test for adminMode.""" # PROTECTED REGION ID(CspSubelementSubarray.test_adminMode) ENABLED START # - assert tango_context.device.adminMode == AdminMode.ONLINE + assert device_under_test.adminMode == AdminMode.ONLINE # PROTECTED REGION END # // CspSubelementSubarray.test_adminMode # PROTECTED REGION ID(CspSubelementSubarray.test_controlMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_controlMode_decorators - def test_controlMode(self, tango_context): + def test_controlMode(self, device_under_test): """Test for controlMode.""" # PROTECTED REGION ID(CspSubelementSubarray.test_controlMode) ENABLED START # - assert tango_context.device.controlMode == ControlMode.REMOTE + assert device_under_test.controlMode == ControlMode.REMOTE # PROTECTED REGION END # // CspSubelementSubarray.test_controlMode # PROTECTED REGION ID(CspSubelementSubarray.test_simulationMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_simulationMode_decorators - def test_simulationMode(self, tango_context): + def test_simulationMode(self, device_under_test): """Test for simulationMode.""" # PROTECTED REGION ID(CspSubelementSubarray.test_simulationMode) ENABLED START # - assert tango_context.device.simulationMode == SimulationMode.FALSE + assert device_under_test.simulationMode == SimulationMode.FALSE # PROTECTED REGION END # // CspSubelementSubarray.test_simulationMode # PROTECTED REGION ID(CspSubelementSubarray.test_testMode_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_testMode_decorators - def test_testMode(self, tango_context): + def test_testMode(self, device_under_test): """Test for testMode.""" # PROTECTED REGION ID(CspSubelementSubarray.test_testMode) ENABLED START # - assert tango_context.device.testMode == TestMode.NONE + assert device_under_test.testMode == TestMode.NONE # PROTECTED REGION END # // CspSubelementSubarray.test_testMode # PROTECTED REGION ID(CspSubelementSubarray.test_scanID_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_scanID_decorators - def test_scanID(self, tango_context): + def test_scanID(self, device_under_test): """Test for scanID.""" # PROTECTED REGION ID(CspSubelementSubarray.test_scanID) ENABLED START # - device_under_test = tango_context.device device_under_test.On() assert device_under_test.scanID == 0 # PROTECTED REGION END # // CspSubelementSubarray.test_scanID # PROTECTED REGION ID(CspSubelementSubarray.test_sdpDestinationAddresses_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_sdpDestinationAddresses_decorators - def test_sdpDestinationAddresses(self, tango_context): + def test_sdpDestinationAddresses(self, device_under_test): """Test for sdpDestinationAddresses.""" # PROTECTED REGION ID(CspSubelementSubarray.test_sdpDestinationAddresses) ENABLED START # addresses_dict = {"outputHost": [], "outputMac": [], "outputPort": []} - tango_context.device.sdpDestinationAddresses = json.dumps(addresses_dict) - assert tango_context.device.sdpDestinationAddresses == json.dumps( - addresses_dict - ) + device_under_test.sdpDestinationAddresses = json.dumps(addresses_dict) + assert device_under_test.sdpDestinationAddresses == json.dumps(addresses_dict) # PROTECTED REGION END # // CspSubelementSubarray.test_sdpDestinationAddresses # PROTECTED REGION ID(CspSubelementSubarray.test_sdpLinkActive_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_sdpLinkActive_decorators - def test_sdpLinkActivity(self, tango_context): + def test_sdpLinkActivity(self, device_under_test): """Test for sdpLinkActive.""" # PROTECTED REGION ID(CspSubelementSubarray.test_sdpLinkActive) ENABLED START # - actual = tango_context.device.sdpLinkActive + actual = device_under_test.sdpLinkActive n_links = len(actual) expected = [False for i in range(0, n_links)] assert all([a == b for a, b in zip(actual, expected)]) @@ -200,20 +197,18 @@ class TestCspSubElementSubarray(object): # PROTECTED REGION ID(CspSubelementSubarray.test_outputDataRateToSdp_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_outputDataRateToSdp_decorators - def test_outputDataRateToSdp(self, tango_context): + def test_outputDataRateToSdp(self, device_under_test): """Test for outputDataRateToSdp.""" # PROTECTED REGION ID(CspSubelementSubarray.test_outputDataRateToSdp) ENABLED START # - assert tango_context.device.outputDataRateToSdp == 0 + assert device_under_test.outputDataRateToSdp == 0 # PROTECTED REGION END # // CspSubelementSubarray.test_outputDataRateToSdp # PROTECTED REGION ID(CspSubelementSubarray.test_listOfDevicesCompletedTasks_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_listOfDevicesCompletedTasks_decorators - def test_listOfDevicesCompletedTasks(self, tango_context): + def test_listOfDevicesCompletedTasks(self, device_under_test): """Test for listOfDevicesCompletedTasks.""" # PROTECTED REGION ID(CspSubelementSubarray.test_listOfDevicesCompletedTasks) ENABLED START # - attr_value_as_dict = json.loads( - tango_context.device.listOfDevicesCompletedTasks - ) + attr_value_as_dict = json.loads(device_under_test.listOfDevicesCompletedTasks) assert not bool(attr_value_as_dict) # PROTECTED REGION END # // CspSubelementSubarray.test_listOfDevicesCompletedTasks @@ -222,103 +217,102 @@ class TestCspSubElementSubarray(object): # PROTECTED REGION ID(CspSubelementSubarray.test_assignResourcesMaximumDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_assignResourcesMaximumDuration_decorators - def test_assignResourcesMaximumDuration(self, tango_context): + def test_assignResourcesMaximumDuration(self, device_under_test): """Test for assignResourcesMaximumDuration.""" # PROTECTED REGION ID(CspSubelementSubarray.test_assignResourcesMaximumDuration) ENABLED START # - tango_context.device.assignResourcesMaximumDuration = 5 - assert tango_context.device.assignResourcesMaximumDuration == 5 + device_under_test.assignResourcesMaximumDuration = 5 + assert device_under_test.assignResourcesMaximumDuration == 5 # PROTECTED REGION END # // CspSubelementSubarray.test_assignResourcesMaximumDuration # PROTECTED REGION ID(CspSubelementSubarray.test_configureScanMeasuredDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_configureScanMeasuredDuration_decorators - def test_configureScanMeasuredDuration(self, tango_context): + def test_configureScanMeasuredDuration(self, device_under_test): """Test for configureScanMeasuredDuration.""" # PROTECTED REGION ID(CspSubelementSubarray.test_configureScanMeasuredDuration) ENABLED START # - assert tango_context.device.configureScanMeasuredDuration == 0 + assert device_under_test.configureScanMeasuredDuration == 0 # PROTECTED REGION END # // CspSubelementSubarray.test_configureScanMeasuredDuration # PROTECTED REGION ID(CspSubelementSubarray.test_configurationProgress_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_configurationProgress_decorators - def test_configurationProgress(self, tango_context): + def test_configurationProgress(self, device_under_test): """Test for configurationProgress.""" # PROTECTED REGION ID(CspSubelementSubarray.test_configurationProgress) ENABLED START # - assert tango_context.device.configurationProgress == 0 + assert device_under_test.configurationProgress == 0 # PROTECTED REGION END # // CspSubelementSubarray.test_configurationProgress # PROTECTED REGION ID(CspSubelementSubarray.test_assignResourcesMeasuredDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_assignResourcesMeasuredDuration_decorators - def test_assignResourcesMeasuredDuration(self, tango_context): + def test_assignResourcesMeasuredDuration(self, device_under_test): """Test for assignResourcesMeasuredDuration.""" # PROTECTED REGION ID(CspSubelementSubarray.test_assignResourcesMeasuredDuration) ENABLED START # - assert tango_context.device.assignResourcesMeasuredDuration == 0 + assert device_under_test.assignResourcesMeasuredDuration == 0 # PROTECTED REGION END # // CspSubelementSubarray.test_assignResourcesMeasuredDuration # PROTECTED REGION ID(CspSubelementSubarray.test_assignResourcesProgress_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_assignResourcesProgress_decorators - def test_assignResourcesProgress(self, tango_context): + def test_assignResourcesProgress(self, device_under_test): """Test for assignResourcesProgress.""" # PROTECTED REGION ID(CspSubelementSubarray.test_assignResourcesProgress) ENABLED START # - assert tango_context.device.assignResourcesProgress == 0 + assert device_under_test.assignResourcesProgress == 0 # PROTECTED REGION END # // CspSubelementSubarray.test_assignResourcesProgress # PROTECTED REGION ID(CspSubelementSubarray.test_releaseResourcesMaximumDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_releaseResourcesMaximumDuration_decorators - def test_releaseResourcesMaximumDuration(self, tango_context): + def test_releaseResourcesMaximumDuration(self, device_under_test): """Test for releaseResourcesMaximumDuration.""" # PROTECTED REGION ID(CspSubelementSubarray.test_releaseResourcesMaximumDuration) ENABLED START # - tango_context.device.releaseResourcesMaximumDuration = 5 - assert tango_context.device.releaseResourcesMaximumDuration == 5 + device_under_test.releaseResourcesMaximumDuration = 5 + assert device_under_test.releaseResourcesMaximumDuration == 5 # PROTECTED REGION END # // CspSubelementSubarray.test_releaseResourcesMaximumDuration # PROTECTED REGION ID(CspSubelementSubarray.test_releaseResourcesMeasuredDuration_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_releaseResourcesMeasuredDuration_decorators - def test_releaseResourcesMeasuredDuration(self, tango_context): + def test_releaseResourcesMeasuredDuration(self, device_under_test): """Test for releaseResourcesMeasuredDuration.""" # PROTECTED REGION ID(CspSubelementSubarray.test_releaseResourcesMeasuredDuration) ENABLED START # - assert tango_context.device.releaseResourcesMeasuredDuration == 0 + assert device_under_test.releaseResourcesMeasuredDuration == 0 # PROTECTED REGION END # // CspSubelementSubarray.test_releaseResourcesMeasuredDuration # PROTECTED REGION ID(CspSubelementSubarray.test_releaseResourcesProgress_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_releaseResourcesProgress_decorators - def test_releaseResourcesProgress(self, tango_context): + def test_releaseResourcesProgress(self, device_under_test): """Test for releaseResourcesProgress.""" # PROTECTED REGION ID(CspSubelementSubarray.test_releaseResourcesProgress) ENABLED START # - assert tango_context.device.releaseResourcesProgress == 0 + assert device_under_test.releaseResourcesProgress == 0 # PROTECTED REGION END # // CspSubelementSubarray.test_releaseResourcesProgress # PROTECTED REGION ID(CspSubelementSubarray.test_timeoutExpiredFlag_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_timeoutExpiredFlag_decorators - def test_configureScanTimeoutExpiredFlag(self, tango_context): + def test_configureScanTimeoutExpiredFlag(self, device_under_test): """Test for timeoutExpiredFlag.""" # PROTECTED REGION ID(CspSubelementSubarray.test_timeoutExpiredFlag) ENABLED START # - assert not tango_context.device.configureScanTimeoutExpiredFlag + assert not device_under_test.configureScanTimeoutExpiredFlag # PROTECTED REGION END # // CspSubelementSubarray.test_timeoutExpiredFlag # PROTECTED REGION ID(CspSubelementSubarray.test_timeoutExpiredFlag_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_timeoutExpiredFlag_decorators - def test_assignResourcesTimeoutExpiredFlag(self, tango_context): + def test_assignResourcesTimeoutExpiredFlag(self, device_under_test): """Test for timeoutExpiredFlag.""" # PROTECTED REGION ID(CspSubelementSubarray.test_timeoutExpiredFlag) ENABLED START # - assert not tango_context.device.assignResourcesTimeoutExpiredFlag + assert not device_under_test.assignResourcesTimeoutExpiredFlag # PROTECTED REGION END # // CspSubelementSubarray.test_timeoutExpiredFlag # PROTECTED REGION ID(CspSubelementSubarray.test_timeoutExpiredFlag_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_timeoutExpiredFlag_decorators - def test_releaseResourcesTimeoutExpiredFlag(self, tango_context): + def test_releaseResourcesTimeoutExpiredFlag(self, device_under_test): """Test for timeoutExpiredFlag.""" # PROTECTED REGION ID(CspSubelementSubarray.test_timeoutExpiredFlag) ENABLED START # - assert not tango_context.device.releaseResourcesTimeoutExpiredFlag + assert not device_under_test.releaseResourcesTimeoutExpiredFlag # PROTECTED REGION END # // CspSubelementSubarray.test_timeoutExpiredFlag # PROTECTED REGION ID(CspSubelementSubarray.test_ConfigureScan_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_ConfigureScan_decorators @pytest.mark.parametrize("command_alias", ["Configure", "ConfigureScan"]) def test_ConfigureScan( - self, tango_context, tango_change_event_helper, command_alias + self, device_under_test, tango_change_event_helper, command_alias ): """Test for ConfigureScan.""" # PROTECTED REGION ID(CspSubelementSubarray.test_ConfigureScan) ENABLED START # - device_under_test = tango_context.device device_under_test.On() device_under_test.AssignResources(json.dumps([1, 2, 3])) assert device_under_test.obsState == ObsState.IDLE @@ -330,65 +324,67 @@ class TestCspSubElementSubarray(object): [ObsState.IDLE, ObsState.CONFIGURING, ObsState.READY] ) assert device_under_test.obsState == ObsState.READY - assert tango_context.device.configurationID == "sbi-mvp01-20200325-00002" - assert tango_context.device.lastScanConfiguration == scan_configuration + assert device_under_test.configurationID == "sbi-mvp01-20200325-00002" + assert device_under_test.lastScanConfiguration == scan_configuration # PROTECTED REGION END # // CspSubelementSubarray.test_ConfigureScan # PROTECTED REGION ID(CspSubelementSubarray.test_ConfigureScan_when_in_wrong_state_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_ConfigureScan_when_in_wrong_state_decorators - def test_ConfigureScan_when_in_wrong_state(self, tango_context): + def test_ConfigureScan_when_in_wrong_state(self, device_under_test): """Test for ConfigureScan when the device is in wrong state.""" # PROTECTED REGION ID(CspSubelementSubarray.test_ConfigureScan_when_in_wrong_state) ENABLED START # # The device in in OFF/EMPTY state, not valid to invoke ConfigureScan. with pytest.raises(DevFailed, match="Command not permitted by state model."): - tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') + device_under_test.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') # PROTECTED REGION END # // CspSubelementSubarray.test_ConfigureScan_when_in_wrong_state # PROTECTED REGION ID(CspSubelementSubarray.test_ConfigureScan_with_wrong_configId_key_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_ConfigureScan_with_wrong_configId_key_decorators - def test_ConfigureScan_with_wrong_configId_key(self, tango_context): + def test_ConfigureScan_with_wrong_configId_key(self, device_under_test): """Test that ConfigureScan handles a wrong configuration id key.""" # PROTECTED REGION ID(CspSubelementSubarray.test_ConfigureScan_with_wrong_configId_key) ENABLED START # - tango_context.device.On() - tango_context.device.AssignResources(json.dumps([1, 2, 3])) + device_under_test.On() + device_under_test.AssignResources(json.dumps([1, 2, 3])) # wrong configurationID key - assert tango_context.device.obsState == ObsState.IDLE + assert device_under_test.obsState == ObsState.IDLE wrong_configuration = '{"subid":"sbi-mvp01-20200325-00002"}' - result_code, _ = tango_context.device.ConfigureScan(wrong_configuration) + result_code, _ = device_under_test.ConfigureScan(wrong_configuration) assert result_code == ResultCode.FAILED - assert tango_context.device.obsState == ObsState.IDLE + assert device_under_test.obsState == ObsState.IDLE # PROTECTED REGION END # // CspSubelementSubarray.test_ConfigureScan_with_wrong_configId_key # PROTECTED REGION ID(CspSubelementSubarray.test_ConfigureScan_with_json_syntax_error) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_ConfigureScan_with_json_syntax_error_decorators - def test_ConfigureScan_with_json_syntax_error(self, tango_context): + def test_ConfigureScan_with_json_syntax_error(self, device_under_test): """Test for ConfigureScan when syntax error in json configuration.""" # PROTECTED REGION ID(CspSubelementSubarray.test_ConfigureScan_with_json_syntax_error) ENABLED START # - tango_context.device.On() - tango_context.device.AssignResources(json.dumps([1, 2, 3])) - assert tango_context.device.obsState == ObsState.IDLE + device_under_test.On() + device_under_test.AssignResources(json.dumps([1, 2, 3])) + assert device_under_test.obsState == ObsState.IDLE - result_code, _ = tango_context.device.ConfigureScan('{"foo": 1,}') + result_code, _ = device_under_test.ConfigureScan('{"foo": 1,}') assert result_code == ResultCode.FAILED - assert tango_context.device.obsState == ObsState.IDLE + assert device_under_test.obsState == ObsState.IDLE # PROTECTED REGION END # // CspSubelementSubarray.test_ConfigureScan_with_json_syntax_error # PROTECTED REGION ID(CspSubelementSubarray.test_GoToIdle_decorators) ENABLED START # # PROTECTED REGION END # // CspSubelementSubarray.test_GoToIdle_decorators @pytest.mark.parametrize("command_alias", ["GoToIdle", "End"]) - def test_GoToIdle(self, tango_context, tango_change_event_helper, command_alias): + def test_GoToIdle( + self, device_under_test, tango_change_event_helper, command_alias + ): """Test for GoToIdle.""" # PROTECTED REGION ID(CspSubelementSubarray.test_GoToIdle) ENABLED START # - tango_context.device.On() - tango_context.device.AssignResources(json.dumps([1, 2, 3])) + device_under_test.On() + device_under_test.AssignResources(json.dumps([1, 2, 3])) obs_state_callback = tango_change_event_helper.subscribe("obsState") - tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') + device_under_test.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}') obs_state_callback.assert_calls( [ObsState.IDLE, ObsState.CONFIGURING, ObsState.READY] ) - tango_context.device.command_inout(command_alias) + device_under_test.command_inout(command_alias) obs_state_callback.assert_call(ObsState.IDLE) - assert tango_context.device.scanID == 0 - assert tango_context.device.configurationID == "" + assert device_under_test.scanID == 0 + assert device_under_test.configurationID == "" # PROTECTED REGION END # // CspSubelementSubarray.test_GoToIdle diff --git a/tests/test_logger_device.py b/tests/test_logger_device.py index b474c825a45783fab433386ba3a0994fd60dfd70..2bdf46bb3c40817af04f3577c52837b6c1072039 100644 --- a/tests/test_logger_device.py +++ b/tests/test_logger_device.py @@ -31,7 +31,6 @@ from ska_tango_base.control_model import ( # PROTECTED REGION ID(SKALogger.test_SKALogger_decorators) ENABLED START # -@pytest.mark.usefixtures("tango_context", "initialize_device") # PROTECTED REGION END # // SKALogger.test_SKALogger_decorators class TestSKALogger(object): """Test class for tests of the SKALogger device class.""" @@ -54,7 +53,7 @@ class TestSKALogger(object): } @pytest.mark.skip("Not implemented") - def test_properties(self, tango_context): + def test_properties(self, device_under_test): """Test device properties.""" # PROTECTED REGION ID(SKALogger.test_properties) ENABLED START # # PROTECTED REGION END # // SKALogger.test_properties @@ -62,100 +61,100 @@ class TestSKALogger(object): # PROTECTED REGION ID(SKALogger.test_State_decorators) ENABLED START # # PROTECTED REGION END # // SKALogger.test_State_decorators - def test_State(self, tango_context): + def test_State(self, device_under_test): """Test for State.""" # PROTECTED REGION ID(SKALogger.test_State) ENABLED START # - assert tango_context.device.State() == DevState.OFF + assert device_under_test.State() == DevState.OFF # PROTECTED REGION END # // SKALogger.test_State # PROTECTED REGION ID(SKALogger.test_Status_decorators) ENABLED START # # PROTECTED REGION END # // SKALogger.test_Status_decorators - def test_Status(self, tango_context): + def test_Status(self, device_under_test): """Test for Status.""" # PROTECTED REGION ID(SKALogger.test_Status) ENABLED START # - assert tango_context.device.Status() == "The device is in OFF state." + assert device_under_test.Status() == "The device is in OFF state." # PROTECTED REGION END # // SKALogger.test_Status # PROTECTED REGION ID(SKALogger.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // SKALogger.test_GetVersionInfo_decorators - def test_GetVersionInfo(self, tango_context): + def test_GetVersionInfo(self, device_under_test): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKALogger.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{tango_context.device.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " "A set of generic base devices for SKA Telescope." ) - versionInfo = tango_context.device.GetVersionInfo() + versionInfo = device_under_test.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None # PROTECTED REGION END # // SKALogger.test_GetVersionInfo # PROTECTED REGION ID(SKALogger.test_buildState_decorators) ENABLED START # # PROTECTED REGION END # // SKALogger.test_buildState_decorators - def test_buildState(self, tango_context): + def test_buildState(self, device_under_test): """Test for buildState.""" # PROTECTED REGION ID(SKALogger.test_buildState) ENABLED START # buildPattern = re.compile( r"ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " r"A set of generic base devices for SKA Telescope" ) - assert (re.match(buildPattern, tango_context.device.buildState)) is not None + assert (re.match(buildPattern, device_under_test.buildState)) is not None # PROTECTED REGION END # // SKALogger.test_buildState # PROTECTED REGION ID(SKALogger.test_versionId_decorators) ENABLED START # # PROTECTED REGION END # // SKALogger.test_versionId_decorators - def test_versionId(self, tango_context): + def test_versionId(self, device_under_test): """Test for versionId.""" # PROTECTED REGION ID(SKALogger.test_versionId) ENABLED START # versionIdPattern = re.compile(r"[0-9]+.[0-9]+.[0-9]+") - assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None + assert (re.match(versionIdPattern, device_under_test.versionId)) is not None # PROTECTED REGION END # // SKALogger.test_versionId # PROTECTED REGION ID(SKALogger.test_loggingLevel_decorators) ENABLED START # # PROTECTED REGION END # // SKALogger.test_loggingLevel_decorators - def test_loggingLevel(self, tango_context): + def test_loggingLevel(self, device_under_test): """Test for loggingLevel.""" # PROTECTED REGION ID(SKALogger.test_loggingLevel) ENABLED START # - assert tango_context.device.loggingLevel == LoggingLevel.INFO + assert device_under_test.loggingLevel == LoggingLevel.INFO # PROTECTED REGION END # // SKALogger.test_loggingLevel # PROTECTED REGION ID(SKALogger.test_healthState_decorators) ENABLED START # # PROTECTED REGION END # // SKALogger.test_healthState_decorators - def test_healthState(self, tango_context): + def test_healthState(self, device_under_test): """Test for healthState.""" # PROTECTED REGION ID(SKALogger.test_healthState) ENABLED START # - assert tango_context.device.healthState == HealthState.OK + assert device_under_test.healthState == HealthState.OK # PROTECTED REGION END # // SKALogger.test_healthState # PROTECTED REGION ID(SKALogger.test_adminMode_decorators) ENABLED START # # PROTECTED REGION END # // SKALogger.test_adminMode_decorators - def test_adminMode(self, tango_context): + def test_adminMode(self, device_under_test): """Test for adminMode.""" # PROTECTED REGION ID(SKALogger.test_adminMode) ENABLED START # - assert tango_context.device.adminMode == AdminMode.ONLINE + assert device_under_test.adminMode == AdminMode.ONLINE # PROTECTED REGION END # // SKALogger.test_adminMode # PROTECTED REGION ID(SKALogger.test_controlMode_decorators) ENABLED START # # PROTECTED REGION END # // SKALogger.test_controlMode_decorators - def test_controlMode(self, tango_context): + def test_controlMode(self, device_under_test): """Test for controlMode.""" # PROTECTED REGION ID(SKALogger.test_controlMode) ENABLED START # - assert tango_context.device.controlMode == ControlMode.REMOTE + assert device_under_test.controlMode == ControlMode.REMOTE # PROTECTED REGION END # // SKALogger.test_controlMode # PROTECTED REGION ID(SKALogger.test_simulationMode_decorators) ENABLED START # # PROTECTED REGION END # // SKALogger.test_simulationMode_decorators - def test_simulationMode(self, tango_context): + def test_simulationMode(self, device_under_test): """Test for simulationMode.""" # PROTECTED REGION ID(SKALogger.test_simulationMode) ENABLED START # - assert tango_context.device.simulationMode == SimulationMode.FALSE + assert device_under_test.simulationMode == SimulationMode.FALSE # PROTECTED REGION END # // SKALogger.test_simulationMode # PROTECTED REGION ID(SKALogger.test_testMode_decorators) ENABLED START # # PROTECTED REGION END # // SKALogger.test_testMode_decorators - def test_testMode(self, tango_context): + def test_testMode(self, device_under_test): """Test for testMode.""" # PROTECTED REGION ID(SKALogger.test_testMode) ENABLED START # - assert tango_context.device.testMode == TestMode.NONE + assert device_under_test.testMode == TestMode.NONE # PROTECTED REGION END # // SKALogger.test_testMode diff --git a/tests/test_obs_device.py b/tests/test_obs_device.py index f374783fe8df55a2b73854c7745b223912a5a6ed..daceac14f357a0d17013f389caf847a4884abb5f 100644 --- a/tests/test_obs_device.py +++ b/tests/test_obs_device.py @@ -33,7 +33,6 @@ from ska_tango_base.control_model import ( # Device test case # PROTECTED REGION ID(SKAObsDevice.test_SKAObsDevice_decorators) ENABLED START # -@pytest.mark.usefixtures("tango_context", "initialize_device") # PROTECTED REGION END # // SKAObsDevice.test_SKAObsDevice_decorators class TestSKAObsDevice(object): """Test class for tests of the SKAObsDevice device class.""" @@ -57,7 +56,7 @@ class TestSKAObsDevice(object): } @pytest.mark.skip("Not implemented") - def test_properties(self, tango_context): + def test_properties(self, device_under_test): """Test device properties.""" # PROTECTED REGION ID(SKAObsDevice.test_properties) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_properties @@ -65,39 +64,39 @@ class TestSKAObsDevice(object): # PROTECTED REGION ID(SKAObsDevice.test_State_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_State_decorators - def test_State(self, tango_context): + def test_State(self, device_under_test): """Test for State.""" # PROTECTED REGION ID(SKAObsDevice.test_State) ENABLED START # - assert tango_context.device.State() == DevState.OFF + assert device_under_test.State() == DevState.OFF # PROTECTED REGION END # // SKAObsDevice.test_State # PROTECTED REGION ID(SKAObsDevice.test_Status_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_Status_decorators - def test_Status(self, tango_context): + def test_Status(self, device_under_test): """Test for Status.""" # PROTECTED REGION ID(SKAObsDevice.test_Status) ENABLED START # - assert tango_context.device.Status() == "The device is in OFF state." + assert device_under_test.Status() == "The device is in OFF state." # PROTECTED REGION END # // SKAObsDevice.test_Status # PROTECTED REGION ID(SKAObsDevice.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_GetVersionInfo_decorators - def test_GetVersionInfo(self, tango_context): + def test_GetVersionInfo(self, device_under_test): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKAObsDevice.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{tango_context.device.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " "A set of generic base devices for SKA Telescope." ) - versionInfo = tango_context.device.GetVersionInfo() + versionInfo = device_under_test.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None # PROTECTED REGION END # // SKAObsDevice.test_GetVersionInfo # PROTECTED REGION ID(SKAObsDevice.test_obsState_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_obsState_decorators - def test_obsState(self, tango_context, tango_change_event_helper): + def test_obsState(self, device_under_test, tango_change_event_helper): """Test for obsState.""" # PROTECTED REGION ID(SKAObsDevice.test_obsState) ENABLED START # - assert tango_context.device.obsState == ObsState.EMPTY + assert device_under_test.obsState == ObsState.EMPTY # Check that events are working by subscribing and checking for that # initial event @@ -107,87 +106,87 @@ class TestSKAObsDevice(object): # PROTECTED REGION ID(SKAObsDevice.test_obsMode_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_obsMode_decorators - def test_obsMode(self, tango_context): + def test_obsMode(self, device_under_test): """Test for obsMode.""" # PROTECTED REGION ID(SKAObsDevice.test_obsMode) ENABLED START # - assert tango_context.device.obsMode == ObsMode.IDLE + assert device_under_test.obsMode == ObsMode.IDLE # PROTECTED REGION END # // SKAObsDevice.test_obsMode # PROTECTED REGION ID(SKAObsDevice.test_configurationProgress_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_configurationProgress_decorators - def test_configurationProgress(self, tango_context): + def test_configurationProgress(self, device_under_test): """Test for configurationProgress.""" # PROTECTED REGION ID(SKAObsDevice.test_configurationProgress) ENABLED START # - assert tango_context.device.configurationProgress == 0 + assert device_under_test.configurationProgress == 0 # PROTECTED REGION END # // SKAObsDevice.test_configurationProgress # PROTECTED REGION ID(SKAObsDevice.test_configurationDelayExpected_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_configurationDelayExpected_decorators - def test_configurationDelayExpected(self, tango_context): + def test_configurationDelayExpected(self, device_under_test): """Test for configurationDelayExpected.""" # PROTECTED REGION ID(SKAObsDevice.test_configurationDelayExpected) ENABLED START # - assert tango_context.device.configurationDelayExpected == 0 + assert device_under_test.configurationDelayExpected == 0 # PROTECTED REGION END # // SKAObsDevice.test_configurationDelayExpected # PROTECTED REGION ID(SKAObsDevice.test_buildState_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_buildState_decorators - def test_buildState(self, tango_context): + def test_buildState(self, device_under_test): """Test for buildState.""" # PROTECTED REGION ID(SKAObsDevice.test_buildState) ENABLED START # buildPattern = re.compile( r"ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " r"A set of generic base devices for SKA Telescope" ) - assert (re.match(buildPattern, tango_context.device.buildState)) is not None + assert (re.match(buildPattern, device_under_test.buildState)) is not None # PROTECTED REGION END # // SKAObsDevice.test_buildState # PROTECTED REGION ID(SKAObsDevice.test_versionId_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_versionId_decorators - def test_versionId(self, tango_context): + def test_versionId(self, device_under_test): """Test for versionId.""" # PROTECTED REGION ID(SKAObsDevice.test_versionId) ENABLED START # versionIdPattern = re.compile(r"[0-9]+.[0-9]+.[0-9]+") - assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None + assert (re.match(versionIdPattern, device_under_test.versionId)) is not None # PROTECTED REGION END # // SKAObsDevice.test_versionId # PROTECTED REGION ID(SKAObsDevice.test_healthState_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_healthState_decorators - def test_healthState(self, tango_context): + def test_healthState(self, device_under_test): """Test for healthState.""" # PROTECTED REGION ID(SKAObsDevice.test_healthState) ENABLED START # - assert tango_context.device.healthState == HealthState.OK + assert device_under_test.healthState == HealthState.OK # PROTECTED REGION END # // SKAObsDevice.test_healthState # PROTECTED REGION ID(SKAObsDevice.test_adminMode_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_adminMode_decorators - def test_adminMode(self, tango_context): + def test_adminMode(self, device_under_test): """Test for adminMode.""" # PROTECTED REGION ID(SKAObsDevice.test_adminMode) ENABLED START # - assert tango_context.device.adminMode == AdminMode.ONLINE + assert device_under_test.adminMode == AdminMode.ONLINE # PROTECTED REGION END # // SKAObsDevice.test_adminMode # PROTECTED REGION ID(SKAObsDevice.test_controlMode_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_controlMode_decorators - def test_controlMode(self, tango_context): + def test_controlMode(self, device_under_test): """Test for controlMode.""" # PROTECTED REGION ID(SKAObsDevice.test_controlMode) ENABLED START # - assert tango_context.device.controlMode == ControlMode.REMOTE + assert device_under_test.controlMode == ControlMode.REMOTE # PROTECTED REGION END # // SKAObsDevice.test_controlMode # PROTECTED REGION ID(SKAObsDevice.test_simulationMode_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_simulationMode_decorators - def test_simulationMode(self, tango_context): + def test_simulationMode(self, device_under_test): """Test for simulationMode.""" # PROTECTED REGION ID(SKAObsDevice.test_simulationMode) ENABLED START # - assert tango_context.device.simulationMode == SimulationMode.FALSE + assert device_under_test.simulationMode == SimulationMode.FALSE # PROTECTED REGION END # // SKAObsDevice.test_simulationMode # PROTECTED REGION ID(SKAObsDevice.test_testMode_decorators) ENABLED START # # PROTECTED REGION END # // SKAObsDevice.test_testMode_decorators - def test_testMode(self, tango_context): + def test_testMode(self, device_under_test): """Test for testMode.""" # PROTECTED REGION ID(SKAObsDevice.test_testMode) ENABLED START # - assert tango_context.device.testMode == TestMode.NONE + assert device_under_test.testMode == TestMode.NONE # PROTECTED REGION END # // SKAObsDevice.test_testMode diff --git a/tests/test_subarray_device.py b/tests/test_subarray_device.py index 18af1c9332d79893cb365f431f5414b7b5ef05c6..cceb1bdf35344267b3e89fdbe77edfb9571667ed 100644 --- a/tests/test_subarray_device.py +++ b/tests/test_subarray_device.py @@ -72,7 +72,7 @@ class TestSKASubarray: } @pytest.mark.skip(reason="Not implemented") - def test_properties(self, tango_context): + def test_properties(self, device_under_test): """Test device properties.""" # PROTECTED REGION ID(SKASubarray.test_properties) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_properties @@ -80,18 +80,18 @@ class TestSKASubarray: # PROTECTED REGION ID(SKASubarray.test_Abort_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_Abort_decorators - def test_Abort(self, tango_context, tango_change_event_helper): + def test_Abort(self, device_under_test, tango_change_event_helper): """Test for Abort.""" # PROTECTED REGION ID(SKASubarray.test_Abort) ENABLED START # - tango_context.device.On() - tango_context.device.AssignResources(json.dumps(["BAND1"])) - tango_context.device.Configure('{"BAND1": 2}') + device_under_test.On() + device_under_test.AssignResources(json.dumps(["BAND1"])) + device_under_test.Configure('{"BAND1": 2}') obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.READY) - assert tango_context.device.Abort() == [ + assert device_under_test.Abort() == [ [ResultCode.OK], ["Abort command completed OK"], ] @@ -100,89 +100,89 @@ class TestSKASubarray: # PROTECTED REGION ID(SKASubarray.test_Configure_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_Configure_decorators - def test_Configure(self, tango_context, tango_change_event_helper): + def test_Configure(self, device_under_test, tango_change_event_helper): """Test for Configure.""" # PROTECTED REGION ID(SKASubarray.test_Configure) ENABLED START # - tango_context.device.On() - tango_context.device.AssignResources(json.dumps(["BAND1"])) + device_under_test.On() + device_under_test.AssignResources(json.dumps(["BAND1"])) obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.IDLE) - tango_context.device.Configure('{"BAND1": 2}') + device_under_test.Configure('{"BAND1": 2}') obs_state_callback.assert_calls([ObsState.CONFIGURING, ObsState.READY]) - assert tango_context.device.obsState == ObsState.READY - assert tango_context.device.configuredCapabilities == ("BAND1:2", "BAND2:0") + assert device_under_test.obsState == ObsState.READY + assert device_under_test.configuredCapabilities == ("BAND1:2", "BAND2:0") # PROTECTED REGION END # // SKASubarray.test_Configure # PROTECTED REGION ID(SKASubarray.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_GetVersionInfo_decorators - def test_GetVersionInfo(self, tango_context): + def test_GetVersionInfo(self, device_under_test): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKASubarray.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{tango_context.device.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " "A set of generic base devices for SKA Telescope." ) - versionInfo = tango_context.device.GetVersionInfo() + versionInfo = device_under_test.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None # PROTECTED REGION END # // SKASubarray.test_GetVersionInfo # PROTECTED REGION ID(SKASubarray.test_Status_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_Status_decorators - def test_Status(self, tango_context): + def test_Status(self, device_under_test): """Test for Status.""" # PROTECTED REGION ID(SKASubarray.test_Status) ENABLED START # - assert tango_context.device.Status() == "The device is in OFF state." + assert device_under_test.Status() == "The device is in OFF state." # PROTECTED REGION END # // SKASubarray.test_Status # PROTECTED REGION ID(SKASubarray.test_State_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_State_decorators - def test_State(self, tango_context): + def test_State(self, device_under_test): """Test for State.""" # PROTECTED REGION ID(SKASubarray.test_State) ENABLED START # - assert tango_context.device.State() == DevState.OFF + assert device_under_test.State() == DevState.OFF # PROTECTED REGION END # // SKASubarray.test_State # PROTECTED REGION ID(SKASubarray.test_AssignResources_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_AssignResources_decorators - def test_AssignResources(self, tango_context, tango_change_event_helper): + def test_AssignResources(self, device_under_test, tango_change_event_helper): """Test for AssignResources.""" # PROTECTED REGION ID(SKASubarray.test_AssignResources) ENABLED START # - tango_context.device.On() + device_under_test.On() obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.EMPTY) resources_to_assign = ["BAND1", "BAND2"] - tango_context.device.AssignResources(json.dumps(resources_to_assign)) + device_under_test.AssignResources(json.dumps(resources_to_assign)) obs_state_callback.assert_calls([ObsState.RESOURCING, ObsState.IDLE]) - assert tango_context.device.ObsState == ObsState.IDLE - assert list(tango_context.device.assignedResources) == resources_to_assign + assert device_under_test.ObsState == ObsState.IDLE + assert list(device_under_test.assignedResources) == resources_to_assign - tango_context.device.ReleaseAllResources() + device_under_test.ReleaseAllResources() obs_state_callback.assert_calls([ObsState.RESOURCING, ObsState.EMPTY]) - assert tango_context.device.ObsState == ObsState.EMPTY + assert device_under_test.ObsState == ObsState.EMPTY with pytest.raises(DevFailed): - tango_context.device.AssignResources("Invalid JSON") + device_under_test.AssignResources("Invalid JSON") # PROTECTED REGION END # // SKASubarray.test_AssignResources # PROTECTED REGION ID(SKASubarray.test_EndSB_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_EndSB_decorators - def test_End(self, tango_context, tango_change_event_helper): + def test_End(self, device_under_test, tango_change_event_helper): """Test for EndSB.""" # PROTECTED REGION ID(SKASubarray.test_EndSB) ENABLED START # - tango_context.device.On() - tango_context.device.AssignResources(json.dumps(["BAND1"])) - tango_context.device.Configure('{"BAND1": 2}') + device_under_test.On() + device_under_test.AssignResources(json.dumps(["BAND1"])) + device_under_test.Configure('{"BAND1": 2}') obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.READY) - assert tango_context.device.End() == [ + assert device_under_test.End() == [ [ResultCode.OK], ["End command completed OK"], ] @@ -192,18 +192,18 @@ class TestSKASubarray: # PROTECTED REGION ID(SKASubarray.test_EndScan_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_EndScan_decorators - def test_EndScan(self, tango_context, tango_change_event_helper): + def test_EndScan(self, device_under_test, tango_change_event_helper): """Test for EndScan.""" # PROTECTED REGION ID(SKASubarray.test_EndScan) ENABLED START # - tango_context.device.On() - tango_context.device.AssignResources(json.dumps(["BAND1"])) - tango_context.device.Configure('{"BAND1": 2}') - tango_context.device.Scan('{"id": 123}') + device_under_test.On() + device_under_test.AssignResources(json.dumps(["BAND1"])) + device_under_test.Configure('{"BAND1": 2}') + device_under_test.Scan('{"id": 123}') obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.SCANNING) - assert tango_context.device.EndScan() == [ + assert device_under_test.EndScan() == [ [ResultCode.OK], ["EndScan command completed OK"], ] @@ -214,101 +214,100 @@ class TestSKASubarray: # PROTECTED REGION ID(SKASubarray.test_ReleaseAllResources_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_ReleaseAllResources_decorators - def test_ReleaseAllResources(self, tango_context, tango_change_event_helper): + def test_ReleaseAllResources(self, device_under_test, tango_change_event_helper): """Test for ReleaseAllResources.""" # PROTECTED REGION ID(SKASubarray.test_ReleaseAllResources) ENABLED START # - # assert tango_context.device.ReleaseAllResources() == [""] - tango_context.device.On() - tango_context.device.AssignResources(json.dumps(["BAND1", "BAND2"])) + # assert device_under_test.ReleaseAllResources() == [""] + device_under_test.On() + device_under_test.AssignResources(json.dumps(["BAND1", "BAND2"])) obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.IDLE) - tango_context.device.ReleaseAllResources() + device_under_test.ReleaseAllResources() obs_state_callback.assert_calls([ObsState.RESOURCING, ObsState.EMPTY]) - assert tango_context.device.assignedResources is None + assert device_under_test.assignedResources is None # PROTECTED REGION END # // SKASubarray.test_ReleaseAllResources # PROTECTED REGION ID(SKASubarray.test_ReleaseResources_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_ReleaseResources_decorators - def test_ReleaseResources(self, tango_context, tango_change_event_helper): + def test_ReleaseResources(self, device_under_test, tango_change_event_helper): """Test for ReleaseResources.""" # PROTECTED REGION ID(SKASubarray.test_ReleaseResources) ENABLED START # - tango_context.device.On() - tango_context.device.AssignResources(json.dumps(["BAND1", "BAND2"])) + device_under_test.On() + device_under_test.AssignResources(json.dumps(["BAND1", "BAND2"])) obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.IDLE) - tango_context.device.ReleaseResources(json.dumps(["BAND1"])) + device_under_test.ReleaseResources(json.dumps(["BAND1"])) obs_state_callback.assert_calls([ObsState.RESOURCING, ObsState.IDLE]) - assert tango_context.device.ObsState == ObsState.IDLE - assert tango_context.device.assignedResources == ("BAND2",) + assert device_under_test.ObsState == ObsState.IDLE + assert device_under_test.assignedResources == ("BAND2",) # PROTECTED REGION END # // SKASubarray.test_ReleaseResources # PROTECTED REGION ID(SKASubarray.test_Reset_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_Reset_decorators - def test_ObsReset(self, tango_context, tango_change_event_helper): + def test_ObsReset(self, device_under_test, tango_change_event_helper): """Test for Reset.""" # PROTECTED REGION ID(SKASubarray.test_Reset) ENABLED START # - tango_context.device.On() - tango_context.device.AssignResources(json.dumps(["BAND1"])) - tango_context.device.Configure('{"BAND1": 2}') - tango_context.device.Abort() + device_under_test.On() + device_under_test.AssignResources(json.dumps(["BAND1"])) + device_under_test.Configure('{"BAND1": 2}') + device_under_test.Abort() obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.ABORTED) - assert tango_context.device.ObsReset() == [ + assert device_under_test.ObsReset() == [ [ResultCode.OK], ["ObsReset command completed OK"], ] obs_state_callback.assert_calls([ObsState.RESETTING, ObsState.IDLE]) - assert tango_context.device.obsState == ObsState.IDLE + assert device_under_test.obsState == ObsState.IDLE # PROTECTED REGION END # // SKASubarray.test_Reset # PROTECTED REGION ID(SKASubarray.test_Scan_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_Scan_decorators - def test_Scan(self, tango_context, tango_change_event_helper): + def test_Scan(self, device_under_test, tango_change_event_helper): """Test for Scan.""" # PROTECTED REGION ID(SKASubarray.test_Scan) ENABLED START # - tango_context.device.On() - tango_context.device.AssignResources(json.dumps(["BAND1"])) - tango_context.device.Configure('{"BAND1": 2}') + device_under_test.On() + device_under_test.AssignResources(json.dumps(["BAND1"])) + device_under_test.Configure('{"BAND1": 2}') obs_state_callback = tango_change_event_helper.subscribe("obsState") obs_state_callback.assert_call(ObsState.READY) - assert tango_context.device.Scan('{"id": 123}') == [ + assert device_under_test.Scan('{"id": 123}') == [ [ResultCode.STARTED], ["Scan command started"], ] obs_state_callback.assert_call(ObsState.SCANNING) - assert tango_context.device.obsState == ObsState.SCANNING + assert device_under_test.obsState == ObsState.SCANNING - tango_context.device.EndScan() + device_under_test.EndScan() with pytest.raises(DevFailed): - tango_context.device.Scan("Invalid JSON") + device_under_test.Scan("Invalid JSON") # PROTECTED REGION END # // SKASubarray.test_Scan # PROTECTED REGION ID(SKASubarray.test_activationTime_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_activationTime_decorators - def test_activationTime(self, tango_context): + def test_activationTime(self, device_under_test): """Test for activationTime.""" # PROTECTED REGION ID(SKASubarray.test_activationTime) ENABLED START # - assert tango_context.device.activationTime == 0.0 + assert device_under_test.activationTime == 0.0 # PROTECTED REGION END # // SKASubarray.test_activationTime # PROTECTED REGION ID(SKASubarray.test_adminMode_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_adminMode_decorators - def test_adminMode(self, tango_context, tango_change_event_helper): + def test_adminMode(self, device_under_test, tango_change_event_helper): """Test for adminMode.""" # PROTECTED REGION ID(SKASubarray.test_adminMode) ENABLED START # - device_under_test = tango_context.device assert device_under_test.state() == DevState.OFF assert device_under_test.adminMode == AdminMode.ONLINE @@ -317,13 +316,13 @@ class TestSKASubarray: admin_mode_callback.assert_call(AdminMode.ONLINE) op_state_callback.assert_call(DevState.OFF) - tango_context.device.adminMode = AdminMode.OFFLINE + device_under_test.adminMode = AdminMode.OFFLINE assert device_under_test.state() == DevState.DISABLE assert device_under_test.adminMode == AdminMode.OFFLINE admin_mode_callback.assert_call(AdminMode.OFFLINE) op_state_callback.assert_call(DevState.DISABLE) - tango_context.device.adminMode = AdminMode.MAINTENANCE + device_under_test.adminMode = AdminMode.MAINTENANCE assert device_under_test.state() == DevState.OFF assert device_under_test.adminMode == AdminMode.MAINTENANCE admin_mode_callback.assert_call(AdminMode.MAINTENANCE) @@ -332,105 +331,105 @@ class TestSKASubarray: # PROTECTED REGION ID(SKASubarray.test_buildState_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_buildState_decorators - def test_buildState(self, tango_context): + def test_buildState(self, device_under_test): """Test for buildState.""" # PROTECTED REGION ID(SKASubarray.test_buildState) ENABLED START # buildPattern = re.compile( r"ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " r"A set of generic base devices for SKA Telescope" ) - assert (re.match(buildPattern, tango_context.device.buildState)) is not None + assert (re.match(buildPattern, device_under_test.buildState)) is not None # PROTECTED REGION END # // SKASubarray.test_buildState # PROTECTED REGION ID(SKASubarray.test_configurationDelayExpected_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_configurationDelayExpected_decorators - def test_configurationDelayExpected(self, tango_context): + def test_configurationDelayExpected(self, device_under_test): """Test for configurationDelayExpected.""" # PROTECTED REGION ID(SKASubarray.test_configurationDelayExpected) ENABLED START # - assert tango_context.device.configurationDelayExpected == 0 + assert device_under_test.configurationDelayExpected == 0 # PROTECTED REGION END # // SKASubarray.test_configurationDelayExpected # PROTECTED REGION ID(SKASubarray.test_configurationProgress_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_configurationProgress_decorators - def test_configurationProgress(self, tango_context): + def test_configurationProgress(self, device_under_test): """Test for configurationProgress.""" # PROTECTED REGION ID(SKASubarray.test_configurationProgress) ENABLED START # - assert tango_context.device.configurationProgress == 0 + assert device_under_test.configurationProgress == 0 # PROTECTED REGION END # // SKASubarray.test_configurationProgress # PROTECTED REGION ID(SKASubarray.test_controlMode_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_controlMode_decorators - def test_controlMode(self, tango_context): + def test_controlMode(self, device_under_test): """Test for controlMode.""" # PROTECTED REGION ID(SKASubarray.test_controlMode) ENABLED START # - assert tango_context.device.controlMode == ControlMode.REMOTE + assert device_under_test.controlMode == ControlMode.REMOTE # PROTECTED REGION END # // SKASubarray.test_controlMode # PROTECTED REGION ID(SKASubarray.test_healthState_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_healthState_decorators - def test_healthState(self, tango_context): + def test_healthState(self, device_under_test): """Test for healthState.""" # PROTECTED REGION ID(SKASubarray.test_healthState) ENABLED START # - assert tango_context.device.healthState == HealthState.OK + assert device_under_test.healthState == HealthState.OK # PROTECTED REGION END # // SKASubarray.test_healthState # PROTECTED REGION ID(SKASubarray.test_obsMode_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_obsMode_decorators - def test_obsMode(self, tango_context): + def test_obsMode(self, device_under_test): """Test for obsMode.""" # PROTECTED REGION ID(SKASubarray.test_obsMode) ENABLED START # - assert tango_context.device.obsMode == ObsMode.IDLE + assert device_under_test.obsMode == ObsMode.IDLE # PROTECTED REGION END # // SKASubarray.test_obsMode # PROTECTED REGION ID(SKASubarray.test_obsState_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_obsState_decorators - def test_obsState(self, tango_context): + def test_obsState(self, device_under_test): """Test for obsState.""" # PROTECTED REGION ID(SKASubarray.test_obsState) ENABLED START # - assert tango_context.device.obsState == ObsState.EMPTY + assert device_under_test.obsState == ObsState.EMPTY # PROTECTED REGION END # // SKASubarray.test_obsState # PROTECTED REGION ID(SKASubarray.test_simulationMode_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_simulationMode_decorators - def test_simulationMode(self, tango_context): + def test_simulationMode(self, device_under_test): """Test for simulationMode.""" # PROTECTED REGION ID(SKASubarray.test_simulationMode) ENABLED START # - assert tango_context.device.simulationMode == SimulationMode.FALSE + assert device_under_test.simulationMode == SimulationMode.FALSE # PROTECTED REGION END # // SKASubarray.test_simulationMode # PROTECTED REGION ID(SKASubarray.test_testMode_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_testMode_decorators - def test_testMode(self, tango_context): + def test_testMode(self, device_under_test): """Test for testMode.""" # PROTECTED REGION ID(SKASubarray.test_testMode) ENABLED START # - assert tango_context.device.testMode == TestMode.NONE + assert device_under_test.testMode == TestMode.NONE # PROTECTED REGION END # // SKASubarray.test_testMode # PROTECTED REGION ID(SKASubarray.test_versionId_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_versionId_decorators - def test_versionId(self, tango_context): + def test_versionId(self, device_under_test): """Test for versionId.""" # PROTECTED REGION ID(SKASubarray.test_versionId) ENABLED START # versionIdPattern = re.compile(r"[0-9]+.[0-9]+.[0-9]+") - assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None + assert (re.match(versionIdPattern, device_under_test.versionId)) is not None # PROTECTED REGION END # // SKASubarray.test_versionId # PROTECTED REGION ID(SKASubarray.test_assignedResources_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_assignedResources_decorators - def test_assignedResources(self, tango_context): + def test_assignedResources(self, device_under_test): """Test for assignedResources.""" # PROTECTED REGION ID(SKASubarray.test_assignedResources) ENABLED START # - tango_context.device.On() - assert tango_context.device.assignedResources is None + device_under_test.On() + assert device_under_test.assignedResources is None # PROTECTED REGION END # // SKASubarray.test_assignedResources # PROTECTED REGION ID(SKASubarray.test_configuredCapabilities_decorators) ENABLED START # # PROTECTED REGION END # // SKASubarray.test_configuredCapabilities_decorators - def test_configuredCapabilities(self, tango_context): + def test_configuredCapabilities(self, device_under_test): """Test for configuredCapabilities.""" # PROTECTED REGION ID(SKASubarray.test_configuredCapabilities) ENABLED START # - tango_context.device.On() - assert tango_context.device.configuredCapabilities == ("BAND1:0", "BAND2:0") + device_under_test.On() + assert device_under_test.configuredCapabilities == ("BAND1:0", "BAND2:0") # PROTECTED REGION END # // SKASubarray.test_configuredCapabilities diff --git a/tests/test_tel_state_device.py b/tests/test_tel_state_device.py index 4055e81afe851fe1f0dc8d140ca87aa54b28b282..e771eb828a42e213b62db69896780b561e9cdb15 100644 --- a/tests/test_tel_state_device.py +++ b/tests/test_tel_state_device.py @@ -27,7 +27,6 @@ from ska_tango_base.control_model import ( # PROTECTED REGION ID(SKATelState.test_SKATelState_decorators) ENABLED START # -@pytest.mark.usefixtures("tango_context", "initialize_device") # PROTECTED REGION END # // SKATelState.test_SKATelState_decorators class TestSKATelState(object): """Test class for tests of the SKATelState device class.""" @@ -50,7 +49,7 @@ class TestSKATelState(object): } @pytest.mark.skip("Not implemented") - def test_properties(self, tango_context): + def test_properties(self, device_under_test): """Test device properties.""" # PROTECTED REGION ID(SKATelState.test_properties) ENABLED START # # PROTECTED REGION END # // SKATelState.test_properties @@ -58,90 +57,90 @@ class TestSKATelState(object): # PROTECTED REGION ID(SKATelState.test_State_decorators) ENABLED START # # PROTECTED REGION END # // SKATelState.test_State_decorators - def test_State(self, tango_context): + def test_State(self, device_under_test): """Test for State.""" # PROTECTED REGION ID(SKATelState.test_State) ENABLED START # - assert tango_context.device.State() == DevState.OFF + assert device_under_test.State() == DevState.OFF # PROTECTED REGION END # // SKATelState.test_State # PROTECTED REGION ID(SKATelState.test_Status_decorators) ENABLED START # # PROTECTED REGION END # // SKATelState.test_Status_decorators - def test_Status(self, tango_context): + def test_Status(self, device_under_test): """Test for Status.""" # PROTECTED REGION ID(SKATelState.test_Status) ENABLED START # - assert tango_context.device.Status() == "The device is in OFF state." + assert device_under_test.Status() == "The device is in OFF state." # PROTECTED REGION END # // SKATelState.test_Status # PROTECTED REGION ID(SKATelState.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // SKATelState.test_GetVersionInfo_decorators - def test_GetVersionInfo(self, tango_context): + def test_GetVersionInfo(self, device_under_test): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKATelState.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{tango_context.device.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " "A set of generic base devices for SKA Telescope." ) - versionInfo = tango_context.device.GetVersionInfo() + versionInfo = device_under_test.GetVersionInfo() assert (re.match(versionPattern, versionInfo[0])) is not None # PROTECTED REGION END # // SKATelState.test_GetVersionInfo # PROTECTED REGION ID(SKATelState.test_buildState_decorators) ENABLED START # # PROTECTED REGION END # // SKATelState.test_buildState_decorators - def test_buildState(self, tango_context): + def test_buildState(self, device_under_test): """Test for buildState.""" # PROTECTED REGION ID(SKATelState.test_buildState) ENABLED START # buildPattern = re.compile( r"ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " r"A set of generic base devices for SKA Telescope" ) - assert (re.match(buildPattern, tango_context.device.buildState)) is not None + assert (re.match(buildPattern, device_under_test.buildState)) is not None # PROTECTED REGION END # // SKATelState.test_buildState # PROTECTED REGION ID(SKATelState.test_versionId_decorators) ENABLED START # # PROTECTED REGION END # // SKATelState.test_versionId_decorators - def test_versionId(self, tango_context): + def test_versionId(self, device_under_test): """Test for versionId.""" # PROTECTED REGION ID(SKATelState.test_versionId) ENABLED START # versionIdPattern = re.compile(r"[0-9]+.[0-9]+.[0-9]+") - assert (re.match(versionIdPattern, tango_context.device.versionId)) is not None + assert (re.match(versionIdPattern, device_under_test.versionId)) is not None # PROTECTED REGION END # // SKATelState.test_versionId # PROTECTED REGION ID(SKATelState.test_healthState_decorators) ENABLED START # # PROTECTED REGION END # // SKATelState.test_healthState_decorators - def test_healthState(self, tango_context): + def test_healthState(self, device_under_test): """Test for healthState.""" # PROTECTED REGION ID(SKATelState.test_healthState) ENABLED START # - assert tango_context.device.healthState == HealthState.OK + assert device_under_test.healthState == HealthState.OK # PROTECTED REGION END # // SKATelState.test_healthState # PROTECTED REGION ID(SKATelState.test_adminMode_decorators) ENABLED START # # PROTECTED REGION END # // SKATelState.test_adminMode_decorators - def test_adminMode(self, tango_context): + def test_adminMode(self, device_under_test): """Test for adminMode.""" # PROTECTED REGION ID(SKATelState.test_adminMode) ENABLED START # - assert tango_context.device.adminMode == AdminMode.ONLINE + assert device_under_test.adminMode == AdminMode.ONLINE # PROTECTED REGION END # // SKATelState.test_adminMode # PROTECTED REGION ID(SKATelState.test_controlMode_decorators) ENABLED START # # PROTECTED REGION END # // SKATelState.test_controlMode_decorators - def test_controlMode(self, tango_context): + def test_controlMode(self, device_under_test): """Test for controlMode.""" # PROTECTED REGION ID(SKATelState.test_controlMode) ENABLED START # - assert tango_context.device.controlMode == ControlMode.REMOTE + assert device_under_test.controlMode == ControlMode.REMOTE # PROTECTED REGION END # // SKATelState.test_controlMode # PROTECTED REGION ID(SKATelState.test_simulationMode_decorators) ENABLED START # # PROTECTED REGION END # // SKATelState.test_simulationMode_decorators - def test_simulationMode(self, tango_context): + def test_simulationMode(self, device_under_test): """Test for simulationMode.""" # PROTECTED REGION ID(SKATelState.test_simulationMode) ENABLED START # - assert tango_context.device.simulationMode == SimulationMode.FALSE + assert device_under_test.simulationMode == SimulationMode.FALSE # PROTECTED REGION END # // SKATelState.test_simulationMode # PROTECTED REGION ID(SKATelState.test_testMode_decorators) ENABLED START # # PROTECTED REGION END # // SKATelState.test_testMode_decorators - def test_testMode(self, tango_context): + def test_testMode(self, device_under_test): """Test for testMode.""" # PROTECTED REGION ID(SKATelState.test_testMode) ENABLED START # - assert tango_context.device.testMode == TestMode.NONE + assert device_under_test.testMode == TestMode.NONE # PROTECTED REGION END # // SKATelState.test_testMode