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

added test

parent bc77b4a8
No related branches found
No related tags found
1 merge request!288Resolve L2SS-446 "Extend snmp client to support mib files"
# -*- coding: utf-8 -*-
#
# This file is part of the LOFAR 2.0 Station Software
#
#
#
# Distributed under the terms of the APACHE license.
# See LICENSE.txt for more info.
from tangostationcontrol.test import base
import tangostationcontrol.toolkit.mib_compiler as mib_compiler
import sys
from os.path import isfile
from tempfile import TemporaryDirectory
from unittest import mock
class TestCompiler(base.TestCase):
def test_compile(self):
with TemporaryDirectory() as tmpdir:
new_sys_argv = [sys.argv[0], "--mibs", "TEST-MIB",
"--source", "/opt/lofar/tango/tangostationcontrol/tangostationcontrol/toolkit/mib_compiler/mibs",
"http://www.net-snmp.org/docs/mibs/",
"--destination", f"{tmpdir}"]
with mock.patch.object(mib_compiler.sys, 'argv', new_sys_argv):
with self.assertRaises(SystemExit):
mib_compiler.main()
# check if file was written
self.assertTrue(isfile(f"{tmpdir}/TEST-MIB.py"))
\ No newline at end of file
......@@ -27,8 +27,7 @@ def mib_compile(mib_list : list, src, dst):
raise Exception(f"Something went wrong, try checking whether all the mib fills imported by the provided mib files are present (To do this enable debug options and scroll up) ") from e
if __name__ == "__main__":
def main():
abs_path = str(Path().absolute()).replace("\\", "/")
out_path = f"{abs_path}/output_pymibs"
in_path = f"{abs_path}/mibs"
......@@ -62,3 +61,6 @@ if __name__ == "__main__":
mib_compile(mib_list=mibs, src=source, dst=destination)
if __name__ == "__main__":
main()
\ No newline at end of file
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