add comments.empty

pull/108/head
Martin Zimmermann 10 years ago
parent 2a0898c928
commit 49f0031157

@ -237,6 +237,10 @@ class Controller(object):
return obj
def empty(self):
return self.db.engine.execute(
select([func.count(self.db.comments)])).fetchone()[0] == 0
def count(self, *threads):
"""Retrieve comment count for :param threads:
"""

@ -176,6 +176,11 @@ class TestController(unittest.TestCase):
self.controller.delete(c2.id)
self.assertIsNone(self.controller.get(p.id))
def test_empty(self):
self.assertTrue(self.controller.empty())
self.controller.new(IP, TH, dict(text="..."))
self.assertFalse(self.controller.empty())
def test_count(self):
threads = [Thread(0, "a"), None, Thread(1, "c")]
counter = [1, 0, 2]

Loading…
Cancel
Save