summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTushar Patil <tushar.vitthal.patil@gmail.com>2011-09-02 17:09:09 -0700
committerTushar Patil <tushar.vitthal.patil@gmail.com>2011-09-02 17:09:09 -0700
commit494eb94192a971f64fa6aa78092074f8ed437a7f (patch)
tree67f119423a32987c63934242eec25acb8dce5595
parent20beec509aff1bb3a30e9f1d95d3e2825f2b38ea (diff)
Added unit tests to check instance record is not inserted in db when security groups passed to the instances are not existing
-rw-r--r--nova/tests/test_compute.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py
index 766a7da9b..65fdffbd6 100644
--- a/nova/tests/test_compute.py
+++ b/nova/tests/test_compute.py
@@ -161,6 +161,19 @@ class ComputeTestCase(test.TestCase):
db.security_group_destroy(self.context, group['id'])
db.instance_destroy(self.context, ref[0]['id'])
+ def test_create_instance_with_invalid_security_group_raises(self):
+ instance_type = instance_types.get_default_instance_type()
+
+ pre_build_len = len(db.instance_get_all(context.get_admin_context()))
+ self.assertRaises(exception.SecurityGroupNotFoundForProject,
+ self.compute_api.create,
+ self.context,
+ instance_type=instance_type,
+ image_href=None,
+ security_group=['this_is_a_fake_sec_group'])
+ self.assertEqual(pre_build_len,
+ len(db.instance_get_all(context.get_admin_context())))
+
def test_create_instance_associates_config_drive(self):
"""Make sure create associates a config drive."""