diff --git a/tangostationcontrol/tangostationcontrol/test/clients/test_snmp_client.py b/tangostationcontrol/tangostationcontrol/test/clients/test_snmp_client.py index aca28b9588d4856d8a56f3acfde75427385951ef..86a6301f9848f8f81c2d75bf3d0b94adb219310c 100644 --- a/tangostationcontrol/tangostationcontrol/test/clients/test_snmp_client.py +++ b/tangostationcontrol/tangostationcontrol/test/clients/test_snmp_client.py @@ -171,4 +171,28 @@ class TestSNMP(base.TestCase): checkval = server.val_check(i, server.dim_list[j]) self.assertEqual(checkval, res_lst, f"During test {j} {i}; Expected: {checkval}, got: {res_lst}") + @mock.patch('tangostationcontrol.clients.snmp_client.snmp_attribute.next_wrap') + def test_named_value(self, m_next): + # # {1: "other", 2: "invalid", 3: "dynamic", 4: "static",} + # test_val = hlapi.Integer.withNamedValues(enable=1, disable=0) + # test_val(1) + + m_client = mock.Mock() + snmp_attr = snmp_attribute(client=m_client, mib="test", name="test", idx=0, dtype=str, dim_x=1, dim_y=0) + + + # create a named integer with the values: 'enable' for 1 and 'disable' for 0 + test_val = ((None, hlapi.Integer.withNamedValues(enable=1, disable=0)(1)),) + ret_val = snmp_attr.convert(test_val) + + # should return 'enable' since we supplied the value 1 + self.assertEqual(ret_val, "enable", f"Expected: to get 'enable', got: {ret_val} of type {type(ret_val)}") + + + # create an unnamed integer with a value of 2 + test_val = ((None, hlapi.Integer(2)),) + ret_val = snmp_attr.convert(test_val) + + # check to make sure the value is indeed 2 + self.assertEqual(ret_val, 2, f"Expected: to get {2}, got: {ret_val} of type {type(ret_val)}")