コード例 #1
0
 def test_pull_image_already_exists(self, mock_get, mock_write, mock_read):
     mock_get.return_value = None
     mock_read.side_effect = etcd.EtcdKeyNotFound
     utils.create_test_image(context=self.context, repo="ubuntu:latest")
     mock_get.return_value = mock.MagicMock()
     self.assertRaises(exception.ResourceExists,
                       utils.create_test_image,
                       context=self.context,
                       repo="ubuntu:latest")
コード例 #2
0
 def test_get_image_by_uuid(self, mock_get, mock_write, mock_read):
     mock_get.return_value = None
     mock_read.side_effect = etcd.EtcdKeyNotFound
     image = utils.create_test_image(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(image.as_dict())
     res = self.dbapi.get_image_by_uuid(self.context, image.uuid)
     self.assertEqual(image.uuid, res.uuid)
コード例 #3
0
 def test_update_image_uuid(self, mock_get, mock_write, mock_read):
     mock_get.return_value = None
     mock_read.side_effect = etcd.EtcdKeyNotFound
     image = utils.create_test_image(context=self.context)
     self.assertRaises(exception.InvalidParameterValue,
                       self.dbapi.update_image, image.uuid,
                       {'uuid': 'newuuid'})
コード例 #4
0
    def test_update_image(self):
        image = utils.create_test_image(context=self.context)
        old_size = image.size
        new_size = '2000'
        self.assertNotEqual(old_size, new_size)

        res = self.dbapi.update_image(image.id, {'size': new_size})
        self.assertEqual(new_size, res.size)
コード例 #5
0
ファイル: test_image.py プロジェクト: openstack/higgins
 def test_list_images(self):
     uuids = []
     for i in range(1, 6):
         image = utils.create_test_image(
             context=self.context, repo="testrepo" + str(i))
         uuids.append(six.text_type(image['uuid']))
     res = self.dbapi.list_images(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
コード例 #6
0
 def test_update_image(self, mock_get, mock_update, mock_write, mock_read):
     mock_get.return_value = None
     mock_read.side_effect = etcd.EtcdKeyNotFound
     image = utils.create_test_image(context=self.context)
     mock_read.side_effect = lambda *args: FakeEtcdResult(image.as_dict())
     self.dbapi.update_image(image.uuid, {'tag': 'newtag'})
     self.assertEqual(
         'newtag',
         json.loads(mock_update.call_args_list[0][0][0].value)['tag'])
コード例 #7
0
 def test_list_images(self):
     uuids = []
     for i in range(1, 6):
         image = utils.create_test_image(context=self.context,
                                         repo="testrepo" + str(i))
         uuids.append(six.text_type(image['uuid']))
     res = self.dbapi.list_image(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
コード例 #8
0
ファイル: test_image.py プロジェクト: openstack/higgins
    def test_update_image(self):
        image = utils.create_test_image(context=self.context)
        old_size = image.size
        new_size = '2000'
        self.assertNotEqual(old_size, new_size)

        res = self.dbapi.update_image(image.id,
                                      {'size': new_size})
        self.assertEqual(new_size, res.size)
コード例 #9
0
    def test_list_images_with_filters(self, mock_get, mock_write, mock_read):
        mock_get.return_value = None
        mock_read.side_effect = etcd.EtcdKeyNotFound
        image1 = utils.create_test_image(context=self.context,
                                         repo='imageone',
                                         uuid=uuidutils.generate_uuid())
        image2 = utils.create_test_image(context=self.context,
                                         repo='imagetwo',
                                         uuid=uuidutils.generate_uuid())
        images = [image1.as_dict(), image2.as_dict()]

        mock_read.side_effect = lambda *args: FakeEtcdMultipleResult(images)
        res = self.dbapi.list_image(self.context, filters={'repo': 'imageone'})
        self.assertEqual([image1.uuid], [r.uuid for r in res])

        res = self.dbapi.list_image(self.context, filters={'repo': 'imagetwo'})
        self.assertEqual([image2.uuid], [r.uuid for r in res])

        res = self.dbapi.list_image(self.context, filters={'repo': 'foo'})
        self.assertEqual([], [r.uuid for r in res])
コード例 #10
0
 def test_list_images(self, mock_get, mock_write, mock_read):
     mock_get.return_value = None
     mock_read.side_effect = etcd.EtcdKeyNotFound
     uuids = []
     images = []
     for i in range(1, 6):
         image = utils.create_test_image(context=self.context,
                                         repo='testrepo' + str(i))
         images.append(image.as_dict())
         uuids.append(image.uuid)
     mock_read.side_effect = lambda *args: FakeEtcdMultipleResult(images)
     res = self.dbapi.list_image(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
コード例 #11
0
    def test_list_image_with_filters(self):
        image1 = utils.create_test_image(context=self.context,
                                         repo='image-one',
                                         uuid=uuidutils.generate_uuid())
        image2 = utils.create_test_image(context=self.context,
                                         repo='image-two',
                                         uuid=uuidutils.generate_uuid())

        res = self.dbapi.list_image(self.context,
                                    filters={'repo': 'image-one'})
        self.assertEqual([image1.id], [r.id for r in res])

        res = self.dbapi.list_image(self.context,
                                    filters={'repo': 'image-two'})
        self.assertEqual([image2.id], [r.id for r in res])

        res = self.dbapi.list_image(self.context,
                                    filters={'repo': 'bad-image'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.list_image(self.context,
                                    filters={'repo': image1.repo})
        self.assertEqual([image1.id], [r.id for r in res])
コード例 #12
0
ファイル: test_image.py プロジェクト: openstack/higgins
    def test_list_images_with_filters(self):
        image1 = utils.create_test_image(
            context=self.context, repo='image-one',
            uuid=uuidutils.generate_uuid())
        image2 = utils.create_test_image(
            context=self.context, repo='image-two',
            uuid=uuidutils.generate_uuid())

        res = self.dbapi.list_images(self.context,
                                     filters={'repo': 'image-one'})
        self.assertEqual([image1.id], [r.id for r in res])

        res = self.dbapi.list_images(self.context,
                                     filters={'repo': 'image-two'})
        self.assertEqual([image2.id], [r.id for r in res])

        res = self.dbapi.list_images(self.context,
                                     filters={'repo': 'bad-image'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.list_images(
            self.context,
            filters={'repo': image1.repo})
        self.assertEqual([image1.id], [r.id for r in res])
コード例 #13
0
ファイル: test_image.py プロジェクト: openstack/higgins
    def test_list_images_sorted(self):
        uuids = []
        for i in range(5):
            image = utils.create_test_image(
                context=self.context, uuid=uuidutils.generate_uuid(),
                repo="testrepo" + str(i))
            uuids.append(six.text_type(image.uuid))
        res = self.dbapi.list_images(self.context, sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          self.dbapi.list_images,
                          self.context,
                          sort_key='foo')
コード例 #14
0
    def test_list_image_sorted(self):
        uuids = []
        for i in range(5):
            image = utils.create_test_image(context=self.context,
                                            uuid=uuidutils.generate_uuid(),
                                            repo="testrepo" + str(i))
            uuids.append(six.text_type(image.uuid))
        res = self.dbapi.list_image(self.context, sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          self.dbapi.list_image,
                          self.context,
                          sort_key='foo')
コード例 #15
0
    def test_get_all_images_with_pagination_marker(self, mock_image_list):
        image_list = []
        for id_ in range(4):
            test_image = utils.create_test_image(
                context=self.context,
                id=id_,
                repo='testrepo' + str(id_),
                uuid=uuidutils.generate_uuid())
            image_list.append(objects.Image(self.context, **test_image))
        mock_image_list.return_value = image_list[-1:]
        response = self.get('/v1/images/?limit=3&marker=%s' %
                            image_list[2].uuid)

        self.assertEqual(200, response.status_int)
        actual_images = response.json['images']
        self.assertEqual(1, len(actual_images))
        self.assertEqual(image_list[-1].uuid, actual_images[0].get('uuid'))
コード例 #16
0
ファイル: test_images.py プロジェクト: openstack/higgins
    def test_get_all_images_with_pagination_marker(
            self, mock_image_list, mock_policy_enforce):
        image_list = []
        for id_ in range(4):
            test_image = utils.create_test_image(
                context=self.context,
                id=id_,
                repo='testrepo' + str(id_),
                uuid=uuidutils.generate_uuid())
            image_list.append(objects.Image(self.context, **test_image))
        mock_image_list.return_value = image_list[-1:]
        response = self.get('/v1/images/?limit=3&marker=%s'
                            % image_list[2].uuid)

        self.assertEqual(200, response.status_int)
        actual_images = response.json['images']
        self.assertEqual(1, len(actual_images))
        self.assertEqual(image_list[-1].uuid,
                         actual_images[0].get('uuid'))
コード例 #17
0
ファイル: test_image.py プロジェクト: openstack/higgins
 def test_update_image_uuid(self):
     image = utils.create_test_image(context=self.context)
     self.assertRaises(exception.InvalidParameterValue,
                       self.dbapi.update_image, image.id,
                       {'uuid': ''})
コード例 #18
0
ファイル: test_image.py プロジェクト: openstack/higgins
 def test_pull_image_duplicate_repo(self):
     utils.create_test_image(context=self.context,
                             repo="ubuntu:latest")
     utils.create_test_image(context=self.context,
                             repo="ubuntu:14.04")
コード例 #19
0
ファイル: test_image.py プロジェクト: openstack/higgins
 def test_pull_image(self):
     utils.create_test_image(context=self.context,
                             repo="ubuntu:latest")
コード例 #20
0
 def test_pull_image_already_exists(self):
     utils.create_test_image(context=self.context, repo="ubuntu:latest")
     self.assertRaises(exception.ResourceExists,
                       utils.create_test_image,
                       context=self.context,
                       repo="ubuntu:latest")
コード例 #21
0
 def test_get_image_by_uuid(self):
     image = utils.create_test_image(context=self.context)
     res = self.dbapi.get_image_by_uuid(self.context, image.uuid)
     self.assertEqual(image.id, res.id)
     self.assertEqual(image.uuid, res.uuid)
コード例 #22
0
 def test_pull_image_duplicate_repo(self):
     utils.create_test_image(context=self.context, repo="ubuntu:latest")
     utils.create_test_image(context=self.context, repo="ubuntu:14.04")
コード例 #23
0
 def test_pull_image_duplicate_tag(self):
     utils.create_test_image(context=self.context, repo="ubuntu:latest")
     utils.create_test_image(context=self.context, repo="centos:latest")
コード例 #24
0
ファイル: test_image.py プロジェクト: openstack/higgins
 def test_pull_image_duplicate_tag(self):
     utils.create_test_image(context=self.context,
                             repo="ubuntu:latest")
     utils.create_test_image(context=self.context,
                             repo="centos:latest")
コード例 #25
0
 def test_pull_image(self):
     utils.create_test_image(context=self.context, repo="ubuntu:latest")
コード例 #26
0
ファイル: test_image.py プロジェクト: openstack/higgins
 def test_pull_image_already_exists(self):
     utils.create_test_image(context=self.context,
                             repo="ubuntu:latest")
     self.assertRaises(exception.ResourceExists,
                       utils.create_test_image,
                       context=self.context, repo="ubuntu:latest")
コード例 #27
0
ファイル: test_image.py プロジェクト: openstack/higgins
 def test_get_image_by_uuid(self):
     image = utils.create_test_image(context=self.context)
     res = self.dbapi.get_image_by_uuid(self.context, image.uuid)
     self.assertEqual(image.id, res.id)
     self.assertEqual(image.uuid, res.uuid)
コード例 #28
0
 def test_update_image_uuid(self):
     image = utils.create_test_image(context=self.context)
     self.assertRaises(exception.InvalidParameterValue,
                       self.dbapi.update_image, image.id, {'uuid': ''})
コード例 #29
0
 def test_pull_image(self, mock_get, mock_write, mock_read):
     mock_get.return_value = None
     mock_read.side_effect = etcd.EtcdKeyNotFound
     utils.create_test_image(context=self.context)
コード例 #30
0
 def test_pull_image_duplicate_tag(self, mock_get, mock_write, mock_read):
     mock_get.return_value = None
     mock_read.side_effect = etcd.EtcdKeyNotFound
     utils.create_test_image(context=self.context, repo="ubuntu:latest")
     utils.create_test_image(context=self.context, repo="centos:14.04")