Skip to content

Commit

Permalink
fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vvb committed Aug 11, 2023
1 parent ac3ea4d commit c77acc6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 54 deletions.
4 changes: 2 additions & 2 deletions tests/common/test_ucstoxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TestUCStoXML(unittest.TestCase):
def test_001_mo_to_xml(self):
from ucsmsdk.mometa.fabric.FabricVsan import FabricVsan

expected = b'<fabricVsan dn="org-root/net-test" name="test" status="modified" />'
expected = b'<fabricVsan name="test" status="modified" dn="org-root/net-test" />'

mo = FabricVsan("org-root", "test")
mo.status = "modified"
Expand Down Expand Up @@ -65,6 +65,6 @@ def test_001_mo_heirarchy_to_xml(self):

response = xc.from_xml_str(response_str)

expected = b'<memoryUnitEnvStatsHist1 childAction="deleteNonPresent" dn="sys/chassis-1/blade-2/board/memarray-1/mem-9/dimm-env-stats/1" id="1" mostRecent="no" rn="1" suspect="no" temperature="28.000000" temperatureAvg="25.599997" temperatureMax="28.000000" temperatureMin="24.000000" thresholded="" timeCollected="2015-09-07T09:43:53.262"><memoryUnitEnvStatsHist2 childAction="deleteNonPresent" dn="sys/chassis-1/blade-2/board/memarray-1/mem-9/dimm-env-stats/1/1" id="1" mostRecent="no" rn="1" suspect="no" temperature="28.000000" temperatureAvg="25.599997" temperatureMax="28.000000" temperatureMin="24.000000" thresholded="" timeCollected="2015-09-07T09:43:53.262" /></memoryUnitEnvStatsHist1>'
expected = b'<memoryUnitEnvStatsHist1 childAction="deleteNonPresent" id="1" mostRecent="no" rn="1" suspect="no" temperature="28.000000" temperatureAvg="25.599997" temperatureMax="28.000000" temperatureMin="24.000000" thresholded="" timeCollected="2015-09-07T09:43:53.262" dn="sys/chassis-1/blade-2/board/memarray-1/mem-9/dimm-env-stats/1"><memoryUnitEnvStatsHist2 rn="1" dn="sys/chassis-1/blade-2/board/memarray-1/mem-9/dimm-env-stats/1/1" childAction="deleteNonPresent" id="1" mostRecent="no" suspect="no" temperature="28.000000" temperatureAvg="25.599997" temperatureMax="28.000000" temperatureMin="24.000000" thresholded="" timeCollected="2015-09-07T09:43:53.262" /></memoryUnitEnvStatsHist1>'
obj = response.out_configs.child[0].child[0].child[0]
self.assertEqual(xc.to_xml_str(obj.to_xml()), expected)
98 changes: 49 additions & 49 deletions tests/common/test_unknown_props.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
# 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.

import unittest

import ucsmsdk.ucsxmlcodec as xc
from ucsmsdk.ucscoremeta import WriteXmlOption


class TestUnknownProps(unittest.TestCase):
def test_001_knownmo_unknownprop(self):
xml_str = '''
<lsServer agentPolicyName=""
name="ra11"
type="instance"
usrLbl="b"
rn = "ls-ra11"
unknownProps="unknown"/>'''

obj = xc.from_xml_str(xml_str)
obj.unknownProps = "known"
xml_element = obj.to_xml()
expected = b'<lsServer agentPolicyName="" dn="ls-ra11" name="ra11" type="instance" unknownProps="known" usrLbl="b" />'
result_str = xc.to_xml_str(xml_element)
self.assertEqual(result_str, expected)

def test_002_knownmo_unknownprop(self):
xml_str = '''
<lsServer agentPolicyName=""
name="ra11"
type="instance"
usrLbl="b"
rn = "ls-ra11"
unknownProps="unknown"/>'''
obj = xc.from_xml_str(xml_str)
obj.unknownProps = "known"
xml_element = obj.to_xml(option=WriteXmlOption.DIRTY)
print(xc.to_xml_str(xml_element))
# 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.

import unittest

import ucsmsdk.ucsxmlcodec as xc
from ucsmsdk.ucscoremeta import WriteXmlOption


class TestUnknownProps(unittest.TestCase):
def test_001_knownmo_unknownprop(self):
xml_str = '''
<lsServer agentPolicyName=""
name="ra11"
type="instance"
usrLbl="b"
rn = "ls-ra11"
unknownProps="unknown"/>'''

obj = xc.from_xml_str(xml_str)
obj.unknownProps = "known"
xml_element = obj.to_xml()
expected = b'<lsServer name="ra11" agentPolicyName="" type="instance" usrLbl="b" unknownProps="known" dn="ls-ra11" />'
result_str = xc.to_xml_str(xml_element)
self.assertEqual(result_str, expected)

def test_002_knownmo_unknownprop(self):
xml_str = '''
<lsServer agentPolicyName=""
name="ra11"
type="instance"
usrLbl="b"
rn = "ls-ra11"
unknownProps="unknown"/>'''

obj = xc.from_xml_str(xml_str)
obj.unknownProps = "known"
xml_element = obj.to_xml(option=WriteXmlOption.DIRTY)
print(xc.to_xml_str(xml_element))
6 changes: 3 additions & 3 deletions tests/generic_mo/test_ucsgmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_002_create_gmo_using_param_dict(self):
elem = obj.to_xml()
xml_str = xc.to_xml_str(elem)

expected = b'<testLsA a="1" b="2" c="3" dn="" rn=""><testLsB a="1" b="2" c="3" dn="" rn="" /></testLsA>'
expected = b'<testLsA a="1" b="2" c="3" rn="" dn=""><testLsB a="1" b="2" c="3" rn="" dn="" /></testLsA>'

self.assertEqual(xml_str, expected)

Expand All @@ -49,7 +49,7 @@ def test_003_create_gmo_using_param_dict(self):
elem = obj.to_xml()
xml_str = xc.to_xml_str(elem)

expected = b'<testLsA a="1" b="2" c="3" dn="org-root/parent" rn="parent"><testLsB dn="org-root/parent/child" rn="child" /></testLsA>'
expected = b'<testLsA a="1" b="2" c="3" rn="parent" dn="org-root/parent"><testLsB rn="child" dn="org-root/parent/child" /></testLsA>'

self.assertEqual(xml_str, expected)

Expand All @@ -60,7 +60,7 @@ def test_004_create_gmo_using_parent_mo(self):
elem = obj.to_xml()
xml_str = xc.to_xml_str(elem)

expected = b'<testLsA a="1" b="2" c="3" dn="org-root/parent" rn="parent"><testLsB dn="org-root/parent/child" rn="child" /></testLsA>'
expected = b'<testLsA a="1" b="2" c="3" rn="parent" dn="org-root/parent"><testLsB rn="child" dn="org-root/parent/child" /></testLsA>'

self.assertEqual(xml_str, expected)

Expand Down

0 comments on commit c77acc6

Please sign in to comment.