From f546f62397979312dd891509c31feadf149b8c59 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 10 Aug 2012 09:25:10 -0700 Subject: Make sure ec2 mapping raises proper exceptions The get commands in the db layer were constructing InstanceNotFound, VolumeNotFound, and SnapshotNotFound with imporoper kwargs. This fixes them to raise properly and adds a test to verify that the exception formatting succeeded. Fixes bug 1035375 Change-Id: I05a5bb57c047ca2b2f086c70ad12a640f51b2d3a --- nova/tests/test_db_api.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index b2b1cf9e2..89cbe18c6 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -45,6 +45,21 @@ class DbApiTestCase(test.TestCase): args.update(kwargs) return db.instance_create(self.context, args) + def test_ec2_ids_not_found_are_printable(self): + + def check_exc_format(method): + try: + method(self.context, 'fake') + except Exception as exc: + self.assertTrue('fake' in unicode(exc)) + + check_exc_format(db.get_ec2_volume_id_by_uuid) + check_exc_format(db.get_volume_uuid_by_ec2_id) + check_exc_format(db.get_ec2_snapshot_id_by_uuid) + check_exc_format(db.get_snapshot_uuid_by_ec2_id) + check_exc_format(db.get_ec2_instance_id_by_uuid) + check_exc_format(db.get_instance_uuid_by_ec2_id) + def test_instance_get_all_by_filters(self): self.create_instances_with_args() self.create_instances_with_args() -- cgit