Skip to content
Snippets Groups Projects
Commit 0bead608 authored by Taya Snijder's avatar Taya Snijder
Browse files

added new test

parent b99a9a81
No related branches found
No related tags found
1 merge request!288Resolve L2SS-446 "Extend snmp client to support mib files"
...@@ -171,4 +171,28 @@ class TestSNMP(base.TestCase): ...@@ -171,4 +171,28 @@ class TestSNMP(base.TestCase):
checkval = server.val_check(i, server.dim_list[j]) checkval = server.val_check(i, server.dim_list[j])
self.assertEqual(checkval, res_lst, f"During test {j} {i}; Expected: {checkval}, got: {res_lst}") 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)}")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment