add comments.empty

This commit is contained in:
Martin Zimmermann 2014-07-25 20:05:15 +02:00
parent 2a0898c928
commit 49f0031157
2 changed files with 9 additions and 0 deletions

View File

@ -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:
"""

View File

@ -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]