Esempio n. 1
0
    def test_get_test_admin_context(self):
        # get_test_admin_context's return value behaves like admin context.
        ctxt = test_utils.get_test_admin_context()

        # TODO(soren): This should verify the full interface context
        # objects expose.
        self.assertTrue(ctxt.is_admin)
Esempio n. 2
0
    def test_check_img_metadata_properties_quota_valid_metadata(self):
        ctxt = utils.get_test_admin_context()
        metadata1 = {"key": "value"}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata1)
        self.assertIsNone(actual)

        metadata2 = {"key": "v" * 260}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata2)
        self.assertIsNone(actual)

        metadata3 = {"key": ""}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata3)
        self.assertIsNone(actual)
Esempio n. 3
0
    def test_check_img_metadata_properties_quota_valid_metadata(self):
        ctxt = utils.get_test_admin_context()
        metadata1 = {"key": "value"}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata1)
        self.assertIsNone(actual)

        metadata2 = {"key": "v" * 260}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata2)
        self.assertIsNone(actual)

        metadata3 = {"key": ""}
        actual = common.check_img_metadata_properties_quota(ctxt, metadata3)
        self.assertIsNone(actual)
Esempio n. 4
0
    def setUp(self):
        super(_VirtDriverTestCase, self).setUp()

        self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
        self.connection = importutils.import_object(self.driver_module,
                                                    fake.FakeVirtAPI())
        self.ctxt = test_utils.get_test_admin_context()
        self.image_service = fake_image.FakeImageService()
        # NOTE(dripton): resolve_driver_format does some file reading and
        # writing and chowning that complicate testing too much by requiring
        # using real directories with proper permissions.  Just stub it out
        # here; we test it in test_imagebackend.py
        self.stubs.Set(imagebackend.Image, 'resolve_driver_format',
                       imagebackend.Image._get_driver_format)
Esempio n. 5
0
    def test_check_img_metadata_properties_quota_inv_metadata(self):
        ctxt = utils.get_test_admin_context()
        metadata1 = {"a" * 260: "value"}
        self.assertRaises(webob.exc.HTTPBadRequest,
                common.check_img_metadata_properties_quota, ctxt, metadata1)

        metadata2 = {"": "value"}
        self.assertRaises(webob.exc.HTTPBadRequest,
                common.check_img_metadata_properties_quota, ctxt, metadata2)

        metadata3 = "invalid metadata"
        self.assertRaises(webob.exc.HTTPBadRequest,
                common.check_img_metadata_properties_quota, ctxt, metadata3)

        metadata4 = None
        self.assertIsNone(common.check_img_metadata_properties_quota(ctxt,
                                                        metadata4))
        metadata5 = {}
        self.assertIsNone(common.check_img_metadata_properties_quota(ctxt,
                                                        metadata5))
Esempio n. 6
0
    def test_check_img_metadata_properties_quota_inv_metadata(self):
        ctxt = utils.get_test_admin_context()
        metadata1 = {"a" * 260: "value"}
        self.assertRaises(webob.exc.HTTPBadRequest,
                          common.check_img_metadata_properties_quota, ctxt,
                          metadata1)

        metadata2 = {"": "value"}
        self.assertRaises(webob.exc.HTTPBadRequest,
                          common.check_img_metadata_properties_quota, ctxt,
                          metadata2)

        metadata3 = "invalid metadata"
        self.assertRaises(webob.exc.HTTPBadRequest,
                          common.check_img_metadata_properties_quota, ctxt,
                          metadata3)

        metadata4 = None
        self.assertIsNone(
            common.check_img_metadata_properties_quota(ctxt, metadata4))
        metadata5 = {}
        self.assertIsNone(
            common.check_img_metadata_properties_quota(ctxt, metadata5))
Esempio n. 7
0
 def test_get_test_instance(self):
     # get_test_instance's return value looks like an instance_ref.
     instance_ref = test_utils.get_test_instance()
     ctxt = test_utils.get_test_admin_context()
     db.instance_get(ctxt, instance_ref['id'])