def __unicode__(self): if self.action_type == ActionTypeEnum("delete"): return "Deleting {0} {1}".format(self.object_type, self.old_value) elif self.action_type == ActionTypeEnum("rename"): return "Renaming {0} from {1} to {2}.".format( self.object_type, self.old_value, self.new_value) elif self.action_type == ActionTypeEnum("legal-flag"): return "Legal flag on copr {0}.".format(self.old_value) return "Action {0} on {1}, old value: {2}, new value: {3}.".format( self.action_type, self.object_type, self.old_value, self.new_value)
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
def test_legal_flag_doesnt_block_copr_functionality(self, f_users, f_coprs, f_db): self.db.session.add(self.models.Action( object_type="copr", object_id=self.c1.id, action_type=ActionTypeEnum("legal-flag"))) self.db.session.commit() # test will fail if this raises exception CoprsLogic.raise_if_unfinished_blocking_action(self.c1, "ha, failed")
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
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) }