summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_vy_device.py42
1 files changed, 36 insertions, 6 deletions
diff --git a/tests/test_vy_device.py b/tests/test_vy_device.py
index b101c1d..84ff0ed 100644
--- a/tests/test_vy_device.py
+++ b/tests/test_vy_device.py
@@ -1,11 +1,12 @@
import sys
import os
import unittest
-from vyapi.device import VyDevice
-from vyapi.device import ApiResponse
+from pyvyos.device import VyDevice
+from pyvyos.device import ApiResponse
from dotenv import load_dotenv
import os
import pprint
+import random, string
load_dotenv()
@@ -25,7 +26,7 @@ class TestVyDevice(unittest.TestCase):
self.device = VyDevice(hostname=hostname, apikey=apikey, port=port, protocol=protocol, verify=verify)
def test_001_retrieve_show_config(self):
- response = self.device.retrieve_show_config(['system'])
+ response = self.device.retrieve_show_config([])
pprint.pprint(response)
self.assertEqual(response.status, 200)
@@ -40,8 +41,14 @@ class TestVyDevice(unittest.TestCase):
self.assertIsNone(response.result)
self.assertFalse(response.error)
+ def test_011_retrieve_return_values(self):
+ response = self.device.retrieve_return_values(path=["interfaces", "dummy", "dum1", "address"])
+ self.assertEqual(response.status, 200)
+ self.assertIsNotNone(response.result)
+ self.assertFalse(response.error)
+ self.assertEqual(response.result, ['192.168.140.1/24'])
- def test_011_configure_delete_interface(self):
+ def test_020_configure_delete_interface(self):
response = self.device.configure_delete(path=["interfaces", "dummy", "dum1"])
pprint.pprint(response)
@@ -49,6 +56,31 @@ class TestVyDevice(unittest.TestCase):
self.assertIsNone(response.result)
self.assertFalse(response.error)
+ def test_050_generate(self):
+ randstring = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(20))
+ keyrand = f'/tmp/key_{randstring}'
+ response = self.device.generate(path=["ssh", "client-key", keyrand])
+ pprint.pprint(response)
+
+ self.assertEqual(response.status, 200)
+ self.assertIsNotNone(response.result)
+ self.assertFalse(response.error)
+
+ def test_100_show(self):
+ response = self.device.show(path=["system", "image"])
+ pprint.pprint(response)
+
+ self.assertEqual(response.status, 200)
+ self.assertIsNotNone(response.result)
+ self.assertFalse(response.error)
+
+ def test_200_reset(self):
+ response = self.device.reset(path=["conntrack-sync", "internal-cache"])
+ pprint.pprint(response)
+
+ self.assertEqual(response.status, 200)
+ self.assertIsNotNone(response.result)
+ self.assertFalse(response.error)
def test_300_config_file_save(self):
response = self.device.config_file_save(file="/config/test300.config")
@@ -76,8 +108,6 @@ class TestVyDevice(unittest.TestCase):
self.assertFalse(response.error)
-
-
def tearDown(self):
pass