diff --git a/isso/controllers/comments.py b/isso/controllers/comments.py index 2aa905f..4df712c 100644 --- a/isso/controllers/comments.py +++ b/isso/controllers/comments.py @@ -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: """ diff --git a/isso/tests/controllers/test_comments.py b/isso/tests/controllers/test_comments.py index cc72d5e..bec569b 100644 --- a/isso/tests/controllers/test_comments.py +++ b/isso/tests/controllers/test_comments.py @@ -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]