public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/council-webapp:master commit in: bot/tests/, bot/ircmeeting/
Date: Wed, 22 Jun 2011 07:59:17 +0000 (UTC)	[thread overview]
Message-ID: <1a137e470619a11e14ed9c0be48f24a062890d1b.betelgeuse@gentoo> (raw)

commit:     1a137e470619a11e14ed9c0be48f24a062890d1b
Author:     Joachim Filip Ignacy Bartosik <jbartosik <AT> gmail <DOT> com>
AuthorDate: Tue Jun 21 15:29:09 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Jun 22 07:22:05 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/council-webapp.git;a=commit;h=1a137e47

Close voting when last user allowed to vote voted.

---
 bot/ircmeeting/agenda.py |   10 +++++++++-
 bot/tests/run_test.py    |   11 +++++++++++
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/bot/ircmeeting/agenda.py b/bot/ircmeeting/agenda.py
index 928ff5f..775dfd9 100644
--- a/bot/ircmeeting/agenda.py
+++ b/bot/ircmeeting/agenda.py
@@ -79,6 +79,7 @@ class Agenda(object):
         self._voters = self._get_json(self.conf.voters_url)
         self._agenda = self._get_json(self.conf.agenda_url)
         self._votes = { }
+        self._voters.sort()
         for i in self._agenda:
             self._votes[i[0]] = { }
 
@@ -93,7 +94,14 @@ class Agenda(object):
           return(opt)
 
         self._votes[self._agenda[self._current_item][0]][nick] = self._agenda[self._current_item][1][opt]
-        return str.format(self.vote_confirm_msg, opt, self._agenda[self._current_item][1][opt])
+
+        users_who_voted = self._votes[self._agenda[self._current_item][0]].keys()
+        users_who_voted.sort()
+
+        reply = str.format(self.vote_confirm_msg, opt, self._agenda[self._current_item][1][opt])
+        if users_who_voted == self._voters:
+          reply += '. ' + self.end_vote()
+        return(reply)
 
     def _get_json(self, url):
         str = urllib.urlopen(url).read()

diff --git a/bot/tests/run_test.py b/bot/tests/run_test.py
index 9808ee6..3c43fef 100644
--- a/bot/tests/run_test.py
+++ b/bot/tests/run_test.py
@@ -406,6 +406,7 @@ class MeetBotTest(unittest.TestCase):
 
     def test_agenda_voting(self):
         test = self.get_simple_agenda_test()
+        test.M.config.agenda._voters.append('t')
         test.answer_should_match('20:13:50 <x> #startvote', 'Voting started\. ' +\
                                   'Available voting options are:\n0. opt1\n1. opt2\nVote ' +\
                                   '#vote <option number>.\nEnd voting with #endvote.')
@@ -427,6 +428,16 @@ class MeetBotTest(unittest.TestCase):
 
         assert(test.votes() == {'first item': {u'x': 'opt2', u'z': 'opt1'}, 'second item': {}})
 
+    def test_agenda_close_voting_after_last_vote(self):
+        test = self.get_simple_agenda_test()
+        test.answer_should_match('20:13:50 <x> #startvote', 'Voting started\. ' +\
+                                  'Available voting options are:\n0. opt1\n1. opt2\nVote ' +\
+                                  '#vote <option number>.\nEnd voting with #endvote.')
+        test.answer_should_match('20:13:50 <x> #startvote', 'Voting is already open. ' +\
+                                  'You can end it with #endvote.')
+        test.answer_should_match('20:13:50 <x> #vote 0', 'You voted for #0 - opt1')
+        test.answer_should_match('20:13:50 <z> #vote 0', 'You voted for #0 - opt1. Voting closed.')
+
 if __name__ == '__main__':
     os.chdir(os.path.join(os.path.dirname(__file__), '.'))
 



             reply	other threads:[~2011-06-22  7:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-22  7:59 Petteri Räty [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-07-18  7:41 [gentoo-commits] proj/council-webapp:master commit in: bot/tests/, bot/ircmeeting/ Petteri Räty
2011-06-25 11:55 Petteri Räty
2011-06-25 11:55 Petteri Räty
2011-06-22  7:59 Petteri Räty
2011-06-18 15:46 Petteri Räty
2011-06-18 15:46 Petteri Räty
2011-06-18 15:46 Petteri Räty
2011-06-18 15:46 Petteri Räty
2011-06-18 15:46 Petteri Räty
2011-06-18 15:46 Petteri Räty
2011-06-05 20:37 Petteri Räty

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1a137e470619a11e14ed9c0be48f24a062890d1b.betelgeuse@gentoo \
    --to=betelgeuse@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox