# Copyright 2015 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 nose.tools import * from ..connection.info import custom_setup, custom_teardown import ucsmsdk.ucsxmlcodec as xc import ucsmsdk.ucsmo as ucsmo handle = None fault_inst_xml_str=''' ''' def setup(): pass # global handle # handle = custom_setup() def teardown(): pass # custom_teardown(handle) def test_001_create_gmo_from_xml(): xml = ''' ''' obj = xc.from_xml_str(xml) assert_equal(obj.__class__.__name__, 'GenericMo') def test_002_create_gmo_using_param_dict(): args = {"a": 1, "b": 2, "c":3} obj = ucsmo.GenericMo("testLsA", "org-root", **args) obj1 = ucsmo.GenericMo("testLsB", "org-root", **args) obj.child_add(obj1) elem = obj.to_xml() xml_str = xc.to_xml_str(elem) expected = b'' assert_equal(xml_str, expected) def test_003_create_gmo_using_param_dict(): args = {"a": 1, "b": 2, "c":3, "rn": "parent"} obj = ucsmo.GenericMo("testLsA", "org-root", **args) obj1 = ucsmo.GenericMo("testLsB", obj.dn, rn="child") obj.child_add(obj1) elem = obj.to_xml() xml_str = xc.to_xml_str(elem) expected = b'' assert_equal(xml_str, expected) def test_004_create_gmo_using_parent_mo(): args = {"a": 1, "b": 2, "c":3, "rn": "parent"} obj = ucsmo.GenericMo("testLsA", "org-root", **args) obj1 = ucsmo.GenericMo("testLsB", obj, rn="child") elem = obj.to_xml() xml_str = xc.to_xml_str(elem) expected = b'' assert_equal(xml_str, expected) def test_005_create_gmo_from_xml(): xml_str = ''' ''' gmo = ucsmo.generic_mo_from_xml(xml_str) xml_element = gmo.to_xml() to_xml_str = xc.to_xml_str(xml_element) def test_006_gmo_to_mo(): xml_str = ''' ''' gmo = ucsmo.generic_mo_from_xml(xml_str) mo = gmo.to_mo() assert_equal(mo.code, "F35275")