Skip to content

Commit

Permalink
Merge 0d6ca53 into 0295992
Browse files Browse the repository at this point in the history
  • Loading branch information
saklar13 committed Apr 2, 2018
2 parents 0295992 + 0d6ca53 commit 35b63fa
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 23 deletions.
21 changes: 11 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
language: python
python:
- '2.7'

before_install:
- pip install -r requirements.txt
- pip install -r test_requirements.txt
- pip install coveralls
- "2.7"

install:
- python setup.py install
- 'if [ ${TRAVIS_BRANCH} \!= "master" ] && [ -f dev_requirements.txt ]; then
pip install --extra-index-url https://testpypi.python.org/pypi -r dev_requirements.txt;
python setup.py develop --no-deps;
else
python setup.py install;
fi'
- pip install -r test_requirements.txt
- pip install coveralls

script:
- python setup.py develop
- nosetests --with-coverage --cover-package=cloudshell
- nosetests --with-coverage --cover-package=cloudshell.networking tests

after_success:
coveralls
- coveralls
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# cloudshell-networking
[![Build Status](https://travis-ci.org/QualiSystems/cloudshell-networking.svg?branch=dev)](https://travis-ci.org/QualiSystems/cloudshell-networking)
[![Coverage Status](https://coveralls.io/repos/github/QualiSystems/cloudshell-networking/badge.svg?branch=dev)](https://coveralls.io/github/QualiSystems/cloudshell-networking?branch=dev)
[![PyPI version](https://badge.fury.io/py/cloudshell-networking.svg)](https://badge.fury.io/py/cloudshell-networking)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def __init__(self, action, result_string):
self.success = True



class ConnectivityErrorResponse(ConnectivityActionResult):
def __init__(self, action, error_string):
ConnectivityActionResult.__init__(self)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ipcalc==1.1.3
jsonpickle==0.9.3
cloudshell-shell-core>=3.1,<3.2
cloudshell-shell-core>=4.0,<4.1
8 changes: 4 additions & 4 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mock==2.0.0
ipcalc==1.1.3
jsonpickle==0.9.3
cloudshell-shell-core>=2.2.217,<2.4
nose
coverage
unittest2
mock
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import unittest

import mock

from cloudshell.networking.apply_connectivity.models.connectivity_result import ConnectivityErrorResponse
from cloudshell.networking.apply_connectivity.models.connectivity_result import ConnectivitySuccessResponse


class TestConnectivitySuccessResponse(unittest.TestCase):
def test_init(self):
"""Check that __init__ nethod will set up object with correct params"""
action = mock.MagicMock()
result_string = "info message"

# act
response = ConnectivitySuccessResponse(action=action, result_string=result_string)

# verify
self.assertEqual(response.type, action.type)
self.assertEqual(response.actionId, action.actionId)
self.assertIsNone(response.errorMessage)
self.assertEqual(response.updatedInterface, action.actionTarget.fullName)
self.assertEqual(response.infoMessage, result_string)
self.assertTrue(response.success)


class TestConnectivityErrorResponse(unittest.TestCase):
def test_init(self):
"""Check that __init__ nethod will set up object with correct params"""
action = mock.MagicMock()
err_string = "error message"

# act
response = ConnectivityErrorResponse(action=action, error_string=err_string)

# verify
self.assertEqual(response.type, action.type)
self.assertEqual(response.actionId, action.actionId)
self.assertIsNone(response.infoMessage)
self.assertEqual(response.updatedInterface, action.actionTarget.fullName)
self.assertEqual(response.errorMessage, err_string)
self.assertFalse(response.success)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from cloudshell.networking.apply_connectivity.models.connectivity_request import ActionTarget, AttributeNameValue, \
ConnectionParams, ConnectivityActionRequest
from cloudshell.networking.apply_connectivity.models.connectivity_result import ConnectivitySuccessResponse
from cloudshell.networking.apply_connectivity.models.connectivity_result import ConnectivityErrorResponse
from cloudshell.networking.apply_connectivity.apply_connectivity_operation import apply_connectivity_changes
from mock import Mock, MagicMock

Expand Down Expand Up @@ -35,7 +36,7 @@ def test_it_delegates_all_add_vlan_calls_to_supplied_callback(self):
result = apply_connectivity_changes(request=request_json,
logger=self.logger,
add_vlan_action=add_vlan_function,
remove_vlan_action= {})
remove_vlan_action={})

# Assert
add_vlan_function.assert_called_once()
Expand Down Expand Up @@ -63,7 +64,7 @@ def test_it_delegates_all_remove_vlan_calls_to_supplied_callback(self):
result = apply_connectivity_changes(request=request_json,
logger=self.logger,
add_vlan_action={},
remove_vlan_action= remove_vlan_function)
remove_vlan_action=remove_vlan_function)

# Assert
remove_vlan_function.assert_called_once()
Expand Down Expand Up @@ -149,7 +150,3 @@ def _stub_remove_vlan_action(full_address='192.1.3.4/1', full_name='rest1/port1'
action.connectorAttributes = []
action.customActionAttributes = []
return action


if __name__ == '__main__':
unittest.main()
16 changes: 16 additions & 0 deletions tests/networking/test_networking_resource_driver_interface.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import unittest

from cloudshell.networking.networking_resource_driver_interface import NetworkingResourceDriverInterface


class TestNetworkingResourceDriverInterface(unittest.TestCase):
def test_abstract_methods(self):
"""Check that instance can't be instantiated without implementation of all abstract methods"""
class TestedClass(NetworkingResourceDriverInterface):
pass

with self.assertRaisesRegexp(TypeError, "Can't instantiate abstract class TestedClass with abstract methods "
"ApplyConnectivityChanges, get_inventory, health_check, load_firmware, "
"orchestration_restore, orchestration_save, restore, "
"run_custom_command, run_custom_config_command, save, shutdown"):
TestedClass()
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
5.1.0

0 comments on commit 35b63fa

Please sign in to comment.