diff options
author | Jakub Jelinek <vilouskubajj@gmail.com> | 2022-10-25 10:37:06 +0100 |
---|---|---|
committer | Jakub Jelinek <vilouskubajj@gmail.com> | 2022-11-15 16:55:36 +0000 |
commit | 59b0dc459907a0c13562c70037ee32d25742ca73 (patch) | |
tree | bcd33669701c1fff0e5350a6c5a0577e1c5ea433 /ironic/tests/unit/db/test_node_inventory.py | |
parent | 9e9b248216ef47f8ba1b4b20f205dc6a95ce7ec1 (diff) | |
download | ironic-59b0dc459907a0c13562c70037ee32d25742ca73.tar.gz |
Implements node inventory: database
Prepare the ironic database to accommodate node inventory received from
the inspector once the API is implemented.
Story: 2010275
Task: 46204
Change-Id: I6b830e5cc30f1fa1f1900e7c45e6f246fa1ec51c
Diffstat (limited to 'ironic/tests/unit/db/test_node_inventory.py')
-rw-r--r-- | ironic/tests/unit/db/test_node_inventory.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/ironic/tests/unit/db/test_node_inventory.py b/ironic/tests/unit/db/test_node_inventory.py new file mode 100644 index 000000000..a146903f7 --- /dev/null +++ b/ironic/tests/unit/db/test_node_inventory.py @@ -0,0 +1,47 @@ +# 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 ironic.common import exception +from ironic.tests.unit.db import base +from ironic.tests.unit.db import utils as db_utils + + +class DBNodeInventoryTestCase(base.DbTestCase): + + def setUp(self): + super(DBNodeInventoryTestCase, self).setUp() + self.node = db_utils.create_test_node() + self.inventory = db_utils.create_test_inventory( + id=0, node_id=self.node.id, + inventory_data={"inventory": "test_inventory"}, + plugin_data={"plugin_data": "test_plugin_data"}) + + def test_destroy_node_inventory_by_node_id(self): + self.dbapi.destroy_node_inventory_by_node_id(self.inventory.node_id) + self.assertRaises(exception.NodeInventoryNotFound, + self.dbapi.get_node_inventory_by_id, + self.inventory.id) + + def test_get_inventory_by_id(self): + res = self.dbapi.get_node_inventory_by_id(self.inventory.id) + self.assertEqual(self.inventory.inventory_data, res.inventory_data) + + def test_get_inventory_by_id_not_found(self): + self.assertRaises(exception.NodeInventoryNotFound, + self.dbapi.get_node_inventory_by_id, -1) + + def test_get_inventory_by_node_id(self): + res = self.dbapi.get_node_inventory_by_node_id(self.inventory.node_id) + self.assertEqual(self.inventory.id, res.id) + + def test_get_history_by_node_id_empty(self): + self.assertEqual([], self.dbapi.get_node_history_by_node_id(10)) |