summaryrefslogtreecommitdiff
path: root/scripts/cli/test_service_snmp.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-02-09 13:02:18 +0100
committerChristian Poessinger <christian@poessinger.com>2020-02-09 13:02:18 +0100
commit6c2a6e0153ea36e5690661f0dec634322352f21a (patch)
tree9c49abb8b5e22686ae1e5d528082ccb6b6e2429a /scripts/cli/test_service_snmp.py
parent189b724dd7e5f4a5be4137809376127298bf9d25 (diff)
downloadvyos-1x-6c2a6e0153ea36e5690661f0dec634322352f21a.tar.gz
vyos-1x-6c2a6e0153ea36e5690661f0dec634322352f21a.zip
all: do not import entire module, use "from foo import" instead
Diffstat (limited to 'scripts/cli/test_service_snmp.py')
-rwxr-xr-xscripts/cli/test_service_snmp.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/scripts/cli/test_service_snmp.py b/scripts/cli/test_service_snmp.py
index 04db860f6..5fd5eafcc 100755
--- a/scripts/cli/test_service_snmp.py
+++ b/scripts/cli/test_service_snmp.py
@@ -21,29 +21,30 @@ import unittest
from vyos.validate import is_ipv4
from psutil import process_iter
-import vyos.config
-import vyos.configsession
+from vyos.config import Config
+from vyos.configsession import ConfigSession, ConfigSessionError
import vyos.util as util
SNMPD_CONF = '/etc/snmp/snmpd.conf'
-
base_path = ['service', 'snmp']
def get_config_value(key):
tmp = util.read_file(SNMPD_CONF)
return re.findall(r'\n?{}\s+(.*)'.format(key), tmp)
-class TestSystemNameServer(unittest.TestCase):
+class TestSNMPService(unittest.TestCase):
def setUp(self):
- self.session = vyos.configsession.ConfigSession(os.getpid())
+ self.session = ConfigSession(os.getpid())
env = self.session.get_session_env()
- self.config = vyos.config.Config(session_env=env)
+ self.config = Config(session_env=env)
def tearDown(self):
# Delete SNNP configuration
self.session.delete(base_path)
self.session.commit()
+ del self.session
+
def test_snmp(self):
""" Check if SNMP can be configured and service runs """
clients = ['192.0.2.1', '2001:db8::1']
@@ -82,13 +83,14 @@ class TestSystemNameServer(unittest.TestCase):
# Check for running process
self.assertTrue("snmpd" in (p.name() for p in process_iter()))
+
def test_snmpv3(self):
""" Check if SNMPv3 can be configured and service runs"""
self.session.set(base_path + ['v3', 'engineid', '0xaffedeadbeef'])
self.session.set(base_path + ['v3', 'group', 'default', 'mode', 'ro'])
# check validate() - a view must be created before this can be comitted
- with self.assertRaises(vyos.configsession.ConfigSessionError):
+ with self.assertRaises(ConfigSessionError):
self.session.commit()
self.session.set(base_path + ['v3', 'view', 'default', 'oid', '1'])