示例#1
0
    def f_coprs(self):
        self.c1 = models.Copr(name=u"foocopr", user=self.u1, repos="")
        self.c2 = models.Copr(name=u"foocopr", user=self.u2, repos="")
        self.c3 = models.Copr(name=u"barcopr", user=self.u2, repos="")
        self.basic_coprs_list = [self.c1, self.c2, self.c3]
        self.db.session.add_all(self.basic_coprs_list)

        self.c1_dir = models.CoprDir(name=u"foocopr", copr=self.c1, main=True)
        self.c2_dir = models.CoprDir(name=u"foocopr", copr=self.c2, main=True)
        self.c3_dir = models.CoprDir(name=u"barcopr", copr=self.c3, main=True)
        self.basic_copr_dir_list = [self.c1_dir, self.c2_dir, self.c3_dir]
        self.db.session.add_all(self.basic_copr_dir_list)
示例#2
0
    def test_delete_build_exceptions(self, f_users, f_coprs, f_mock_chroots,
                                     f_builds, f_db):
        for bc in self.b4_bc:
            bc.status = StatusEnum("succeeded")
            bc.ended_on = time.time()
        self.u1.admin = False

        self.db.session.add_all(self.b4_bc)
        self.db.session.add(self.b4)
        self.db.session.add(self.u1)
        self.db.session.commit()
        with pytest.raises(InsufficientRightsException):
            BuildsLogic.delete_build(self.u1, self.b4)

        self.b1_bc[0].status = StatusEnum("running")
        self.db.session.add(self.b1_bc[0])
        self.db.session.commit()
        with pytest.raises(ActionInProgressException):
            BuildsLogic.delete_build(self.u1, self.b1)

        self.copr_persistent = models.Copr(name=u"persistent_copr",
                                           user=self.u2,
                                           persistent=True)
        self.copr_dir = models.CoprDir(name="persistent_copr",
                                       main=True,
                                       copr=self.copr_persistent)
        self.build_persistent = models.Build(copr=self.copr_persistent,
                                             copr_dir=self.copr_dir,
                                             package=self.p2,
                                             user=self.u2,
                                             submitted_on=100)
        with pytest.raises(InsufficientRightsException):
            BuildsLogic.delete_build(self.u2, self.build_persistent)
示例#3
0
    def get_or_create(cls, copr, dirname, main=False):
        copr_dir = cls.get_by_copr(copr, dirname).first()

        if copr_dir:
            return copr_dir

        copr_dir = models.CoprDir(name=dirname, copr=copr, main=main)

        db.session.add(copr_dir)
        return copr_dir
示例#4
0
    def add(cls,
            user,
            name,
            selected_chroots,
            repos=None,
            description=None,
            instructions=None,
            check_for_duplicates=False,
            group=None,
            persistent=False,
            auto_prune=True,
            use_bootstrap_container=False,
            follow_fedora_branching=False,
            **kwargs):

        if not user.admin and persistent:
            raise exceptions.NonAdminCannotCreatePersistentProject()

        if not user.admin and not auto_prune:
            raise exceptions.NonAdminCannotDisableAutoPrunning()

        # form validation checks for duplicates
        cls.new(user, name, group, check_for_duplicates=check_for_duplicates)

        copr = models.Copr(name=name,
                           repos=repos or u"",
                           user=user,
                           description=description or u"",
                           instructions=instructions or u"",
                           created_on=int(time.time()),
                           persistent=persistent,
                           auto_prune=auto_prune,
                           use_bootstrap_container=use_bootstrap_container,
                           follow_fedora_branching=follow_fedora_branching,
                           **kwargs)

        if group is not None:
            UsersLogic.raise_if_not_in_group(user, group)
            copr.group = group

        copr_dir = models.CoprDir(main=True, name=name, copr=copr)

        db.session.add(copr_dir)
        db.session.add(copr)

        CoprChrootsLogic.new_from_names(copr, selected_chroots)

        db.session.flush()
        ActionsLogic.send_create_gpg_key(copr)

        return copr
示例#5
0
    def fork_copr(self, copr, name):
        fcopr = self.get(copr, name)
        if not fcopr:
            fcopr = self.create_object(models.Copr,
                                       copr,
                                       exclude=[
                                           "id", "group_id", "created_on",
                                           "scm_repo_url", "scm_api_type",
                                           "scm_api_auth_json", "persistent",
                                           "auto_prune", "contact",
                                           "webhook_secret"
                                       ])

            fcopr.forked_from_id = copr.id
            fcopr.user = self.user
            fcopr.user_id = self.user.id
            fcopr.created_on = int(time.time())
            if name:
                fcopr.name = name
            if self.group:
                fcopr.group = self.group
                fcopr.group_id = self.group.id

            fcopr_dir = models.CoprDir(name=fcopr.name, copr=fcopr, main=True)

            for chroot in list(copr.copr_chroots):
                CoprChrootsLogic.create_chroot(
                    self.user,
                    fcopr,
                    chroot.mock_chroot,
                    chroot.buildroot_pkgs,
                    chroot.repos,
                    comps=chroot.comps,
                    comps_name=chroot.comps_name,
                    with_opts=chroot.with_opts,
                    without_opts=chroot.without_opts)
            db.session.add(fcopr)
            db.session.add(fcopr_dir)

        return fcopr
示例#6
0
 def f_pr_dir(self):
     self.c4_dir = models.CoprDir(name=u"foocopr:PR", copr=self.c1,
             main=False)
     self.p4 = models.Package(
         copr=self.c1, copr_dir=self.c4_dir, name="hello-world",
         source_type=0)