def test_if_comments_returned(self): with DB.Connect() as cursor: DB.insert_one(cursor, self.entry) self.entry.id_ = 1 self.entry.entry_id = 1 self.entry.type_ = 'entry_comment' DB.insert_one(cursor, self.entry) self.entry.id_ = 2 self.entry.entry_id = 1 self.entry.type_ = 'entry_comment' DB.insert_one(cursor, self.entry) result = list(DB.get_comments_by_entry_id(cursor, 1)) self.assertEqual(2, len(result)) result = list(DB.get_comments_by_entry_id(1)) # called without cursor passed self.assertEqual(2, len(result))
def test_if_comments_not_found(self): with DB.Connect() as cursor: DB.insert_one(cursor, self.entry) result = list(DB.get_comments_by_entry_id(cursor, 1)) self.assertEqual([], result)