Skip to content

Commit

Permalink
Included junit test case for connect exception and plugin was updated…
Browse files Browse the repository at this point in the history
… accordingly
  • Loading branch information
Malinoski committed Oct 27, 2020
1 parent a1ac883 commit 5167356
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion networkapi/plugins/Juniper/JUNOS/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def connect(self):

except ConnectError as e:
log.error("Could not connect to Juniper host {}: {}".format(self.equipment_access.fqdn, e))
raise ConnectError
raise ConnectError(e)

except Exception, e:
log.error("Unknown error while connecting to host {}: {}".format(self.equipment_access.fqdn, e))
Expand Down
12 changes: 11 additions & 1 deletion networkapi/plugins/Juniper/JUNOS/tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from networkapi.test.test_case import NetworkApiTestCase
from networkapi.plugins.base import BasePlugin
from networkapi.plugins.Juniper.JUNOS.plugin import JUNOS
import mock
from mock import patch, MagicMock
from jnpr.junos.exception import ConnectError, LockError


class JunosPluginTest(NetworkApiTestCase):
Expand Down Expand Up @@ -64,6 +64,16 @@ def test_connect_success(self, mock_device):
self.assertIsNotNone(plugin.configuration)
self.assertEqual(connection_response, True)

def test_connect_wrong_data_exception(self):

"""
test_connect_wrong_data_exception
"""

plugin = JUNOS(equipment_access=self.mock_equipment_access)
with self.assertRaises(ConnectError):
plugin.connect()

@patch('jnpr.junos.utils.config.Config')
def test_exec_command_success(self, mock_config):

Expand Down

0 comments on commit 5167356

Please sign in to comment.