~hudson-openstack/nova/trunk

« back to all changes in this revision

Viewing changes to nova/tests/test_compute.py

  • Committer: Tushar Patil
  • Date: 2011-09-03 00:09:09 UTC
  • mto: This revision was merged to the branch mainline in revision 1526.
  • Revision ID: tushar.vitthal.patil@gmail.com-20110903000909-uahwq1oixaxt2f5p
Added unit tests to check instance record is not inserted in db when security groups passed to the instances are not existing

Show diffs side-by-side

added added

removed removed

Lines of Context:
161
161
            db.security_group_destroy(self.context, group['id'])
162
162
            db.instance_destroy(self.context, ref[0]['id'])
163
163
 
 
164
    def test_create_instance_with_invalid_security_group_raises(self):
 
165
        instance_type = instance_types.get_default_instance_type()
 
166
 
 
167
        pre_build_len = len(db.instance_get_all(context.get_admin_context()))
 
168
        self.assertRaises(exception.SecurityGroupNotFoundForProject,
 
169
                          self.compute_api.create,
 
170
                          self.context,
 
171
                          instance_type=instance_type,
 
172
                          image_href=None,
 
173
                          security_group=['this_is_a_fake_sec_group'])
 
174
        self.assertEqual(pre_build_len,
 
175
                         len(db.instance_get_all(context.get_admin_context())))
 
176
 
164
177
    def test_create_instance_associates_config_drive(self):
165
178
        """Make sure create associates a config drive."""
166
179