From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QZILP-0000uj-OJ for garchives@archives.gentoo.org; Wed, 22 Jun 2011 07:59:28 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0B49A1C0D3; Wed, 22 Jun 2011 07:59:20 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id C006C1C0D3 for ; Wed, 22 Jun 2011 07:59:20 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 36FFD1B4004 for ; Wed, 22 Jun 2011 07:59:20 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id E248980040 for ; Wed, 22 Jun 2011 07:59:17 +0000 (UTC) From: "Petteri Räty" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Petteri Räty" Message-ID: Subject: [gentoo-commits] proj/council-webapp:master commit in: bot/tests/, bot/ircmeeting/ X-VCS-Repository: proj/council-webapp X-VCS-Files: bot/ircmeeting/agenda.py bot/ircmeeting/meeting.py bot/tests/run_test.py X-VCS-Directories: bot/tests/ bot/ircmeeting/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: bc787b2518ac4fedcffaaf24e14f04839c3d7d3a Date: Wed, 22 Jun 2011 07:59:17 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: ccb881303105a7d05230f0d4732764b3 commit: bc787b2518ac4fedcffaaf24e14f04839c3d7d3a Author: Joachim Filip Ignacy Bartosik gmail com= > AuthorDate: Mon Jun 20 16:58:30 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Wed Jun 22 07:22:05 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/council-webap= p.git;a=3Dcommit;h=3Dbc787b25 Add #changeitem command to MeetBot --- bot/ircmeeting/agenda.py | 25 +++++++++++++++++++++---- bot/ircmeeting/meeting.py | 3 +++ bot/tests/run_test.py | 20 ++++++++++++++------ 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/bot/ircmeeting/agenda.py b/bot/ircmeeting/agenda.py index 775dfd9..af03c3a 100644 --- a/bot/ircmeeting/agenda.py +++ b/bot/ircmeeting/agenda.py @@ -15,8 +15,8 @@ class Agenda(object): voting_already_closed_msg =3D "Voting is already closed. You can sta= rt it with #startvote." voting_open_so_item_not_changed_msg =3D "Voting is currently open so= I didn't change item. Please #endvote first" can_not_vote_msg =3D "You can not vote or change agenda. Only {} can= ." - not_a_number_msg =3D "Your vote was not recognized as a number. Plea= se retry." - out_of_range_msg =3D "Your vote was out of range!" + not_a_number_msg =3D "Your choice was not recognized as a number. Pl= ease retry." + out_of_range_msg =3D "Your choice was out of range!" vote_confirm_msg =3D "You voted for #{} - {}" =20 # Internal @@ -109,14 +109,20 @@ class Agenda(object): result =3D json.loads(str) return result =20 - def _to_voting_option_number(self, line): + def _to_number(self, line, upper_limit): if not line.isdigit(): return self.not_a_number_msg opt =3D int(line) - if opt < 0 or opt >=3D len(self._agenda[self._current_item][1]): + if opt < 0 or opt >=3D upper_limit: return self.out_of_range_msg return(opt) =20 + def _to_voting_option_number(self, line): + return(self._to_number(line, len(self._agenda[self._current_item= ][1]))) + + def _to_agenda_item_number(self, line): + return(self._to_number(line, len(self._agenda))) + def options(self): options_list =3D self._agenda[self._current_item][1] n =3D len(options_list) @@ -138,6 +144,17 @@ class Agenda(object): options_list.append(option_text) return str.format(self.added_option_msg, option_text) =20 + def change_agenda_item(self, line): + if not self.conf.manage_agenda: + return('') + if self._vote_open: + return self.voting_open_so_item_not_changed_msg + opt =3D self._to_agenda_item_number(line) + if opt.__class__ is not int: + return(opt) + self._current_item =3D opt + return(self.get_agenda_item()) + def remove_option(self, nick, line): if not self.conf.manage_agenda: return('') diff --git a/bot/ircmeeting/meeting.py b/bot/ircmeeting/meeting.py index 84949ed..c01176a 100644 --- a/bot/ircmeeting/meeting.py +++ b/bot/ircmeeting/meeting.py @@ -328,6 +328,9 @@ class MeetingCommands(object): def do_previtem(self, nick, time_, line, **kwargs): self.reply(self.config.agenda.prev_agenda_item()) =20 + def do_changeitem(self, nick, time_, line, **kwargs): + self.reply(self.config.agenda.change_agenda_item(line)) + def do_startvote(self, nick, time_, line, **kwargs): for messageline in self.config.agenda.start_vote().split('\n'): self.reply(messageline) diff --git a/bot/tests/run_test.py b/bot/tests/run_test.py index 3c43fef..1358d47 100644 --- a/bot/tests/run_test.py +++ b/bot/tests/run_test.py @@ -342,7 +342,7 @@ class MeetBotTest(unittest.TestCase): def get_simple_agenda_test(self): test =3D test_meeting.TestMeeting() test.set_voters(['x', 'z']) - test.set_agenda([['first item', ['opt1', 'opt2']], ['second item= ', []]]) + test.set_agenda([['first item', ['opt1', 'opt2']], ['second item= ', []], ['third item', []]]) test.M.config.manage_agenda =3D False =20 test.answer_should_match("20:13:50 #startmeeting", @@ -356,9 +356,16 @@ class MeetBotTest(unittest.TestCase): =20 # Test changing item before vote test.answer_should_match('20:13:50 #nextitem', 'Current agen= da item is second item.') - test.answer_should_match('20:13:50 #nextitem', 'Current agen= da item is second item.') + test.answer_should_match('20:13:50 #nextitem', 'Current agen= da item is third item.') + test.answer_should_match('20:13:50 #nextitem', 'Current agen= da item is third item.') + test.answer_should_match('20:13:50 #previtem', 'Current agen= da item is second item.') test.answer_should_match('20:13:50 #previtem', 'Current agen= da item is first item.') test.answer_should_match('20:13:50 #previtem', 'Current agen= da item is first item.') + test.answer_should_match('20:13:50 #changeitem 2', 'Current = agenda item is third item.') + test.answer_should_match('20:13:50 #changeitem 1', 'Current = agenda item is second item.') + test.answer_should_match('20:13:50 #changeitem 0', 'Current = agenda item is first item.') + test.answer_should_match('20:13:50 #changeitem 10', 'Your ch= oice was out of range!') + test.answer_should_match('20:13:50 #changeitem puppy', 'Your= choice was not recognized as a number. Please retry.') =20 # Test changing item during vote test.process('20:13:50 #startvote') @@ -366,13 +373,14 @@ class MeetBotTest(unittest.TestCase): 'open so I didn\'t change item. Please= #endvote first') test.answer_should_match('20:13:50 #previtem', 'Voting is cu= rrently ' +\ 'open so I didn\'t change item. Please= #endvote first') + test.answer_should_match('20:13:50 #changeitem 2', 'Voting i= s currently ' +\ + 'open so I didn\'t change item. Please= #endvote first') =20 # Test changing item after vote test.process('20:13:50 #endvote') test.answer_should_match('20:13:50 #nextitem', 'Current agen= da item is second item.') - test.answer_should_match('20:13:50 #nextitem', 'Current agen= da item is second item.') - test.answer_should_match('20:13:50 #previtem', 'Current agen= da item is first item.') test.answer_should_match('20:13:50 #previtem', 'Current agen= da item is first item.') + test.answer_should_match('20:13:50 #changeitem 2', 'Current = agenda item is third item.') =20 def test_agenda_option_listing(self): test =3D self.get_simple_agenda_test() @@ -412,7 +420,7 @@ class MeetBotTest(unittest.TestCase): '#vote