Merge lp:~jtran/nova/lp732902 into lp:~hudson-openstack/nova/trunk

Proposed by John Tran
Status: Merged
Approved by: Vish Ishaya
Approved revision: 923
Merged at revision: 979
Proposed branch: lp:~jtran/nova/lp732902
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 31 lines (+14/-0)
1 file modified
nova/tests/test_cloud.py (+14/-0)
To merge this branch: bzr merge lp:~jtran/nova/lp732902
Reviewer Review Type Date Requested Status
Vish Ishaya (community) Approve
Devin Carlen (community) Approve
Review via email: mp+56425@code.launchpad.net

Commit message

Add a unit test for terminate_instances.

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Vish Ishaya (vishvananda) wrote :

lgtm

review: Approve
Revision history for this message
Vish Ishaya (vishvananda) wrote :

merging this because addtional tests are good and it doesn't touch any actual code

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/tests/test_cloud.py'
2--- nova/tests/test_cloud.py 2011-03-30 00:07:59 +0000
3+++ nova/tests/test_cloud.py 2011-04-05 18:32:32 +0000
4@@ -36,6 +36,7 @@
5 from nova import service
6 from nova import test
7 from nova import utils
8+from nova import exception
9 from nova.auth import manager
10 from nova.compute import power_state
11 from nova.api.ec2 import cloud
12@@ -341,6 +342,19 @@
13 LOG.debug(_("Terminating instance %s"), instance_id)
14 rv = self.compute.terminate_instance(instance_id)
15
16+ def test_terminate_instances(self):
17+ inst1 = db.instance_create(self.context, {'reservation_id': 'a',
18+ 'image_id': 1,
19+ 'host': 'host1'})
20+ terminate_instances = self.cloud.terminate_instances
21+ # valid instance_id
22+ result = terminate_instances(self.context, ['i-00000001'])
23+ self.assertTrue(result)
24+ # non-existing instance_id
25+ self.assertRaises(exception.InstanceNotFound, terminate_instances,
26+ self.context, ['i-2'])
27+ db.instance_destroy(self.context, inst1['id'])
28+
29 def test_update_of_instance_display_fields(self):
30 inst = db.instance_create(self.context, {})
31 ec2_id = ec2utils.id_to_ec2_id(inst['id'])