diff options
author | Lucas Alvares Gomes <lucasagomes@gmail.com> | 2013-10-31 14:13:27 +0000 |
---|---|---|
committer | Lucas Alvares Gomes <lucasagomes@gmail.com> | 2013-11-18 10:10:34 +0000 |
commit | 35208610e89195d92ee29ec51f55d318bb7618e9 (patch) | |
tree | dea979ffec80ce24e7254e72b1ae31b51c2fb90a /ironic/tests/db | |
parent | dc1c76dcd2a7db46650f750ab1320b0e609bc203 (diff) | |
download | ironic-35208610e89195d92ee29ec51f55d318bb7618e9.tar.gz |
Accessing a subresource that parent does not exist
When accessing a subresource like /nodes/<id>/ports or /chassis/<id>/nodes
where <id> does not exist should fail with 404.
Also fix a typo in the name of a method on test_nodes.py
Change-Id: I5b6beba00fa7cc72b45689c5685914da895b7aa2
Closes-Bug: #1246731
Diffstat (limited to 'ironic/tests/db')
-rw-r--r-- | ironic/tests/db/test_nodes.py | 11 | ||||
-rw-r--r-- | ironic/tests/db/test_ports.py | 12 |
2 files changed, 12 insertions, 11 deletions
diff --git a/ironic/tests/db/test_nodes.py b/ironic/tests/db/test_nodes.py index 378ebd13e..d655104dd 100644 --- a/ironic/tests/db/test_nodes.py +++ b/ironic/tests/db/test_nodes.py @@ -85,11 +85,12 @@ class DbNodeTestCase(base.DbTestCase): self.assertEqual(n['id'], nodes[0]['id']) def test_get_nodes_by_chassis_that_does_not_exist(self): - nodes = self.dbapi.get_nodes_by_chassis(33) - self.assertEqual(0, len(nodes)) - - nodes = self.dbapi.get_nodes_by_chassis("1231231-123123-123123") - self.assertEqual(0, len(nodes)) + self.assertRaises(exception.ChassisNotFound, + self.dbapi.get_nodes_by_chassis, + 33) + self.assertRaises(exception.ChassisNotFound, + self.dbapi.get_nodes_by_chassis, + '12345678-9999-0000-aaaa-123456789012') def test_get_node_by_id(self): n = self._create_test_node() diff --git a/ironic/tests/db/test_ports.py b/ironic/tests/db/test_ports.py index e440bb3ba..206ebfe6f 100644 --- a/ironic/tests/db/test_ports.py +++ b/ironic/tests/db/test_ports.py @@ -84,12 +84,12 @@ class DbPortTestCase(base.DbTestCase): def test_get_ports_by_node_that_does_not_exist(self): self.dbapi.create_port(self.p) - res = self.dbapi.get_ports_by_node(99) - self.assertEqual(0, len(res)) - - res = self.dbapi.get_ports_by_node( - '12345678-9999-0000-aaaa-123456789012') - self.assertEqual(0, len(res)) + self.assertRaises(exception.NodeNotFound, + self.dbapi.get_ports_by_node, + 99) + self.assertRaises(exception.NodeNotFound, + self.dbapi.get_ports_by_node, + '12345678-9999-0000-aaaa-123456789012') def test_destroy_port(self): self.dbapi.create_port(self.p) |