diff options
Diffstat (limited to 'test/mocks/netconf-pnp-simulator/engine/tests/nctest.py')
-rw-r--r-- | test/mocks/netconf-pnp-simulator/engine/tests/nctest.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/mocks/netconf-pnp-simulator/engine/tests/nctest.py b/test/mocks/netconf-pnp-simulator/engine/tests/nctest.py new file mode 100644 index 000000000..2f848c361 --- /dev/null +++ b/test/mocks/netconf-pnp-simulator/engine/tests/nctest.py @@ -0,0 +1,37 @@ +from ncclient import manager, operations +import settings +import unittest + +class NCTestCase(unittest.TestCase): + """ Base class for NETCONF test cases. Provides a NETCONF connection and some helper methods. """ + + def setUp(self): + self.nc = manager.connect( + host=settings.HOST, + port=settings.PORT, + username=settings.USERNAME, + key_filename=settings.KEY_FILENAME, + allow_agent=False, + look_for_keys=False, + hostkey_verify=False) + self.nc.raise_mode = operations.RaiseMode.NONE + + def tearDown(self): + self.nc.close_session() + + def check_reply_ok(self, reply): + self.assertIsNotNone(reply) + if settings.DEBUG: + print(reply.xml) + self.assertTrue(reply.ok) + self.assertIsNone(reply.error) + + def check_reply_err(self, reply): + self.assertIsNotNone(reply) + if settings.DEBUG: + print(reply.xml) + self.assertFalse(reply.ok) + self.assertIsNotNone(reply.error) + + def check_reply_data(self, reply): + self.check_reply_ok(reply) |