diff options
| author | Yuriy Zveryanskyy <yzveryanskyy@mirantis.com> | 2013-05-30 15:28:35 +0300 |
|---|---|---|
| committer | Yuriy Zveryanskyy <yzveryanskyy@mirantis.com> | 2013-06-10 17:49:57 +0300 |
| commit | 3abd08defd352a7015d4c8c5ccc4ca12ac080421 (patch) | |
| tree | 8613504f09b1da17bf8634893c360a3434ea4f13 | |
| parent | e0142d0f63bf64a07db3bd3b840fc2072d2e6ca3 (diff) | |
| download | nova-3abd08defd352a7015d4c8c5ccc4ca12ac080421.tar.gz nova-3abd08defd352a7015d4c8c5ccc4ca12ac080421.tar.xz nova-3abd08defd352a7015d4c8c5ccc4ca12ac080421.zip | |
Add missing tests for s3_image_* methods
There was no tests in test_db_api for s3_image_*
methods.
Add tests to ensure that all works.
blueprint db-api-tests
Change-Id: I906025f4c5178b26c222fb28d5c3b220e00ae79c
| -rw-r--r-- | nova/tests/db/test_db_api.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/nova/tests/db/test_db_api.py b/nova/tests/db/test_db_api.py index 409a988ab..96557db93 100644 --- a/nova/tests/db/test_db_api.py +++ b/nova/tests/db/test_db_api.py @@ -4603,6 +4603,41 @@ class QuotaClassTestCase(test.TestCase, ModelsObjectComparatorMixin): self.ctxt, 'class name', 'resource', 42) +class S3ImageTestCase(test.TestCase): + + def setUp(self): + super(S3ImageTestCase, self).setUp() + self.ctxt = context.get_admin_context() + self.values = [uuidutils.generate_uuid() for i in xrange(3)] + self.images = [db.s3_image_create(self.ctxt, uuid) + for uuid in self.values] + + def test_s3_image_create(self): + for ref in self.images: + self.assertTrue(uuidutils.is_uuid_like(ref.uuid)) + self.assertEqual(sorted(self.values), + sorted([ref.uuid for ref in self.images])) + + def test_s3_image_get_by_uuid(self): + for uuid in self.values: + ref = db.s3_image_get_by_uuid(self.ctxt, uuid) + self.assertTrue(uuidutils.is_uuid_like(ref.uuid)) + self.assertEqual(uuid, ref.uuid) + + def test_s3_image_get(self): + self.assertEqual(sorted(self.values), + sorted([db.s3_image_get(self.ctxt, ref.id).uuid + for ref in self.images])) + + def test_s3_image_get_not_found(self): + self.assertRaises(exception.ImageNotFound, db.s3_image_get, self.ctxt, + 100500) + + def test_s3_image_get_by_uuid_not_found(self): + self.assertRaises(exception.ImageNotFound, db.s3_image_get_by_uuid, + self.ctxt, uuidutils.generate_uuid()) + + class ArchiveTestCase(test.TestCase): def setUp(self): |
