Beispiel #1
0
def create_collection(session):
    """ Create some basic collection for testing. """
    collection = model.Collection(
        name='Fedora',
        version='17',
        status='Active',
        owner='toshio',
        branchname='f17',
        dist_tag='.fc17',
    )
    session.add(collection)

    collection = model.Collection(
        name='Fedora',
        version='18',
        status='Active',
        owner='toshio',
        branchname='f18',
        dist_tag='.fc18',
    )
    session.add(collection)

    collection = model.Collection(
        name='Fedora',
        version='devel',
        status='Under Development',
        owner='kevin',
        branchname='master',
        dist_tag='devel',
        allow_retire=True,
    )
    session.add(collection)

    collection = model.Collection(
        name='Fedora EPEL',
        version='6',
        status='Active',
        owner='kevin',
        branchname='el6',
        dist_tag='.el6',
    )
    session.add(collection)

    collection = model.Collection(
        name='Fedora EPEL',
        version='4',
        status='EOL',
        owner='kevin',
        branchname='el4',
        dist_tag='.el4',
    )
    session.add(collection)

    session.commit()
Beispiel #2
0
    def test_branch(self):
        """ Test the branch method of PackageListing. """
        create_package_acl(self.session)

        pkg = model.Package.by_name(self.session, 'guake')
        pkg_list = model.PackageListing.by_package_id(self.session, pkg.id)
        self.assertEqual(len(pkg_list), 2)
        self.assertEqual(pkg_list[0].collection.branchname, 'f18')
        self.assertEqual(len(pkg_list[0].acls), 2)
        self.assertEqual(pkg_list[1].collection.branchname, 'master')
        self.assertEqual(len(pkg_list[1].acls), 5)

        # Create a new collection
        new_collection = model.Collection(
            name='Fedora',
            version='19',
            status='Active',
            owner='toshio',
            branchname='f19',
            dist_tag='.fc19',
        )
        self.session.add(new_collection)
        self.session.commit()

        # Branch guake from master to f19
        pkg_list[1].branch(self.session, new_collection)

        pkg_list = model.PackageListing.by_package_id(self.session, pkg.id)
        self.assertEqual(len(pkg_list), 3)
        self.assertEqual(pkg_list[0].collection.branchname, 'f18')
        self.assertEqual(pkg_list[1].collection.branchname, 'master')
        self.assertEqual(len(pkg_list[1].acls), 5)
        self.assertEqual(pkg_list[2].collection.branchname, 'f19')
        self.assertEqual(len(pkg_list[2].acls), 5)
Beispiel #3
0
def convert_collections(pkg1_sess, pkg2_sess):
    ''' Convert the Collection from pkgdb1 to pkgdb2.
    '''
    cnt = 0
    for collect in pkg1_sess.query(P1Collection).all():
        branch = pkg1_sess.query(P1Branch).filter(
            P1Branch.collectionid == collect.id).one()
        new_collection = model.Collection(
            name=collect.name,
            version=collect.version,
            status=STATUS[collect.statuscode],
            owner=collect.owner,
            branchname=branch.gitbranchname or branch.branchname,
            dist_tag=branch.disttag,
            koji_name=collect.koji_name,
        )
        new_collection.id = collect.id
        pkg2_sess.add(new_collection)
        cnt += 1
    pkg2_sess.commit()
    print '%s collections added' % cnt