Add update method in EthernetSwitchStaticMAC in RSD 2.1
Change-Id: I04790902566a6456b6d95089eca1d8a2925d73b6
This commit is contained in:
@@ -15,10 +15,11 @@
|
||||
|
||||
import json
|
||||
import jsonschema
|
||||
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
from sushy import exceptions
|
||||
|
||||
from rsd_lib.resources.v2_1.ethernet_switch import ethernet_switch_static_mac
|
||||
from rsd_lib.tests.unit.fakes import request_fakes
|
||||
|
||||
@@ -52,6 +53,39 @@ class EthernetSwitchStaticMACTestCase(testtools.TestCase):
|
||||
self.assertEqual("00:11:22:33:44:55", self.static_mac_inst.mac_address)
|
||||
self.assertEqual(112, self.static_mac_inst.vlan_id)
|
||||
|
||||
def test_update(self):
|
||||
reqs = {"MACAddress": "00:11:22:33:44:55"}
|
||||
self.static_mac_inst.update("00:11:22:33:44:55")
|
||||
self.static_mac_inst._conn.patch.assert_called_once_with(
|
||||
"/redfish/v1/EthernetSwitches/Switch1/Ports/StaticMACs/1",
|
||||
data=reqs,
|
||||
)
|
||||
|
||||
self.static_mac_inst._conn.patch.reset_mock()
|
||||
reqs = {"MACAddress": "00:11:22:33:44:55", "VLANId": 69}
|
||||
self.static_mac_inst.update(
|
||||
"00:11:22:33:44:55", vlan_id=69
|
||||
)
|
||||
self.static_mac_inst._conn.patch.assert_called_once_with(
|
||||
"/redfish/v1/EthernetSwitches/Switch1/Ports/StaticMACs/1",
|
||||
data=reqs,
|
||||
)
|
||||
|
||||
def test_update_invalid_reqs(self):
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.InvalidParameterValueError,
|
||||
('The parameter "mac_address" value "True" is invalid'),
|
||||
):
|
||||
self.static_mac_inst.update(True)
|
||||
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.InvalidParameterValueError,
|
||||
('The parameter "vlan_id" value "invalid-value" is invalid'),
|
||||
):
|
||||
self.static_mac_inst.update(
|
||||
"00:11:22:33:44:55", vlan_id="invalid-value"
|
||||
)
|
||||
|
||||
def test_delete(self):
|
||||
self.static_mac_inst.delete()
|
||||
self.static_mac_inst._conn.delete.assert_called_once_with(
|
||||
|
||||
Reference in New Issue
Block a user