Commit 346f57cc authored by ale's avatar ale
Browse files

fix stats() and add a test for it

parent 73753983
......@@ -119,8 +119,8 @@ class NoSpam(object):
def stats(self, site=None):
if not site:
site = '@all'
return (self._counters.get('ham:%s' % site, 0),
self._counters.get('spam:%s' % site, 0))
return (self._counters.get('comments{kind=ham,site=%s}' % site, 0),
self._counters.get('comments{kind=spam,site=%s}' % site, 0))
class BlogSpamCompatibleAPI(object):
......
......@@ -59,7 +59,15 @@ class TestAPI(unittest.TestCase):
del self.ns
self.ns = NoSpam(self.config)
self.ns._incr_counter('test')
self.assertEquals(2, self.ns._counters['test:@all'])
self.assertEquals(2, self.ns._counters['comments{kind=test,site=@all}'])
def test_stats(self):
self.ns._incr_counter('spam', 'example.org')
self.ns._incr_counter('spam', 'example.org')
self.ns._incr_counter('ham', 'example.org')
ham, spam = self.ns.stats('example.org')
self.assertEquals(1, ham)
self.assertEquals(2, spam)
if __name__ == '__main__':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment