Exemplo n.º 1
0
 def test_create_registry_already_exists(self):
     utils.create_test_registry(context=self.context,
                                uuid='123')
     with self.assertRaisesRegex(exception.RegistryAlreadyExists,
                                 'A registry with UUID 123.*'):
         utils.create_test_registry(context=self.context,
                                    uuid='123')
Exemplo n.º 2
0
 def test_create_registry_already_exists(self):
     utils.create_test_registry(context=self.context,
                                uuid='123')
     with self.assertRaisesRegex(exception.RegistryAlreadyExists,
                                 'A registry with UUID 123.*'):
         utils.create_test_registry(context=self.context,
                                    uuid='123')
Exemplo n.º 3
0
    def test_list_registries_with_filters(self):
        registry1 = utils.create_test_registry(
            name='registry-one',
            uuid=uuidutils.generate_uuid(),
            context=self.context)
        registry2 = utils.create_test_registry(
            name='registry-two',
            uuid=uuidutils.generate_uuid(),
            context=self.context)

        res = dbapi.list_registries(
            self.context, filters={'name': 'registry-one'})
        self.assertEqual([registry1.id], [r.id for r in res])

        res = dbapi.list_registries(
            self.context, filters={'name': 'registry-two'})
        self.assertEqual([registry2.id], [r.id for r in res])

        res = dbapi.list_registries(
            self.context, filters={'name': 'bad-registry'})
        self.assertEqual([], [r.id for r in res])

        res = dbapi.list_registries(
            self.context,
            filters={'name': registry1.name})
        self.assertEqual([registry1.id], [r.id for r in res])
Exemplo n.º 4
0
    def test_list_registries_with_filters(self):
        registry1 = utils.create_test_registry(
            name='registry-one',
            uuid=uuidutils.generate_uuid(),
            context=self.context)
        registry2 = utils.create_test_registry(
            name='registry-two',
            uuid=uuidutils.generate_uuid(),
            context=self.context)

        res = dbapi.list_registries(
            self.context, filters={'name': 'registry-one'})
        self.assertEqual([registry1.id], [r.id for r in res])

        res = dbapi.list_registries(
            self.context, filters={'name': 'registry-two'})
        self.assertEqual([registry2.id], [r.id for r in res])

        res = dbapi.list_registries(
            self.context, filters={'name': 'bad-registry'})
        self.assertEqual([], [r.id for r in res])

        res = dbapi.list_registries(
            self.context,
            filters={'name': registry1.name})
        self.assertEqual([registry1.id], [r.id for r in res])
Exemplo n.º 5
0
    def test_list_registries_with_list_filters(self):
        registry1 = utils.create_test_registry(name='registry-one',
                                               uuid=uuidutils.generate_uuid(),
                                               context=self.context)
        registry2 = utils.create_test_registry(name='registry-two',
                                               uuid=uuidutils.generate_uuid(),
                                               context=self.context)

        res = dbapi.list_registries(
            self.context, filters={'name': ['registry-one', 'registry-two']})
        uuids = sorted([registry1.uuid, registry2.uuid])
        self.assertEqual(uuids, sorted([r.uuid for r in res]))
Exemplo n.º 6
0
    def test_list_registries_with_list_filters(self):
        registry1 = utils.create_test_registry(
            name='registry-one',
            uuid=uuidutils.generate_uuid(),
            context=self.context)
        registry2 = utils.create_test_registry(
            name='registry-two',
            uuid=uuidutils.generate_uuid(),
            context=self.context)

        res = dbapi.list_registries(
            self.context, filters={'name': ['registry-one', 'registry-two']})
        uuids = sorted([registry1.uuid, registry2.uuid])
        self.assertEqual(uuids, sorted([r.uuid for r in res]))
Exemplo n.º 7
0
 def test_create_registry(self):
     username = '******'
     password = '******'
     registry = utils.create_test_registry(context=self.context,
                                           username=username,
                                           password=password)
     self.assertEqual(username, registry.username)
     self.assertEqual(password, registry.password)
Exemplo n.º 8
0
 def test_create_registry(self):
     username = '******'
     password = '******'
     registry = utils.create_test_registry(context=self.context,
                                           username=username,
                                           password=password)
     self.assertEqual(username, registry.username)
     self.assertEqual(password, registry.password)
Exemplo n.º 9
0
 def test_get_registry_by_name(self):
     username = '******'
     password = '******'
     registry = utils.create_test_registry(context=self.context,
                                           username=username,
                                           password=password)
     res = dbapi.get_registry_by_name(self.context, registry.name)
     self.assertEqual(registry.id, res.id)
     self.assertEqual(registry.uuid, res.uuid)
     self.assertEqual(username, res.username)
     self.assertEqual(password, res.password)
Exemplo n.º 10
0
    def test_update_registry(self):
        registry = utils.create_test_registry(context=self.context)
        old_name = registry.name
        new_name = 'new-name'
        new_password = '******'
        self.assertNotEqual(old_name, new_name)

        res = dbapi.update_registry(self.context, registry.id,
                                    {'name': new_name,
                                     'password': new_password})
        self.assertEqual(new_name, res.name)
        self.assertEqual(new_password, res.password)
Exemplo n.º 11
0
 def test_get_registry_by_name(self):
     username = '******'
     password = '******'
     registry = utils.create_test_registry(context=self.context,
                                           username=username,
                                           password=password)
     res = dbapi.get_registry_by_name(
         self.context, registry.name)
     self.assertEqual(registry.id, res.id)
     self.assertEqual(registry.uuid, res.uuid)
     self.assertEqual(username, res.username)
     self.assertEqual(password, res.password)
Exemplo n.º 12
0
    def test_update_registry(self):
        registry = utils.create_test_registry(context=self.context)
        old_name = registry.name
        new_name = 'new-name'
        new_password = '******'
        self.assertNotEqual(old_name, new_name)

        res = dbapi.update_registry(self.context, registry.id,
                                    {'name': new_name,
                                     'password': new_password})
        self.assertEqual(new_name, res.name)
        self.assertEqual(new_password, res.password)
Exemplo n.º 13
0
    def test_list_registries_sorted(self):
        uuids = []
        for i in range(5):
            registry = utils.create_test_registry(
                uuid=uuidutils.generate_uuid(),
                context=self.context,
                name='registry' + str(i))
            uuids.append(six.text_type(registry.uuid))
        res = dbapi.list_registries(self.context, sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          dbapi.list_registries,
                          self.context,
                          sort_key='foo')
Exemplo n.º 14
0
    def test_list_registries_sorted(self):
        uuids = []
        for i in range(5):
            registry = utils.create_test_registry(
                uuid=uuidutils.generate_uuid(),
                context=self.context,
                name='registry' + str(i))
            uuids.append(str(registry.uuid))
        res = dbapi.list_registries(self.context, sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          dbapi.list_registries,
                          self.context,
                          sort_key='foo')
Exemplo n.º 15
0
 def test_list_registries(self):
     uuids = []
     passwords = []
     for i in range(1, 6):
         password = '******' + str(i)
         passwords.append(password)
         registry = utils.create_test_registry(
             uuid=uuidutils.generate_uuid(),
             context=self.context,
             name='registry' + str(i),
             password=password)
         uuids.append(str(registry['uuid']))
     res = dbapi.list_registries(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
     res_passwords = [r.password for r in res]
     self.assertEqual(sorted(passwords), sorted(res_passwords))
Exemplo n.º 16
0
 def test_list_registries(self):
     uuids = []
     passwords = []
     for i in range(1, 6):
         password = '******' + str(i)
         passwords.append(password)
         registry = utils.create_test_registry(
             uuid=uuidutils.generate_uuid(),
             context=self.context,
             name='registry' + str(i),
             password=password)
         uuids.append(six.text_type(registry['uuid']))
     res = dbapi.list_registries(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
     res_passwords = [r.password for r in res]
     self.assertEqual(sorted(passwords), sorted(res_passwords))
Exemplo n.º 17
0
    def test_get_all_registries_with_pagination_marker(self,
                                                       mock_registry_list):
        registry_list = []
        for id_ in range(4):
            test_registry = utils.create_test_registry(
                id=id_,
                uuid=uuidutils.generate_uuid(),
                name='registry' + str(id_),
                context=self.context)
            registry_list.append(
                objects.Registry(self.context, **test_registry))
        mock_registry_list.return_value = registry_list[-1:]
        response = self.get('/v1/registries/?limit=3&marker=%s' %
                            registry_list[2].uuid)

        self.assertEqual(200, response.status_int)
        actual_registries = response.json['registries']
        self.assertEqual(1, len(actual_registries))
        self.assertEqual(registry_list[-1].uuid,
                         actual_registries[0].get('uuid'))
Exemplo n.º 18
0
 def test_destroy_registry_by_uuid(self):
     registry = utils.create_test_registry(context=self.context)
     dbapi.destroy_registry(self.context, registry.uuid)
     self.assertRaises(exception.RegistryNotFound,
                       dbapi.get_registry_by_uuid,
                       self.context, registry.uuid)
Exemplo n.º 19
0
 def test_update_registry_uuid(self):
     registry = utils.create_test_registry(context=self.context)
     self.assertRaises(exception.InvalidParameterValue,
                       dbapi.update_registry, self.context,
                       registry.id, {'uuid': ''})
Exemplo n.º 20
0
 def test_update_registry_uuid(self):
     registry = utils.create_test_registry(context=self.context)
     self.assertRaises(exception.InvalidParameterValue,
                       dbapi.update_registry, self.context,
                       registry.id, {'uuid': ''})
Exemplo n.º 21
0
 def test_destroy_registry_by_uuid(self):
     registry = utils.create_test_registry(context=self.context)
     dbapi.destroy_registry(self.context, registry.uuid)
     self.assertRaises(exception.RegistryNotFound,
                       dbapi.get_registry_by_uuid,
                       self.context, registry.uuid)