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])
def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None, filters=None): """Return a list of Registry objects. :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :param filters: filters when list registries. :returns: a list of :class:`Registry` object. """ db_registries = dbapi.list_registries(context, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir, filters=filters) return Registry._from_db_object_list(db_registries, cls, context)
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]))
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]))
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')
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')
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))
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))
def list(cls, context, limit=None, marker=None, sort_key=None, sort_dir=None, filters=None): """Return a list of Registry objects. :param context: Security context. :param limit: maximum number of resources to return in a single result. :param marker: pagination marker for large data sets. :param sort_key: column to sort results by. :param sort_dir: direction to sort. "asc" or "desc". :param filters: filters when list registries. :returns: a list of :class:`Registry` object. """ db_registries = dbapi.list_registries( context, limit=limit, marker=marker, sort_key=sort_key, sort_dir=sort_dir, filters=filters) return Registry._from_db_object_list(db_registries, cls, context)