Merge "Add update service for RSD2.2"
This commit is contained in:
commit
c487703cf1
@ -21,6 +21,7 @@ from rsd_lib.resources.v2_2.manager import manager
|
|||||||
from rsd_lib.resources.v2_2.node import node
|
from rsd_lib.resources.v2_2.node import node
|
||||||
from rsd_lib.resources.v2_2.system import system
|
from rsd_lib.resources.v2_2.system import system
|
||||||
from rsd_lib.resources.v2_2.telemetry import telemetry
|
from rsd_lib.resources.v2_2.telemetry import telemetry
|
||||||
|
from rsd_lib.resources.v2_2.update_service import update_service
|
||||||
|
|
||||||
|
|
||||||
class RSDLibV2_2(v2_1.RSDLibV2_1):
|
class RSDLibV2_2(v2_1.RSDLibV2_1):
|
||||||
@ -41,6 +42,10 @@ class RSDLibV2_2(v2_1.RSDLibV2_1):
|
|||||||
required=True)
|
required=True)
|
||||||
"""Telemetry Service path"""
|
"""Telemetry Service path"""
|
||||||
|
|
||||||
|
_update_service_path = base.Field(['UpdateService', '@odata.id'],
|
||||||
|
required=True)
|
||||||
|
"""Update Service path"""
|
||||||
|
|
||||||
def get_system(self, identity):
|
def get_system(self, identity):
|
||||||
"""Given the identity return a System object
|
"""Given the identity return a System object
|
||||||
|
|
||||||
@ -123,3 +128,12 @@ class RSDLibV2_2(v2_1.RSDLibV2_1):
|
|||||||
return manager.Manager(self._conn,
|
return manager.Manager(self._conn,
|
||||||
identity,
|
identity,
|
||||||
redfish_version=self.redfish_version)
|
redfish_version=self.redfish_version)
|
||||||
|
|
||||||
|
def get_update_service(self):
|
||||||
|
"""Get a UpdateService object
|
||||||
|
|
||||||
|
:returns: The UpdateService object
|
||||||
|
"""
|
||||||
|
return update_service.UpdateService(
|
||||||
|
self._conn, self._update_service_path,
|
||||||
|
redfish_version=self.redfish_version)
|
||||||
|
0
rsd_lib/resources/v2_2/update_service/__init__.py
Normal file
0
rsd_lib/resources/v2_2/update_service/__init__.py
Normal file
57
rsd_lib/resources/v2_2/update_service/action_info.py
Normal file
57
rsd_lib/resources/v2_2/update_service/action_info.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# Copyright 2019 Intel, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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 sushy.resources import base
|
||||||
|
from sushy import utils
|
||||||
|
|
||||||
|
NAME_MAPPING = {
|
||||||
|
"Name": "name",
|
||||||
|
"Required": "required",
|
||||||
|
"DataType": "data_type",
|
||||||
|
"AllowableValues": "allowable_values"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class ActionInfo(base.ResourceBase):
|
||||||
|
oem = base.Field("Oem")
|
||||||
|
"""The action info oem"""
|
||||||
|
|
||||||
|
def __init__(self, connector, identity, redfish_version=None):
|
||||||
|
"""A class representing a ActionInfo
|
||||||
|
|
||||||
|
:param connector: A Connector instance
|
||||||
|
:param identity: The identity of the ActionInfo resource
|
||||||
|
:param redfish_version: The version of RedFish. Used to construct
|
||||||
|
the object according to schema of the given version.
|
||||||
|
"""
|
||||||
|
super(ActionInfo, self).__init__(
|
||||||
|
connector, identity, redfish_version)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@utils.cache_it
|
||||||
|
def parameters(self):
|
||||||
|
"""Property to provide reference to `ActionInfo` instance
|
||||||
|
|
||||||
|
It is calculated once when it is queried for the first time. On
|
||||||
|
refresh, this property is reset.
|
||||||
|
"""
|
||||||
|
parameters = []
|
||||||
|
for i in self.json.get('Parameters'):
|
||||||
|
item = {}
|
||||||
|
for key in i.keys():
|
||||||
|
item[NAME_MAPPING[key]] = i.get(key, None)
|
||||||
|
parameters.append(item)
|
||||||
|
|
||||||
|
return parameters
|
95
rsd_lib/resources/v2_2/update_service/update_service.py
Normal file
95
rsd_lib/resources/v2_2/update_service/update_service.py
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
# Copyright 2019 Intel, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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 rsd_lib.resources.v2_2.update_service import action_info
|
||||||
|
from rsd_lib import utils as rsd_lib_utils
|
||||||
|
from sushy.resources import base
|
||||||
|
from sushy import utils
|
||||||
|
|
||||||
|
|
||||||
|
class StatusField(base.CompositeField):
|
||||||
|
state = base.Field("State")
|
||||||
|
"""The status state"""
|
||||||
|
|
||||||
|
health = base.Field("Health", adapter=rsd_lib_utils.num_or_none)
|
||||||
|
"""The status health"""
|
||||||
|
|
||||||
|
health_rollup = base.Field("HealthRollup",
|
||||||
|
adapter=rsd_lib_utils.num_or_none)
|
||||||
|
"""The status health rollup"""
|
||||||
|
|
||||||
|
|
||||||
|
class SimpleUpdateField(base.CompositeField):
|
||||||
|
target = base.Field("target")
|
||||||
|
"""The simple update target"""
|
||||||
|
|
||||||
|
|
||||||
|
class ActionsField(base.CompositeField):
|
||||||
|
simple_update = SimpleUpdateField("#UpdateService.SimpleUpdate")
|
||||||
|
"""The actions simple update"""
|
||||||
|
|
||||||
|
oem = base.Field("Oem")
|
||||||
|
"""The actions oem"""
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateService(base.ResourceBase):
|
||||||
|
identity = base.Field("Id")
|
||||||
|
"""The update service identity"""
|
||||||
|
|
||||||
|
name = base.Field("Name")
|
||||||
|
"""The update service name"""
|
||||||
|
|
||||||
|
status = StatusField("Status")
|
||||||
|
"""The update service name"""
|
||||||
|
|
||||||
|
service_enabled = base.Field("ServiceEnabled", adapter=bool)
|
||||||
|
"""Whether the update service is enabled"""
|
||||||
|
|
||||||
|
actions = ActionsField("Actions")
|
||||||
|
"""The update service actions"""
|
||||||
|
|
||||||
|
oem = base.Field("Oem")
|
||||||
|
"""The update service oem"""
|
||||||
|
|
||||||
|
odata_context = base.Field("@odata.context")
|
||||||
|
"""The update service odata context"""
|
||||||
|
|
||||||
|
def __init__(self, connector, identity, redfish_version=None):
|
||||||
|
"""A class representing a UpdateService
|
||||||
|
|
||||||
|
:param connector: A Connector instance
|
||||||
|
:param identity: The identity of the UpdateService resource
|
||||||
|
:param redfish_version: The version of RedFish. Used to construct
|
||||||
|
the object according to schema of the given version.
|
||||||
|
"""
|
||||||
|
super(UpdateService, self).__init__(connector, identity,
|
||||||
|
redfish_version)
|
||||||
|
|
||||||
|
def _get_action_info_path(self):
|
||||||
|
"""Helper function to find the ActionInfo path"""
|
||||||
|
return self.json.get("Actions").get("#UpdateService.SimpleUpdate").get(
|
||||||
|
"@Redfish.ActionInfo")
|
||||||
|
|
||||||
|
@property
|
||||||
|
@utils.cache_it
|
||||||
|
def action_info(self):
|
||||||
|
"""Property to provide reference to `ActionInfo` instance
|
||||||
|
|
||||||
|
It is calculated once when it is queried for the first time. On
|
||||||
|
refresh, this property is reset.
|
||||||
|
"""
|
||||||
|
return action_info.ActionInfo(
|
||||||
|
self._conn, self._get_action_info_path(),
|
||||||
|
redfish_version=self.redfish_version)
|
@ -46,5 +46,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"UpdateService": {
|
||||||
|
"@odata.id": "/redfish/v1/UpdateService"
|
||||||
|
},
|
||||||
"Links": {}
|
"Links": {}
|
||||||
}
|
}
|
24
rsd_lib/tests/unit/json_samples/v2_2/update_service.json
Normal file
24
rsd_lib/tests/unit/json_samples/v2_2/update_service.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"@odata.type":"#UpdateService.v1_0_2.UpdateService",
|
||||||
|
"Id":"UpdateService",
|
||||||
|
"Name":"Update service",
|
||||||
|
"Status":{
|
||||||
|
"State":"Disabled",
|
||||||
|
"Health":null,
|
||||||
|
"HealthRollup":null
|
||||||
|
},
|
||||||
|
"ServiceEnabled":false,
|
||||||
|
"Actions":{
|
||||||
|
"#UpdateService.SimpleUpdate":{
|
||||||
|
"target":"/redfish/v1/UpdateService/Actions/SimpleUpdate",
|
||||||
|
"@Redfish.ActionInfo":"/redfish/v1/UpdateService/SimpleUpdateActionInfo"
|
||||||
|
},
|
||||||
|
"Oem":{
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Oem":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"@odata.context":"/redfish/v1/$metadata#UpdateService/$entity"
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"@odata.type":"#ActionInfo.v1_0_0.ActionInfo",
|
||||||
|
"Parameters":[
|
||||||
|
{
|
||||||
|
"Name":"ImageURI",
|
||||||
|
"Required":true,
|
||||||
|
"DataType":"String"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name":"TransferProtocol",
|
||||||
|
"Required":false,
|
||||||
|
"DataType":"String",
|
||||||
|
"AllowableValues":[
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name":"Targets",
|
||||||
|
"Required":false,
|
||||||
|
"DataType":"StringArray",
|
||||||
|
"AllowableValues":[
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Oem":{
|
||||||
|
|
||||||
|
},
|
||||||
|
"@odata.context":"/redfish/v1/$metadata#ActionInfo.ActionInfo",
|
||||||
|
"@odata.id":"/redfish/v1/UpdateService/SimpleUpdateActionInfo"
|
||||||
|
}
|
@ -43,5 +43,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"UpdateService": {
|
||||||
|
"@odata.id": "/redfish/v1/UpdateService"
|
||||||
|
},
|
||||||
"Links": {}
|
"Links": {}
|
||||||
}
|
}
|
@ -43,5 +43,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"UpdateService": {
|
||||||
|
"@odata.id": "/redfish/v1/UpdateService"
|
||||||
|
},
|
||||||
"Links": {}
|
"Links": {}
|
||||||
}
|
}
|
@ -31,6 +31,8 @@ from rsd_lib.resources.v2_2.manager import manager as v2_2_manager
|
|||||||
from rsd_lib.resources.v2_2.node import node as v2_2_node
|
from rsd_lib.resources.v2_2.node import node as v2_2_node
|
||||||
from rsd_lib.resources.v2_2.system import system as v2_2_system
|
from rsd_lib.resources.v2_2.system import system as v2_2_system
|
||||||
from rsd_lib.resources.v2_2.telemetry import telemetry as v2_2_telemetry
|
from rsd_lib.resources.v2_2.telemetry import telemetry as v2_2_telemetry
|
||||||
|
from rsd_lib.resources.v2_2.update_service import update_service \
|
||||||
|
as v2_2_update_service
|
||||||
|
|
||||||
|
|
||||||
class RSDLibV2_2TestCase(testtools.TestCase):
|
class RSDLibV2_2TestCase(testtools.TestCase):
|
||||||
@ -58,6 +60,8 @@ class RSDLibV2_2TestCase(testtools.TestCase):
|
|||||||
self.rsd._task_service_path)
|
self.rsd._task_service_path)
|
||||||
self.assertEqual("/redfish/v1/Registries",
|
self.assertEqual("/redfish/v1/Registries",
|
||||||
self.rsd._registries_path)
|
self.rsd._registries_path)
|
||||||
|
self.assertEqual("/redfish/v1/UpdateService",
|
||||||
|
self.rsd._update_service_path)
|
||||||
|
|
||||||
@mock.patch.object(v2_2_system, 'SystemCollection', autospec=True)
|
@mock.patch.object(v2_2_system, 'SystemCollection', autospec=True)
|
||||||
def test_get_system_collection(self, mock_system_collection):
|
def test_get_system_collection(self, mock_system_collection):
|
||||||
@ -193,3 +197,11 @@ class RSDLibV2_2TestCase(testtools.TestCase):
|
|||||||
self.rsd._conn, 'fake-registries-id',
|
self.rsd._conn, 'fake-registries-id',
|
||||||
redfish_version=self.rsd.redfish_version
|
redfish_version=self.rsd.redfish_version
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@mock.patch.object(v2_2_update_service, 'UpdateService', autospec=True)
|
||||||
|
def test_get_update_service(
|
||||||
|
self, mock_update_service):
|
||||||
|
self.rsd.get_update_service()
|
||||||
|
mock_update_service.assert_called_once_with(
|
||||||
|
self.rsd._conn, '/redfish/v1/UpdateService',
|
||||||
|
redfish_version=self.rsd.redfish_version)
|
||||||
|
@ -0,0 +1,109 @@
|
|||||||
|
# Copyright 2019 Intel, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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 json
|
||||||
|
|
||||||
|
import mock
|
||||||
|
import testtools
|
||||||
|
|
||||||
|
from rsd_lib.resources.v2_2.update_service import action_info
|
||||||
|
|
||||||
|
|
||||||
|
class ActionInfoTestCase(testtools.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(ActionInfoTestCase, self).setUp()
|
||||||
|
self.conn = mock.Mock()
|
||||||
|
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||||
|
'update_service_action_info.json',
|
||||||
|
'r') as f:
|
||||||
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
|
|
||||||
|
self.action_info_inst = action_info.ActionInfo(
|
||||||
|
self.conn, '/redfish/v1/UpdateService/SimpleUpdateActionInfo',
|
||||||
|
redfish_version='1.1.0')
|
||||||
|
|
||||||
|
def test__parse_attributes(self):
|
||||||
|
self.action_info_inst._parse_attributes()
|
||||||
|
self.assertEqual({}, self.action_info_inst.oem)
|
||||||
|
|
||||||
|
def test_parameters(self):
|
||||||
|
# | WHEN |
|
||||||
|
actual_parameters = self.action_info_inst.parameters
|
||||||
|
# | THEN |
|
||||||
|
expected = [
|
||||||
|
{
|
||||||
|
"name": "ImageURI",
|
||||||
|
"required": True,
|
||||||
|
"data_type": "String"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "TransferProtocol",
|
||||||
|
"required": False,
|
||||||
|
"data_type": "String",
|
||||||
|
"allowable_values": [
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Targets",
|
||||||
|
"required": False,
|
||||||
|
"data_type": "StringArray",
|
||||||
|
"allowable_values": [
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
self.assertEqual(expected, actual_parameters)
|
||||||
|
|
||||||
|
# tests for same object on invoking subsequently
|
||||||
|
self.assertIs(actual_parameters,
|
||||||
|
self.action_info_inst.parameters)
|
||||||
|
|
||||||
|
def test_parameters_on_refresh(self):
|
||||||
|
expected = [
|
||||||
|
{
|
||||||
|
"name": "ImageURI",
|
||||||
|
"required": True,
|
||||||
|
"data_type": "String"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "TransferProtocol",
|
||||||
|
"required": False,
|
||||||
|
"data_type": "String",
|
||||||
|
"allowable_values": [
|
||||||
|
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Targets",
|
||||||
|
"required": False,
|
||||||
|
"data_type": "StringArray",
|
||||||
|
"allowable_values": [
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
self.assertEqual(expected, self.action_info_inst.parameters)
|
||||||
|
|
||||||
|
self.action_info_inst.invalidate()
|
||||||
|
self.action_info_inst.refresh(force=False)
|
||||||
|
|
||||||
|
# | GIVEN |
|
||||||
|
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||||
|
'update_service_action_info.json', 'r') as f:
|
||||||
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
|
# | WHEN & THEN |
|
||||||
|
self.assertEqual(expected, self.action_info_inst.parameters)
|
@ -0,0 +1,102 @@
|
|||||||
|
# Copyright 2019 Intel, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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 json
|
||||||
|
|
||||||
|
import mock
|
||||||
|
import testtools
|
||||||
|
|
||||||
|
from rsd_lib.resources.v2_2.update_service import action_info
|
||||||
|
from rsd_lib.resources.v2_2.update_service import update_service
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateServiceTestCase(testtools.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(UpdateServiceTestCase, self).setUp()
|
||||||
|
self.conn = mock.Mock()
|
||||||
|
with open('rsd_lib/tests/unit/json_samples/v2_2/update_service.json',
|
||||||
|
'r') as f:
|
||||||
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
|
|
||||||
|
self.update_service_inst = update_service.UpdateService(
|
||||||
|
self.conn, '/redfish/v1/UpdateService',
|
||||||
|
redfish_version='1.1.0')
|
||||||
|
|
||||||
|
def test__parse_attributes(self):
|
||||||
|
self.update_service_inst._parse_attributes()
|
||||||
|
self.assertEqual("UpdateService", self.update_service_inst.identity)
|
||||||
|
self.assertEqual("Update service", self.update_service_inst.name)
|
||||||
|
self.assertEqual("Disabled", self.update_service_inst.status.state)
|
||||||
|
self.assertEqual(None, self.update_service_inst.status.health)
|
||||||
|
self.assertEqual(None, self.update_service_inst.status.health_rollup)
|
||||||
|
self.assertEqual(False, self.update_service_inst.service_enabled)
|
||||||
|
self.assertEqual("/redfish/v1/UpdateService/Actions/SimpleUpdate",
|
||||||
|
self.update_service_inst.actions.simple_update.target)
|
||||||
|
self.assertEqual({}, self.update_service_inst.actions.oem)
|
||||||
|
self.assertEqual({}, self.update_service_inst.oem)
|
||||||
|
self.assertEqual("/redfish/v1/$metadata#UpdateService/$entity",
|
||||||
|
self.update_service_inst.odata_context)
|
||||||
|
|
||||||
|
def test__get_action_info_path(self):
|
||||||
|
expected = '/redfish/v1/UpdateService/SimpleUpdateActionInfo'
|
||||||
|
result = self.update_service_inst._get_action_info_path()
|
||||||
|
self.assertEqual(expected, result)
|
||||||
|
|
||||||
|
def test_action_info(self):
|
||||||
|
# | GIVEN |
|
||||||
|
self.conn.get.return_value.json.reset_mock()
|
||||||
|
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||||
|
'update_service_action_info.json', 'r') as f:
|
||||||
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
|
# | WHEN |
|
||||||
|
actual_action_info = self.update_service_inst.action_info
|
||||||
|
# | THEN |
|
||||||
|
self.assertIsInstance(actual_action_info,
|
||||||
|
action_info.ActionInfo)
|
||||||
|
self.conn.get.return_value.json.assert_called_once_with()
|
||||||
|
|
||||||
|
# reset mock
|
||||||
|
self.conn.get.return_value.json.reset_mock()
|
||||||
|
# | WHEN & THEN |
|
||||||
|
# tests for same object on invoking subsequently
|
||||||
|
self.assertIs(actual_action_info,
|
||||||
|
self.update_service_inst.action_info)
|
||||||
|
self.conn.get.return_value.json.assert_not_called()
|
||||||
|
|
||||||
|
def test_action_info_on_refresh(self):
|
||||||
|
# | GIVEN |
|
||||||
|
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||||
|
'update_service_action_info.json', 'r') as f:
|
||||||
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
|
# | WHEN & THEN |
|
||||||
|
self.assertIsInstance(self.update_service_inst.action_info,
|
||||||
|
action_info.ActionInfo)
|
||||||
|
|
||||||
|
# On refreshing the update service instance...
|
||||||
|
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||||
|
'update_service.json', 'r') as f:
|
||||||
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
|
|
||||||
|
self.update_service_inst.invalidate()
|
||||||
|
self.update_service_inst.refresh(force=False)
|
||||||
|
|
||||||
|
# | GIVEN |
|
||||||
|
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||||
|
'update_service_action_info.json', 'r') as f:
|
||||||
|
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||||
|
# | WHEN & THEN |
|
||||||
|
self.assertIsInstance(self.update_service_inst.action_info,
|
||||||
|
action_info.ActionInfo)
|
@ -22,6 +22,8 @@ from rsd_lib.resources.v2_1.registries import registries as v2_1_registries
|
|||||||
from rsd_lib.resources.v2_1.task import task_service as v2_1_task_service
|
from rsd_lib.resources.v2_1.task import task_service as v2_1_task_service
|
||||||
from rsd_lib.resources.v2_2.manager import manager as v2_2_manager
|
from rsd_lib.resources.v2_2.manager import manager as v2_2_manager
|
||||||
from rsd_lib.resources.v2_2.system import system as v2_2_system
|
from rsd_lib.resources.v2_2.system import system as v2_2_system
|
||||||
|
from rsd_lib.resources.v2_2.update_service import update_service \
|
||||||
|
as v2_2_update_service
|
||||||
from rsd_lib.resources import v2_3
|
from rsd_lib.resources import v2_3
|
||||||
from rsd_lib.resources.v2_3.ethernet_switch import ethernet_switch \
|
from rsd_lib.resources.v2_3.ethernet_switch import ethernet_switch \
|
||||||
as v2_3_ethernet_switch
|
as v2_3_ethernet_switch
|
||||||
@ -55,6 +57,8 @@ class RSDLibV2_3TestCase(testtools.TestCase):
|
|||||||
self.rsd._task_service_path)
|
self.rsd._task_service_path)
|
||||||
self.assertEqual("/redfish/v1/Registries",
|
self.assertEqual("/redfish/v1/Registries",
|
||||||
self.rsd._registries_path)
|
self.rsd._registries_path)
|
||||||
|
self.assertEqual("/redfish/v1/UpdateService",
|
||||||
|
self.rsd._update_service_path)
|
||||||
|
|
||||||
@mock.patch.object(v2_2_system, 'SystemCollection', autospec=True)
|
@mock.patch.object(v2_2_system, 'SystemCollection', autospec=True)
|
||||||
def test_get_system_collection(self, mock_system_collection):
|
def test_get_system_collection(self, mock_system_collection):
|
||||||
@ -184,6 +188,14 @@ class RSDLibV2_3TestCase(testtools.TestCase):
|
|||||||
redfish_version=self.rsd.redfish_version
|
redfish_version=self.rsd.redfish_version
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@mock.patch.object(v2_2_update_service, 'UpdateService', autospec=True)
|
||||||
|
def test_get_update_service(
|
||||||
|
self, mock_update_service):
|
||||||
|
self.rsd.get_update_service()
|
||||||
|
mock_update_service.assert_called_once_with(
|
||||||
|
self.rsd._conn, '/redfish/v1/UpdateService',
|
||||||
|
redfish_version=self.rsd.redfish_version)
|
||||||
|
|
||||||
# @mock.patch.object(v2_2_telemetry, 'Telemetry', autospec=True)
|
# @mock.patch.object(v2_2_telemetry, 'Telemetry', autospec=True)
|
||||||
# def test_get_telemetry_service(self, mock_telemetry_service):
|
# def test_get_telemetry_service(self, mock_telemetry_service):
|
||||||
# self.rsd.get_telemetry_service()
|
# self.rsd.get_telemetry_service()
|
||||||
|
@ -22,6 +22,8 @@ from rsd_lib.resources.v2_1.registries import registries as v2_1_registries
|
|||||||
from rsd_lib.resources.v2_1.task import task_service as v2_1_task_service
|
from rsd_lib.resources.v2_1.task import task_service as v2_1_task_service
|
||||||
from rsd_lib.resources.v2_2.manager import manager as v2_2_manager
|
from rsd_lib.resources.v2_2.manager import manager as v2_2_manager
|
||||||
from rsd_lib.resources.v2_2.system import system as v2_2_system
|
from rsd_lib.resources.v2_2.system import system as v2_2_system
|
||||||
|
from rsd_lib.resources.v2_2.update_service import update_service \
|
||||||
|
as v2_2_update_service
|
||||||
from rsd_lib.resources.v2_3.ethernet_switch import ethernet_switch \
|
from rsd_lib.resources.v2_3.ethernet_switch import ethernet_switch \
|
||||||
as v2_3_ethernet_switch
|
as v2_3_ethernet_switch
|
||||||
from rsd_lib.resources.v2_3.fabric import fabric as v2_3_fabric
|
from rsd_lib.resources.v2_3.fabric import fabric as v2_3_fabric
|
||||||
@ -55,6 +57,8 @@ class RSDLibV2_3TestCase(testtools.TestCase):
|
|||||||
self.rsd._task_service_path)
|
self.rsd._task_service_path)
|
||||||
self.assertEqual("/redfish/v1/Registries",
|
self.assertEqual("/redfish/v1/Registries",
|
||||||
self.rsd._registries_path)
|
self.rsd._registries_path)
|
||||||
|
self.assertEqual("/redfish/v1/UpdateService",
|
||||||
|
self.rsd._update_service_path)
|
||||||
|
|
||||||
@mock.patch.object(v2_2_system, 'SystemCollection', autospec=True)
|
@mock.patch.object(v2_2_system, 'SystemCollection', autospec=True)
|
||||||
def test_get_system_collection(self, mock_system_collection):
|
def test_get_system_collection(self, mock_system_collection):
|
||||||
@ -184,6 +188,14 @@ class RSDLibV2_3TestCase(testtools.TestCase):
|
|||||||
redfish_version=self.rsd.redfish_version
|
redfish_version=self.rsd.redfish_version
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@mock.patch.object(v2_2_update_service, 'UpdateService', autospec=True)
|
||||||
|
def test_get_update_service(
|
||||||
|
self, mock_update_service):
|
||||||
|
self.rsd.get_update_service()
|
||||||
|
mock_update_service.assert_called_once_with(
|
||||||
|
self.rsd._conn, '/redfish/v1/UpdateService',
|
||||||
|
redfish_version=self.rsd.redfish_version)
|
||||||
|
|
||||||
# @mock.patch.object(v2_2_telemetry, 'Telemetry', autospec=True)
|
# @mock.patch.object(v2_2_telemetry, 'Telemetry', autospec=True)
|
||||||
# def test_get_telemetry_service(self, mock_telemetry_service):
|
# def test_get_telemetry_service(self, mock_telemetry_service):
|
||||||
# self.rsd.get_telemetry_service()
|
# self.rsd.get_telemetry_service()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user