当前位置: 首页>>代码示例>>Python>>正文


Python actions_logic.ActionsLogic类代码示例

本文整理汇总了Python中coprs.logic.actions_logic.ActionsLogic的典型用法代码示例。如果您正苦于以下问题:Python ActionsLogic类的具体用法?Python ActionsLogic怎么用?Python ActionsLogic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ActionsLogic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_delete_build_as_admin

    def test_delete_build_as_admin(
            self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):

        self.b4.pkgs = "http://example.com/copr-keygen-1.58-1.fc20.src.rpm"
        expected_dir = self.b4.result_dir_name
        for bc in self.b4_bc:
            bc.status = StatusEnum("succeeded")
            bc.ended_on = time.time()

        self.u1.admin = True

        self.db.session.add_all(self.b4_bc)
        self.db.session.add(self.b4)
        self.db.session.add(self.u1)
        self.db.session.commit()

        expected_chroots_to_delete = set()
        for bchroot in self.b4_bc:
            expected_chroots_to_delete.add(bchroot.name)

        assert len(ActionsLogic.get_many().all()) == 0
        BuildsLogic.delete_build(self.u1, self.b4)
        self.db.session.commit()

        assert len(ActionsLogic.get_many().all()) == 1
        action = ActionsLogic.get_many().one()
        delete_data = json.loads(action.data)
        assert "chroots" in delete_data
        assert delete_data["result_dir_name"] == expected_dir
        assert expected_chroots_to_delete == set(delete_data["chroots"])

        with pytest.raises(NoResultFound):
            BuildsLogic.get(self.b4.id).one()
开发者ID:0-T-0,项目名称:copr,代码行数:33,代码来源:test_builds_logic.py

示例2: test_delete_build_basic

    def test_delete_build_basic(
            self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):

        self.b1.pkgs = "http://example.com/copr-keygen-1.58-1.fc20.src.rpm"
        expected_dir = self.b1.result_dir_name
        self.db.session.add(self.b1)
        self.db.session.commit()

        expected_chroots_to_delete = set()
        for bchroot in self.b1_bc:
            expected_chroots_to_delete.add(bchroot.name)

        assert len(ActionsLogic.get_many().all()) == 0
        BuildsLogic.delete_build(self.u1, self.b1)
        self.db.session.commit()

        assert len(ActionsLogic.get_many().all()) == 1
        action = ActionsLogic.get_many().one()
        delete_data = json.loads(action.data)
        assert "chroots" in delete_data
        assert delete_data["result_dir_name"] == expected_dir
        assert expected_chroots_to_delete == set(delete_data["chroots"])

        with pytest.raises(NoResultFound):
            BuildsLogic.get(self.b1.id).one()
开发者ID:0-T-0,项目名称:copr,代码行数:25,代码来源:test_builds_logic.py

示例3: remove_comps

    def remove_comps(cls, user, copr_chroot):
        UsersLogic.raise_if_cant_update_copr(
            user, copr_chroot.copr,
            "Only owners and admins may update their projects.")

        copr_chroot.comps_name = None
        copr_chroot.comps_zlib = None
        ActionsLogic.send_update_comps(copr_chroot)
        db.session.add(copr_chroot)
开发者ID:jhdulaney,项目名称:copr,代码行数:9,代码来源:coprs_logic.py

示例4: test_delete_build_no_chroots_to_clean

    def test_delete_build_no_chroots_to_clean(
            self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):

        for bchroot in self.b1_bc:
            bchroot.status = helpers.StatusEnum("skipped")

        self.db.session.commit()
        assert len(ActionsLogic.get_many().all()) == 0
        BuildsLogic.delete_build(self.u1, self.b1)
        self.db.session.commit()
        assert len(ActionsLogic.get_many().all()) == 0
开发者ID:0-T-0,项目名称:copr,代码行数:11,代码来源:test_builds_logic.py

示例5: on_auto_createrepo_change

def on_auto_createrepo_change(target_copr, value_acr, old_value_acr, initiator):
    """ Emit createrepo action when auto_createrepo re-enabled"""
    if old_value_acr == NEVER_SET:
        #  created new copr, not interesting
        return
    if not old_value_acr and value_acr:
        #  re-enabled
        ActionsLogic.send_createrepo(
            target_copr.user.name,
            target_copr.name,
            chroots=[chroot.name for chroot in target_copr.active_chroots]
        )
开发者ID:jhdulaney,项目名称:copr,代码行数:12,代码来源:coprs_logic.py

示例6: fork_copr

    def fork_copr(cls, copr, user, dstname, dstgroup=None):
        if dstgroup and not user.can_build_in_group(dstgroup):
            raise exceptions.InsufficientRightsException(
                "Only members may create projects in the particular groups.")

        fcopr = CoprsLogic.get_by_group_id(dstgroup.id, dstname).first() if dstgroup \
            else CoprsLogic.filter_without_group_projects(CoprsLogic.get(flask.g.user.name, dstname)).first()

        if fcopr:
            raise exceptions.DuplicateException("You already have {}/{} project".format(user.name, copr.name))

        # @TODO Move outside and properly test it
        def create_object(clazz, from_object, exclude=list()):
            arguments = {}
            for name, column in from_object.__mapper__.columns.items():
                if not name in exclude:
                    arguments[name] = getattr(from_object, name)
            return clazz(**arguments)

        fcopr = create_object(models.Copr, copr, exclude=["id", "group_id"])
        fcopr.forked_from_id = copr.id
        fcopr.owner = user
        fcopr.owner_id = user.id
        if dstname:
            fcopr.name = dstname
        if dstgroup:
            fcopr.group = dstgroup
            fcopr.group_id = dstgroup.id

        for chroot in list(copr.copr_chroots):
            CoprChrootsLogic.create_chroot(user, fcopr, chroot.mock_chroot, chroot.buildroot_pkgs,
                                           comps=chroot.comps, comps_name=chroot.comps_name)

        builds_map = {}
        for package in copr.packages:
            fpackage = create_object(models.Package, package, exclude=["id", "copr_id"])
            fpackage.copr = fcopr
            db.session.add(fpackage)

            build = package.last_build()
            if not build:
                continue

            fbuild = create_object(models.Build, build, exclude=["id", "copr_id", "package_id"])
            fbuild.copr = fcopr
            fbuild.package = fpackage
            fbuild.build_chroots = [create_object(models.BuildChroot, c, exclude=["id"]) for c in build.build_chroots]
            db.session.add(fbuild)
            builds_map[fbuild.id] = build.id

        ActionsLogic.send_fork_copr(copr, fcopr, builds_map)
        db.session.add(fcopr)
        return fcopr
开发者ID:tkdchen,项目名称:copr,代码行数:53,代码来源:complex_logic.py

示例7: test_re_enable_auto_createrepo_produce_action

    def test_re_enable_auto_createrepo_produce_action(
            self, f_users, f_coprs, f_mock_chroots, f_db):

        self.db.session.add_all(
            [self.u1, self.c1, self.mc1, self.mc2, self.mc3])


        username = self.u1.name
        coprname = self.c1.name
        copr_id = self.c1.id
        chroot = self.mc1.name

        # 1.ensure ACR enabled

        self.db.session.commit()
        c1_actual = CoprsLogic.get(self.u1.name, self.c1.name).one()
        assert c1_actual.auto_createrepo
        # 1. disabling ACR
        self.test_client.post(
            "/coprs/{0}/{1}/update/".format(username, coprname),
            data={"name": coprname, chroot: "y", "id": copr_id,
                  "disable_createrepo": True},
            follow_redirects=True
        )
        self.db.session.commit()

        # check current status
        c1_actual = CoprsLogic.get(username, coprname).one()
        assert not c1_actual.auto_createrepo
        # no actions issued before
        assert len(ActionsLogic.get_many().all()) == 0

        # 2. enabling ACR
        self.test_client.post(
            "/coprs/{0}/{1}/update/".format(username, coprname),
            data={"name": coprname, chroot: "y", "id": copr_id,
                  "disable_createrepo": "false"},
            follow_redirects=True
        )
        self.db.session.commit()

        c1_actual = CoprsLogic.get(username, coprname).one()

        # ACR enabled
        assert c1_actual.auto_createrepo
        # added action
        assert len(ActionsLogic.get_many().all()) > 0
        action = ActionsLogic.get_many(action_type=ActionTypeEnum("createrepo")).one()

        data_dict = json.loads(action.data)
        assert data_dict["username"] == username
        assert data_dict["projectname"] == coprname
开发者ID:0-T-0,项目名称:copr,代码行数:52,代码来源:test_coprs_general.py

示例8: test_fork_copr_sends_actions

    def test_fork_copr_sends_actions(self, mc_flask_g, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
        mc_flask_g.user.name = self.u2.name
        fc1, created = ComplexLogic.fork_copr(self.c1, self.u2, u"dstname")
        self.db.session.commit()

        actions = ActionsLogic.get_many(ActionTypeEnum("gen_gpg_key")).all()
        assert len(actions) == 1
        data = json.loads(actions[0].data)
        assert data["username"] == self.u2.name
        assert data["projectname"] == "dstname"

        actions = ActionsLogic.get_many(ActionTypeEnum("fork")).all()
        assert len(actions) == 1
        data = json.loads(actions[0].data)
        assert data["user"] == self.u2.name
        assert data["copr"] == "dstname"

        last_build, forked_build = self.c1.packages[0].builds[1], fc1.builds[0]
        assert data["builds_map"] == {str(forked_build.id): str(last_build.result_dir_name)}
开发者ID:RadimS97,项目名称:copr,代码行数:19,代码来源:test_complex_logic.py

示例9: fork_copr

    def fork_copr(cls, copr, user, dstname, dstgroup=None):
        forking = ProjectForking(user, dstgroup)
        fcopr = forking.fork_copr(copr, dstname)
        created = fcopr in db.session.new

        if fcopr.full_name == copr.full_name:
            raise exceptions.DuplicateException("Source project should not be same as destination")

        builds_map = {}
        for package in copr.packages:
            fpackage = forking.fork_package(package, fcopr)
            build = package.last_build()
            if not build:
                continue

            fbuild = forking.fork_build(build, fcopr, fpackage)
            builds_map[fbuild.id] = build.result_dir_name

        ActionsLogic.send_fork_copr(copr, fcopr, builds_map)
        return fcopr, created
开发者ID:lubomir,项目名称:copr,代码行数:20,代码来源:complex_logic.py

示例10: test_delete_build_basic

    def test_delete_build_basic(
            self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):
        self.db.session.commit()

        expected_chroots_to_delete = set()
        for bchroot in self.b1_bc:
            expected_chroots_to_delete.add(bchroot.name)

        assert len(ActionsLogic.get_many().all()) == 0
        BuildsLogic.delete_build(self.u1, self.b1)
        self.db.session.commit()

        assert len(ActionsLogic.get_many().all()) == 1
        action = ActionsLogic.get_many().one()
        delete_data = json.loads(action.data)
        assert "chroots" in delete_data
        assert expected_chroots_to_delete == set(delete_data["chroots"])

        with pytest.raises(NoResultFound):
            BuildsLogic.get(self.b1.id).one()
开发者ID:1dot75cm,项目名称:Copr,代码行数:20,代码来源:test_builds_logic.py

示例11: test_copr_logic_add_sends_create_gpg_key_action

    def test_copr_logic_add_sends_create_gpg_key_action(self, f_users, f_mock_chroots, f_db):
        name = u"project_1"
        selected_chroots = [self.mc1.name]

        CoprsLogic.add(self.u1, name, selected_chroots)
        self.db.session.commit()

        actions = ActionsLogic.get_many(ActionTypeEnum("gen_gpg_key")).all()
        assert len(actions) == 1
        data = json.loads(actions[0].data)
        assert data["username"] == self.u1.name
        assert data["projectname"] == name
开发者ID:danvratil,项目名称:copr,代码行数:12,代码来源:test_coprs_logic.py

示例12: delete_build

    def delete_build(cls, user, build, send_delete_action=True):
        """
        :type user: models.User
        :type build: models.Build
        """
        if not user.can_edit(build.copr):
            raise exceptions.InsufficientRightsException(
                "You are not allowed to delete build `{}`.".format(build.id))

        if not build.deletable:
            # from celery.contrib import rdb; rdb.set_trace()
            raise exceptions.ActionInProgressException(
                "You can not delete build `{}` which is not finished.".format(build.id),
                "Unfinished build")

        if send_delete_action and build.state not in ["canceled"]: # cancelled builds should have nothing in backend to delete
            ActionsLogic.send_delete_build(build)

        for build_chroot in build.build_chroots:
            db.session.delete(build_chroot)
        db.session.delete(build)
开发者ID:jhdulaney,项目名称:copr,代码行数:21,代码来源:builds_logic.py

示例13: test_delete_build_bad_src_pkg

    def test_delete_build_bad_src_pkg(
            self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):

        # has meaning only for the builds with old result dir naming schema

        self.b1.pkgs = "http://example.com/"
        self.db.session.add(self.b1)
        self.db.session.commit()

        expected_chroots_to_delete = set()
        for bchroot in self.b1_bc:
            bchroot.git_hash = None
            expected_chroots_to_delete.add(bchroot.name)

        assert len(ActionsLogic.get_many().all()) == 0
        BuildsLogic.delete_build(self.u1, self.b1)
        self.db.session.commit()

        assert len(ActionsLogic.get_many().all()) == 0

        with pytest.raises(NoResultFound):
            BuildsLogic.get(self.b1.id).one()
开发者ID:0-T-0,项目名称:copr,代码行数:22,代码来源:test_builds_logic.py

示例14: add

    def add(cls, user, name, selected_chroots, repos=None, description=None,
            instructions=None, check_for_duplicates=False, group=None, **kwargs):
        copr = models.Copr(name=name,
                           repos=repos or u"",
                           user_id=user.id,
                           description=description or u"",
                           instructions=instructions or u"",
                           created_on=int(time.time()),
                           **kwargs)

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

        # form validation checks for duplicates
        cls.new(user, copr, check_for_duplicates=check_for_duplicates)
        CoprChrootsLogic.new_from_names(copr, selected_chroots)

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

        return copr
开发者ID:RadimS97,项目名称:copr,代码行数:22,代码来源:coprs_logic.py

示例15: test_delete_build_some_chroots

    def test_delete_build_some_chroots(
            self, f_users, f_coprs, f_mock_chroots, f_builds, f_db):

        expected_chroots_to_delete = set([self.b1_bc[0].name,
                                          self.b1_bc[-1].name])
        for bchroot in self.b1_bc[1:-1]:
            bchroot.status = helpers.StatusEnum("skipped")

        self.db.session.commit()

        assert len(ActionsLogic.get_many().all()) == 0
        BuildsLogic.delete_build(self.u1, self.b1)
        self.db.session.commit()

        assert len(ActionsLogic.get_many().all()) == 1
        action = ActionsLogic.get_many().one()
        delete_data = json.loads(action.data)
        assert "chroots" in delete_data
        assert expected_chroots_to_delete == set(delete_data["chroots"])

        with pytest.raises(NoResultFound):
            BuildsLogic.get(self.b1.id).one()
开发者ID:1dot75cm,项目名称:Copr,代码行数:22,代码来源:test_builds_logic.py


注:本文中的coprs.logic.actions_logic.ActionsLogic类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。