Merge lp:~xavier-antoviaque/ibid/factoidknowonethings-723098 into lp:ibid

Proposed by XavierAntoviaque
Status: Needs review
Proposed branch: lp:~xavier-antoviaque/ibid/factoidknowonethings-723098
Merge into: lp:ibid
Diff against target: 33 lines (+11/-1)
2 files modified
ibid/plugins/factoid.py (+2/-1)
ibid/test/plugins/test_factoid.py (+9/-0)
To merge this branch: bzr merge lp:~xavier-antoviaque/ibid/factoidknowonethings-723098
Reviewer Review Type Date Requested Status
Keegan Carruthers-Smith Approve
Review via email: mp+94875@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Keegan Carruthers-Smith (keegan-csmith) wrote :

In ibid.utils there is a helper function called plural. So you can go plural(len(factoids), '', 's'). Otherwise this looks good so just gonna go ahead and approve it now.

review: Approve
Revision history for this message
Stefano Rivera (stefanor) wrote :

For translation purposes, plural(len(factoids, 'thing', 'things') is better. (Not that we have translation, but we try to keep that idea in mind...)

Unmerged revisions

1045. By XavierAntoviaque

Fixes #723098 - "I only know 1 things about foo"

Now uses singular in the error message, when there is only one factoid available and asked for a factoid number higher than 1.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/plugins/factoid.py'
2--- ibid/plugins/factoid.py 2011-08-12 10:04:25 +0000
3+++ ibid/plugins/factoid.py 2012-02-27 22:53:23 +0000
4@@ -296,9 +296,10 @@
5 factoids = get_factoid(event.session, name, None, pattern, is_regex,
6 literal=True)
7 if factoids:
8- event.addresponse(u"I only know %(number)d things about %(name)s", {
9+ event.addresponse(u"I only know %(number)d thing%(plural)s about %(name)s", {
10 u'number': len(factoids),
11 u'name': name,
12+ u'plural': len(factoids)>1 and 's' or '',
13 })
14
15
16
17=== modified file 'ibid/test/plugins/test_factoid.py'
18--- ibid/test/plugins/test_factoid.py 2011-02-01 14:24:21 +0000
19+++ ibid/test/plugins/test_factoid.py 2012-02-27 22:53:23 +0000
20@@ -133,3 +133,12 @@
21 self.assertResponseMatches('. is foo', '.*empty')
22 self.failIfResponseMatches('', '.*foo')
23 self.failIfResponseMatches('.', '.*foo')
24+
25+ def test_literal_number_too_large(self):
26+ self.assertSucceeds('Foo is bar')
27+ self.assertResponseMatches('literal foo #1', '1: is bar')
28+ self.assertResponseMatches('literal foo #2', 'I only know 1 thing about foo')
29+ self.assertSucceeds('Foo is also zorg')
30+ self.assertResponseMatches('literal foo #2', '2: is zorg')
31+ self.assertResponseMatches('literal foo #3', 'I only know 2 things about foo')
32+
33\ No newline at end of file

Subscribers

People subscribed via source and target branches