Commit ebcf42aa authored by Prozer's avatar Prozer Committed by Jeremy Pallats
Browse files

FIX #139 - Vote current status manual change

parent 85c0f9f1
Loading
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -559,7 +559,7 @@ class Admin(Action):
        return reply

    async def execute(self):
        #globe = cogdb.query.get_current_global(self.session)
        globe = cogdb.query.get_current_global(self.session)
        try:
            admin = cogdb.query.get_admin(self.session, self.duser)
        except cog.exc.NoMatch as exc:
@@ -569,8 +569,8 @@ class Admin(Action):
            func = getattr(self, self.args.subcmd)
            if self.args.subcmd == "remove":
                response = await func(admin)
            #elif self.args.subcmd == "cycle":
                #response = await func(globe)
            elif self.args.subcmd == "cycle":
                response = await func(globe)
            else:
                response = await func()
            if response:
@@ -2023,6 +2023,15 @@ class Voting(Action):
            msg = "New vote goal is **{goal}%**, current vote is {current_vote}%."\
                .format(goal=self.args.set, current_vote=globe.consolidation)

        elif self.args.force:
            try:
                cogdb.query.get_admin(self.session, self.duser)
            except cog.exc.NoMatch as exc:
                raise cog.exc.InvalidPerms("{} You are not an admin!".format(self.msg.author.mention)) from exc
            globe.consolidation = self.args.force
            msg = "Vote goal is **{goal}%**, forced current vote is {current_vote}%."\
                .format(goal=globe.vote_goal, current_vote=self.args.force)

        elif self.args.vote_tuple:
            vote_type, amount = cog.parse.parse_vote_tuple(self.args.vote_tuple)
            vote = cogdb.query.add_vote(self.session, self.msg.author.id, vote_type, amount)
+1 −0
Original line number Diff line number Diff line
@@ -772,6 +772,7 @@ def subs_vote(subs, prefix):
    CMD_MAP['Voting'] = 'vote'
    sub.add_argument('vote_tuple', nargs='*', help='format either: cons 1 or 5 prep')
    sub.add_argument('--set', '-s', type=int, help='Set vote goal.')
    sub.add_argument('--force', '-fs', type=int, help='Force set the current vote status.')
    sub.add_argument('--display', '-d', action='store_true', help='Display the current vote goal.')
    sub.add_argument('--summary', action='store_true', help='Display the admin summary of votes this cycle.')

+8 −0
Original line number Diff line number Diff line
@@ -1789,6 +1789,14 @@ async def test_cmd_vote_set_goal(f_bot, f_admins, f_dusers, f_global_testbed, f_
    f_bot.send_message.assert_called_with(msg.channel, 'New vote goal is **75%**, current vote is 77%.')


@pytest.mark.asyncio
async def test_cmd_vote_set_current(f_bot, f_admins, f_dusers, f_global_testbed, f_vote_testbed, db_cleanup):
    msg = fake_msg_gears("!vote -fs 42")

    await action_map(msg, f_bot).execute()
    f_bot.send_message.assert_called_with(msg.channel, 'Vote goal is **0%**, forced current vote is 42%.')


@pytest.mark.asyncio
async def test_cmd_vote_display(f_bot, f_admins, f_dusers, f_global_testbed, f_vote_testbed, db_cleanup):
    msg = fake_msg_gears("!vote --display")