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

changes

parent d6eac54d
No related branches found
No related tags found
1 merge request!427Resolve L2SS-874 "Mib loading test"
...@@ -238,7 +238,7 @@ class snmp_attribute: ...@@ -238,7 +238,7 @@ class snmp_attribute:
elif needs_conversion_from_integer_to_str(value): elif needs_conversion_from_integer_to_str(value):
result = convert_integer_to_str(value) result = convert_integer_to_str(value)
elif needs_conversion_from_number_to_int64(value): elif needs_conversion_from_number_to_int64(value):
result = numpy.int64(value) * self.scaling_factor result = numpy.int64(value) * self.scaling_factor
elif needs_conversion_from_string_to_str(value): elif needs_conversion_from_string_to_str(value):
result = str(value) result = str(value)
else: else:
......
from tangostationcontrol.test import base from tangostationcontrol.test import base
# from tangostationcontrol.clients.snmp_client import mib_loader from tangostationcontrol.clients.snmp_client import mib_loader
# from pysnmp.smi import view from pysnmp.smi import view
# import pysnmp.hlapi as pysnmp import pysnmp.hlapi as pysnmp
# from pysnmp.smi.rfc1902 import ObjectIdentity from pysnmp.smi.rfc1902 import ObjectIdentity
#
# from os import path from os import path
class TestMibLoading(base.TestCase): class TestMibLoading(base.TestCase):
...@@ -17,40 +17,54 @@ class TestMibLoading(base.TestCase): ...@@ -17,40 +17,54 @@ class TestMibLoading(base.TestCase):
REL_DIR = "SNMP_mib_loading" REL_DIR = "SNMP_mib_loading"
def test_content(self): def test_content(self):
return
"""
# """ This file contains a 1 variable named: testNamedValue with oid "9.8.7.6.5.4.3.2.1" with named values: ("A", 1), ("B", 2), ("C", 3), ("D", 4)
# This file contains a 1 variable named: testNamedValue with oid "9.8.7.6.5.4.3.2.1" with named values: ("A", 1), ("B", 2), ("C", 3), ("D", 4) In order to confirm that the mib is indeed loaded correctly this test has to get the oids, the values and the named values
# In order to confirm that the mib is indeed loaded correctly this test has to get the oids, the values and the named values
# """
# """
# abs_dir = path.dirname(__file__) + "/" + self.REL_DIR
# # abs_dir = path.dirname(__file__) + "/" + self.REL_DIR abs_dir = "test/clients/SNMP_mib_loading/TEST-MIB.mib"
# abs_dir = "test/clients/SNMP_mib_loading/TEST-MIB.mib" loader = mib_loader(abs_dir)
# loader = mib_loader(abs_dir)
# loader.load_pymib(self.MIB) iterator = pysnmp.getCmd(
# pysnmp.SnmpEngine(),
# # used to view mibs client side pysnmp.CommunityData('public', mpModel=1),
# mibView = view.MibViewController(loader.mibBuilder) pysnmp.UdpTransportTarget(('127.0.0.1', 161)),
# pysnmp.ContextData(),
# # The expected testNamedValue parameters as written in TEST-MIB.py pysnmp.ObjectType(ObjectIdentity('TEST-MIB', 'testNamedValue', 1))
# testNamedValue = "testNamedValue" )
# testNamedValue_oid = "9.8.7.6.5.4.3.2.1"
# testNamedValue_named = "A" try:
# testNamedValue_value = 1 next(iterator)
# except:
# # get testValue and set a value of 1 pass
# obj_T = pysnmp.ObjectType(ObjectIdentity(self.MIB, testNamedValue), pysnmp.Integer32(1))
# obj_T.resolveWithMib(mibView) loader.load_pymib(self.MIB)
#
# # get the oid
# self.assertEqual(str(obj_T[0]), testNamedValue_oid) # used to view mibs client side
# mibView = view.MibViewController(loader.mibBuilder)
# # get the name format: mib::name
# self.assertEqual(obj_T[0].prettyPrint(), f"{self.MIB}::{testNamedValue}") # The expected testNamedValue parameters as written in TEST-MIB.py
# testNamedValue = "testNamedValue"
# # get the namedValue testNamedValue_oid = "9.8.7.6.5.4.3.2.1"
# self.assertEqual(str(obj_T[1]), testNamedValue_named) testNamedValue_named = "A"
# testNamedValue_value = 1
# # get the numerical value
# self.assertEqual(int(obj_T[1]), testNamedValue_value) # get testValue and set a value of 1
obj_T = pysnmp.ObjectType(ObjectIdentity(self.MIB, testNamedValue), pysnmp.Integer32(1))
obj_T.resolveWithMib(mibView)
# get the oid
self.assertEqual(str(obj_T[0]), testNamedValue_oid)
# get the name format: mib::name
self.assertEqual(obj_T[0].prettyPrint(), f"{self.MIB}::{testNamedValue}")
# get the namedValue
self.assertEqual(str(obj_T[1]), testNamedValue_named)
# get the numerical value
self.assertEqual(int(obj_T[1]), testNamedValue_value)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment