summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-02-13 18:53:15 +0000
committerGerrit Code Review <review@openstack.org>2014-02-13 18:53:15 +0000
commit62da1a655726b143edab0aa12d1f619364105a2f (patch)
tree8f258e1f84518b2976a9f312316a7b30740ee5f1
parente48c9e29d4457a16e5e17f7793ebdf1314f2b409 (diff)
parentea72bcb23a4c4af158fb8bfc2b9163cf4c9191ab (diff)
downloadironic-62da1a655726b143edab0aa12d1f619364105a2f.tar.gz
Merge "Remove POST calls in tests for resource creation"
-rw-r--r--ironic/tests/api/test_chassis.py23
-rw-r--r--ironic/tests/api/test_nodes.py28
-rw-r--r--ironic/tests/api/test_ports.py40
3 files changed, 49 insertions, 42 deletions
diff --git a/ironic/tests/api/test_chassis.py b/ironic/tests/api/test_chassis.py
index b6a1d5237..28f35c739 100644
--- a/ironic/tests/api/test_chassis.py
+++ b/ironic/tests/api/test_chassis.py
@@ -146,7 +146,7 @@ class TestPatch(base.FunctionalTest):
def setUp(self):
super(TestPatch, self).setUp()
cdict = dbutils.get_test_chassis()
- self.post_json('/chassis', cdict)
+ self.dbapi.create_chassis(cdict)
self.addCleanup(timeutils.clear_time_override)
def test_update_not_found(self):
@@ -178,8 +178,9 @@ class TestPatch(base.FunctionalTest):
def test_replace_multi(self):
extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
cdict = dbutils.get_test_chassis(extra=extra,
- uuid=utils.generate_uuid())
- self.post_json('/chassis', cdict)
+ uuid=utils.generate_uuid(),
+ id=None)
+ self.dbapi.create_chassis(cdict)
new_value = 'new value'
response = self.patch_json('/chassis/%s' % cdict['uuid'],
[{'path': '/extra/foo2',
@@ -193,8 +194,9 @@ class TestPatch(base.FunctionalTest):
def test_remove_singular(self):
cdict = dbutils.get_test_chassis(extra={'a': 'b'},
- uuid=utils.generate_uuid())
- self.post_json('/chassis', cdict)
+ uuid=utils.generate_uuid(),
+ id=None)
+ self.dbapi.create_chassis(cdict)
response = self.patch_json('/chassis/%s' % cdict['uuid'],
[{'path': '/description', 'op': 'remove'}])
self.assertEqual('application/json', response.content_type)
@@ -209,8 +211,9 @@ class TestPatch(base.FunctionalTest):
def test_remove_multi(self):
extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
cdict = dbutils.get_test_chassis(extra=extra, description="foobar",
- uuid=utils.generate_uuid())
- self.post_json('/chassis', cdict)
+ uuid=utils.generate_uuid(),
+ id=None)
+ self.dbapi.create_chassis(cdict)
# Removing one item from the collection
response = self.patch_json('/chassis/%s' % cdict['uuid'],
@@ -312,7 +315,7 @@ class TestPost(base.FunctionalTest):
def test_post_nodes_subresource(self):
cdict = dbutils.get_test_chassis()
- self.post_json('/chassis', cdict)
+ self.dbapi.create_chassis(cdict)
ndict = dbutils.get_test_node(chassis_id=None)
ndict['chassis_uuid'] = cdict['uuid']
response = self.post_json('/chassis/nodes', ndict,
@@ -344,7 +347,7 @@ class TestDelete(base.FunctionalTest):
def test_delete_chassis(self):
cdict = dbutils.get_test_chassis()
- self.post_json('/chassis', cdict)
+ self.dbapi.create_chassis(cdict)
self.delete('/chassis/%s' % cdict['uuid'])
response = self.get_json('/chassis/%s' % cdict['uuid'],
expect_errors=True)
@@ -372,7 +375,7 @@ class TestDelete(base.FunctionalTest):
def test_delete_nodes_subresource(self):
cdict = dbutils.get_test_chassis()
- self.post_json('/chassis', cdict)
+ self.dbapi.create_chassis(cdict)
response = self.delete('/chassis/%s/nodes' % cdict['uuid'],
expect_errors=True)
self.assertEqual(403, response.status_int)
diff --git a/ironic/tests/api/test_nodes.py b/ironic/tests/api/test_nodes.py
index 718b3ea9a..7e912dee1 100644
--- a/ironic/tests/api/test_nodes.py
+++ b/ironic/tests/api/test_nodes.py
@@ -592,8 +592,8 @@ class TestPost(base.FunctionalTest):
self.assertTrue(response.json['error_message'])
def test_vendor_passthru_ok(self):
- ndict = post_get_test_node()
- self.post_json('/nodes', ndict)
+ ndict = dbutils.get_test_node()
+ self.dbapi.create_node(ndict)
uuid = ndict['uuid']
info = {'foo': 'bar'}
@@ -608,8 +608,8 @@ class TestPost(base.FunctionalTest):
self.assertEqual(202, response.status_code)
def test_vendor_passthru_no_such_method(self):
- ndict = post_get_test_node()
- self.post_json('/nodes', ndict)
+ ndict = dbutils.get_test_node()
+ self.dbapi.create_node(ndict)
uuid = ndict['uuid']
info = {'foo': 'bar'}
@@ -626,8 +626,8 @@ class TestPost(base.FunctionalTest):
self.assertEqual(400, response.status_code)
def test_vendor_passthru_without_method(self):
- ndict = post_get_test_node()
- self.post_json('/nodes', ndict)
+ ndict = dbutils.get_test_node()
+ self.dbapi.create_node(ndict)
response = self.post_json('/nodes/%s/vendor_passthru' % ndict['uuid'],
{'foo': 'bar'}, expect_errors=True)
self.assertEqual('application/json', response.content_type, )
@@ -635,8 +635,8 @@ class TestPost(base.FunctionalTest):
self.assertTrue(response.json['error_message'])
def test_post_ports_subresource(self):
- ndict = post_get_test_node()
- self.post_json('/nodes', ndict)
+ ndict = dbutils.get_test_node()
+ self.dbapi.create_node(ndict)
pdict = dbutils.get_test_port(node_id=None)
pdict['node_uuid'] = ndict['uuid']
response = self.post_json('/nodes/ports', pdict,
@@ -675,8 +675,8 @@ class TestDelete(base.FunctionalTest):
self.chassis = self.dbapi.create_chassis(cdict)
def test_delete_node(self):
- ndict = post_get_test_node()
- self.post_json('/nodes', ndict)
+ ndict = dbutils.get_test_node()
+ self.dbapi.create_node(ndict)
self.delete('/nodes/%s' % ndict['uuid'])
response = self.get_json('/nodes/%s' % ndict['uuid'],
expect_errors=True)
@@ -685,16 +685,16 @@ class TestDelete(base.FunctionalTest):
self.assertTrue(response.json['error_message'])
def test_delete_ports_subresource(self):
- ndict = post_get_test_node()
- self.post_json('/nodes', ndict)
+ ndict = dbutils.get_test_node()
+ self.dbapi.create_node(ndict)
response = self.delete('/nodes/%s/ports' % ndict['uuid'],
expect_errors=True)
self.assertEqual(403, response.status_int)
def test_delete_associated(self):
- ndict = post_get_test_node(
+ ndict = dbutils.get_test_node(
instance_uuid='aaaaaaaa-1111-bbbb-2222-cccccccccccc')
- self.post_json('/nodes', ndict)
+ self.dbapi.create_node(ndict)
response = self.delete('/nodes/%s' % ndict['uuid'], expect_errors=True)
self.assertEqual(409, response.status_int)
diff --git a/ironic/tests/api/test_ports.py b/ironic/tests/api/test_ports.py
index 750db7de5..54b8a4627 100644
--- a/ironic/tests/api/test_ports.py
+++ b/ironic/tests/api/test_ports.py
@@ -135,8 +135,8 @@ class TestPatch(base.FunctionalTest):
super(TestPatch, self).setUp()
ndict = dbutils.get_test_node()
self.node = self.dbapi.create_node(ndict)
- self.pdict = post_get_test_port()
- self.post_json('/ports', self.pdict)
+ self.pdict = dbutils.get_test_port(id=None)
+ self.dbapi.create_port(self.pdict)
self.addCleanup(timeutils.clear_time_override)
def test_update_byid(self):
@@ -185,13 +185,15 @@ class TestPatch(base.FunctionalTest):
self.assertEqual(address, result['address'])
def test_replace_address_already_exist(self):
- pdict1 = post_get_test_port(address='AA:AA:AA:AA:AA:AA',
- uuid=utils.generate_uuid())
- self.post_json('/ports', pdict1)
+ pdict1 = dbutils.get_test_port(address='aa:aa:aa:aa:aa:aa',
+ uuid=utils.generate_uuid(),
+ id=None)
+ self.dbapi.create_port(pdict1)
- pdict2 = post_get_test_port(address='BB:BB:BB:BB:BB:BB',
- uuid=utils.generate_uuid())
- self.post_json('/ports', pdict2)
+ pdict2 = dbutils.get_test_port(address='bb:bb:bb:bb:bb:bb',
+ uuid=utils.generate_uuid(),
+ id=None)
+ self.dbapi.create_port(pdict2)
response = self.patch_json('/ports/%s' % pdict1['uuid'],
[{'path': '/address',
@@ -214,10 +216,11 @@ class TestPatch(base.FunctionalTest):
def test_replace_multi(self):
extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
- pdict = post_get_test_port(extra=extra,
+ pdict = dbutils.get_test_port(extra=extra,
address="AA:BB:CC:DD:EE:FF",
uuid=utils.generate_uuid())
- self.post_json('/ports', pdict)
+ self.dbapi.create_port(pdict)
+
new_value = 'new value'
response = self.patch_json('/ports/%s' % pdict['uuid'],
[{'path': '/extra/foo2',
@@ -231,10 +234,10 @@ class TestPatch(base.FunctionalTest):
def test_remove_multi(self):
extra = {"foo1": "bar1", "foo2": "bar2", "foo3": "bar3"}
- pdict = post_get_test_port(extra=extra,
+ pdict = dbutils.get_test_port(extra=extra,
address="aa:bb:cc:dd:ee:ff",
uuid=utils.generate_uuid())
- self.post_json('/ports', pdict)
+ self.dbapi.create_port(pdict)
# Removing one item from the collection
response = self.patch_json('/ports/%s' % pdict['uuid'],
@@ -266,9 +269,10 @@ class TestPatch(base.FunctionalTest):
self.assertTrue(response.json['error_message'])
def test_remove_mandatory_field(self):
- pdict = post_get_test_port(address="AA:BB:CC:DD:EE:FF",
+ pdict = dbutils.get_test_port(address="AA:BB:CC:DD:EE:FF",
uuid=utils.generate_uuid())
- self.post_json('/ports', pdict)
+ self.dbapi.create_port(pdict)
+
response = self.patch_json('/ports/%s' % pdict['uuid'],
[{'path': '/address', 'op': 'remove'}],
expect_errors=True)
@@ -306,9 +310,9 @@ class TestPatch(base.FunctionalTest):
self.assertTrue(response.json['error_message'])
def test_update_address_invalid_format(self):
- pdict = post_get_test_port(address="AA:BB:CC:DD:EE:FF",
+ pdict = dbutils.get_test_port(address="AA:BB:CC:DD:EE:FF",
uuid=utils.generate_uuid())
- self.post_json('/ports', pdict)
+ self.dbapi.create_port(pdict)
response = self.patch_json('/ports/%s' % pdict['uuid'],
[{'path': '/address',
'value': 'invalid-format',
@@ -451,8 +455,8 @@ class TestDelete(base.FunctionalTest):
super(TestDelete, self).setUp()
ndict = dbutils.get_test_node()
self.node = self.dbapi.create_node(ndict)
- pdict = post_get_test_port()
- self.post_json('/ports', pdict)
+ pdict = dbutils.get_test_port()
+ self.dbapi.create_port(pdict)
def test_delete_port_byid(self):
pdict = dbutils.get_test_port()