Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
*.py[cod]

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
var
sdist
develop-eggs
.installed.cfg
lib
lib64

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml
htmlcov

# Translations
*.mo

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Complexity
output/*.html
output/*/index.html

# Sphinx
docs/_build

# Idea IDE
.idea/*

.DS_Store
tags
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Contributors
------------

* Ryan England <ryan.england@peak10.com>
* Britt Houser <bhouser@cisco.com>
3 changes: 2 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ flake8==2.4.1
tox==2.1.1
coverage==4.0
Sphinx==1.3.1

nose==1.3.7
mock==2.0.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
]

test_requirements = [
# TODO: put package test requirements here
'nose'
]

setup(
Expand Down Expand Up @@ -49,7 +49,7 @@
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
],
test_suite='tests',
test_suite='nose.collector',
tests_require=test_requirements,
extras_require={
'docs': ['sphinx<1.3', 'sphinxcontrib-napoleon',
Expand Down
2 changes: 0 additions & 2 deletions tests/test_ucsmsdk_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import unittest

from ucsmsdk_samples import ucsmsdk_samples


class TestUcsmsdk_samples(unittest.TestCase):

Expand Down
37 changes: 37 additions & 0 deletions tests/unit_tests/test_chassis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright 2017 Cisco Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


from mock import patch
from ucsmsdk.ucshandle import UcsHandle
from ucsmsdk_samples.server.chassis import chassis_acknowledge
from ucsmsdk.mometa.equipment.EquipmentChassis import EquipmentChassis


# Patch UcsHandle.commit to simulate ucsm interaction w/o real ucsm
@patch.object(UcsHandle, 'commit')
# Patch UcsHandle.add_mo to simulate ucsm interaction w/o real ucsm
@patch.object(UcsHandle, 'add_mo')
def test_valid_chassis_acknowledge(add_mo_mock, commit_mock):
add_mo_mock.return_value = True
commit_mock.return_value = True
handle = UcsHandle('169.254.1.1', 'admin', 'password')

# Scenario: Chassis 1
chassis_retval = chassis_acknowledge(handle, 1)
# Verify we were passed back the correct object type
assert isinstance(chassis_retval, EquipmentChassis)
# Verify the id we requested was assigned correctly
assert chassis_retval.id == "1"
# Verify the state we requested is "re-acknowledge"
assert chassis_retval.admin_state == "re-acknowledge"
93 changes: 93 additions & 0 deletions tests/unit_tests/test_network.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright 2016 Cisco Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from mock import patch
from ucsmsdk.ucshandle import UcsHandle
from ucsmsdk_samples.network.uplink_port import uplink_port_create
from ucsmsdk_samples.network.server_port import server_port_create


@patch.object(UcsHandle, 'commit')
@patch.object(UcsHandle, 'add_mo')
def test_valid_uplink_port_create(add_mo_mock, commit_mock):
# Patch UcsHandle.add_mo to simulate CIMC interaction w/o real CIMC
# Patch UcsHandle.commit to simulate CIMC interaction w/o real CIMC
add_mo_mock.return_value = True
commit_mock.return_value = True
handle = UcsHandle('169.254.1.1', 'admin', 'password')

# Scenario: Set Fabric-A port Eth1/10 to uplink port
fabric_dn = 'fabric/lan/A'
port_id = '10'
slot_id = '1'
uplink_port_create(handle, fabric_dn, port_id, slot_id)

# Assert values of the object passed to add_mo()
test_uplink_mo = add_mo_mock.call_args[0][0]
assert test_uplink_mo.port_id == "10"
assert test_uplink_mo.slot_id == "1"
assert test_uplink_mo.dn == '{0}/phys-slot-{1}-port-{2}'.format(fabric_dn,
slot_id,
port_id)

# Scenario: Set Fabric-B port Eth2/6 to uplink port
fabric_dn = 'fabric/lan/B'
port_id = '6'
slot_id = '2'
uplink_port_create(handle, fabric_dn, port_id, slot_id)

# Assert values of the object passed to add_mo()
test_uplink_mo = add_mo_mock.call_args[0][0]
assert test_uplink_mo.port_id == "6"
assert test_uplink_mo.slot_id == "2"
assert test_uplink_mo.dn == '{0}/phys-slot-{1}-port-{2}'.format(fabric_dn,
slot_id,
port_id)


@patch.object(UcsHandle, 'commit')
@patch.object(UcsHandle, 'add_mo')
def test_valid_server_port_create(add_mo_mock, commit_mock):
# Patch UcsHandle.add_mo to simulate CIMC interaction w/o real CIMC
# Patch UcsHandle.commit to simulate CIMC interaction w/o real CIMC
add_mo_mock.return_value = True
commit_mock.return_value = True
handle = UcsHandle('169.254.1.1', 'admin', 'password')

# Scenario: Set Fabric-A port Eth1/10 to server port
fabric_dn = 'fabric/lan/A'
port_id = '10'
slot_id = '1'
server_port_create(handle, fabric_dn, port_id, slot_id)

# Assert values of the object passed to add_mo()
test_server_mo = add_mo_mock.call_args[0][0]
assert test_server_mo.port_id == "10"
assert test_server_mo.slot_id == "1"
assert test_server_mo.dn == '{0}/slot-{1}-port-{2}'.format(fabric_dn,
slot_id,
port_id)

# Scenario: Set Fabric-B port Eth2/6 to server port
fabric_dn = 'fabric/lan/B'
port_id = '6'
slot_id = '2'
server_port_create(handle, fabric_dn, port_id, slot_id)

# Assert values of the object passed to add_mo()
test_server_mo = add_mo_mock.call_args[0][0]
assert test_server_mo.port_id == "6"
assert test_server_mo.slot_id == "2"
assert test_server_mo.dn == '{0}/slot-{1}-port-{2}'.format(fabric_dn,
slot_id,
port_id)
Loading