From 320b18858be5b1abab14c4c3b55d6ee7a465f43d Mon Sep 17 00:00:00 2001 From: lukken <lukken@astron.nl> Date: Wed, 19 Jan 2022 14:31:34 +0000 Subject: [PATCH] L2SS-575: Test error case --- .../test/devices/test_beam_device.py | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py b/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py index 227253b0a..107f95293 100644 --- a/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py +++ b/tangostationcontrol/tangostationcontrol/test/devices/test_beam_device.py @@ -58,7 +58,7 @@ class TestBeamDevice(base.TestCase): def test_set_pointing_epochs(self): """Verify can set epochs attribute without error""" - with DeviceTestContext(beam.Beam, process=False) as proxy: + with DeviceTestContext(beam.Beam, process=True) as proxy: proxy.init() proxy.Initialise() self.assertEqual(DevState.STANDBY, proxy.state()) @@ -84,14 +84,36 @@ class TestBeamDevice(base.TestCase): compare_obj = data == proxy.read_attribute(attribute).value self.assertTrue(compare_obj.all()) - def test_pointing_direction(self): + def test_direction_pointing(self): """Set and Get test with actual values for pointing attribute""" self.pointing("HBAT_pointing_direction_R", lambda x, y: x.set_direction_pointings(y)) - def test_pointing_epochs(self): + def test_direction_epochs(self): """Set and Get test with actual values for pointing attribute""" self.pointing("HBAT_pointing_epoch_R", lambda x, y: x.set_direction_epochs(y)) + + def test_pointing_invalid(self): + """Test that set pointings command refuses invalid lengths""" + + with DeviceTestContext(beam.Beam, process=True) as proxy: + proxy.init() + proxy.Initialise() + self.assertEqual(DevState.STANDBY, proxy.state()) + + # should return error due to invalid length + self.assertEqual(-1, proxy.set_direction_pointings(numpy.zeros(55))) + + def test_epoch_invalid(self): + """Test that set epochs command refuses invalid lengths""" + + with DeviceTestContext(beam.Beam, process=True) as proxy: + proxy.init() + proxy.Initialise() + self.assertEqual(DevState.STANDBY, proxy.state()) + + # should return error due to invalid length + self.assertEqual(-1, proxy.set_direction_epochs(numpy.zeros(55))) -- GitLab