Exemple #1
0
 def test_if_everything_is_deleted(self):
     with DB.Connect() as cursor:
         DB.delete_entry(cursor, 1)
         e_ids = DB.get_ids(cursor, 'entry')
         c_ids = DB.get_ids(cursor, 'entry_comment')
     self.assertEqual(0, len(e_ids))
     self.assertEqual(0, len(c_ids))
Exemple #2
0
 def test_if_date_sorting_works(self):
     with DB.Connect() as cursor:
         self.entry.date = '5.06.2017'
         DB.insert_one(cursor, self.entry)
         self.entry.id_ = 2
         self.entry.date = '7.06.2017'
         DB.insert_one(cursor, self.entry)
         self.assertEqual([2, 1], list(DB.get_ids('entry')))
Exemple #3
0
 def test_if_ids_correctly_returned_from_entry(self):
     with DB.Connect() as cursor:
         DB.insert_one(cursor, self.entry)
         self.entry.id_ = 2
         DB.insert_one(cursor, self.entry)
         self.entry.id_ = 3
         DB.insert_one(cursor, self.entry)
         self.assertEqual({1, 2, 3}, set(DB.get_ids(cursor, 'entry')))
Exemple #4
0
 def test_if_ids_returned_if_tag_is_matched(self):
     with DB.Connect() as cursor:
         DB.insert_one(cursor, self.entry)
         self.entry.id_ = 2
         DB.insert_one(cursor, self.entry)
         self.entry.id_ = 3
         self.entry.tags = ' testtag2 '
         DB.insert_one(cursor, self.entry)
         self.assertEqual({1, 2}, set(DB.get_ids(cursor, 'entry', tag='testtag1')))
Exemple #5
0
 def test_if_ids_correctly_returned_from_entry_comment(self):
     self.entry.type_ = 'entry_comment'
     self.entry.entry_id = 321
     with DB.Connect() as cursor:
         DB.insert_one(cursor, self.entry)
         self.entry.id_ = 2
         DB.insert_one(cursor, self.entry)
         self.entry.id_ = 3
         DB.insert_one(cursor, self.entry)
         self.assertEqual({1, 2, 3}, set(DB.get_ids(cursor, 'entry_comment')))
Exemple #6
0
 def test_if_ids_if_nsfw_filtering_on(self):
     settings.NSFW_FILTER = True
     with DB.Connect() as cursor:
         self.entry.is_nsfw = True
         DB.insert_one(cursor, self.entry)
         self.entry.id_ = 2
         self.entry.is_nsfw = True
         DB.insert_one(cursor, self.entry)
         self.entry.id_ = 3
         self.entry.is_nsfw = False
         DB.insert_one(cursor, self.entry)
         self.assertEqual({3}, set(DB.get_ids(cursor, 'entry')))
Exemple #7
0
 def test_if_decorator_works_when_cursor_not_passed(self):
     with DB.Connect() as cursor:
         DB.insert_one(cursor, self.entry)
         self.entry.id_ = 2
         DB.insert_one(cursor, self.entry)
     self.assertEqual({1, 2}, set(DB.get_ids('entry')))