|
@@ -35,7 +35,7 @@ class CategoriesTrackerTests(ReadTrackerTests):
|
|
|
self.assertIsNone(self.category.last_post_on)
|
|
|
self.assertTrue(self.category.is_read)
|
|
|
|
|
|
- def test_anon_category_with_recent_reply_read(self):
|
|
|
+ def test_anon_category_recent_reply_read(self):
|
|
|
"""anon users content is always read"""
|
|
|
categoriestracker.make_read_aware(self.anon, self.categories)
|
|
|
self.category.last_post_on = timezone.now()
|
|
@@ -54,14 +54,14 @@ class CategoriesTrackerTests(ReadTrackerTests):
|
|
|
categoriestracker.make_read_aware(self.user, self.categories)
|
|
|
self.assertTrue(self.category.is_read)
|
|
|
|
|
|
- def test_make_read_aware_sets_read_flag_for_category_with_old_thread(self):
|
|
|
+ def test_make_read_aware_sets_read_flag_for_category_old_thread(self):
|
|
|
"""make_read_aware sets read flag on category with old thread"""
|
|
|
self.category.last_post_on = self.user.joined_on - timedelta(days=1)
|
|
|
|
|
|
categoriestracker.make_read_aware(self.user, self.categories)
|
|
|
self.assertTrue(self.category.is_read)
|
|
|
|
|
|
- def test_make_read_aware_sets_unread_flag_for_category_with_new_thread(self):
|
|
|
+ def test_make_read_aware_sets_unread_flag_for_category_new_thread(self):
|
|
|
"""make_read_aware sets unread flag on category with new thread"""
|
|
|
self.category.last_post_on = self.user.joined_on + timedelta(days=1)
|
|
|
|
|
@@ -77,7 +77,7 @@ class CategoriesTrackerTests(ReadTrackerTests):
|
|
|
categoriestracker.make_read_aware(self.user, self.categories)
|
|
|
self.assertTrue(self.category.is_read)
|
|
|
|
|
|
- def test_sync_record_for_category_with_old_thread_and_reply(self):
|
|
|
+ def test_sync_record_for_category_old_thread_and_reply(self):
|
|
|
"""
|
|
|
sync_record sets read flag on category with old thread,
|
|
|
then changes flag to unread when new reply is posted
|
|
@@ -96,7 +96,7 @@ class CategoriesTrackerTests(ReadTrackerTests):
|
|
|
categoriestracker.make_read_aware(self.user, self.categories)
|
|
|
self.assertFalse(self.category.is_read)
|
|
|
|
|
|
- def test_sync_record_for_category_with_new_thread(self):
|
|
|
+ def test_sync_record_for_category_new_thread(self):
|
|
|
"""
|
|
|
sync_record sets read flag on category with old thread,
|
|
|
then keeps flag to unread when new reply is posted
|
|
@@ -115,7 +115,7 @@ class CategoriesTrackerTests(ReadTrackerTests):
|
|
|
categoriestracker.make_read_aware(self.user, self.categories)
|
|
|
self.assertFalse(self.category.is_read)
|
|
|
|
|
|
- def test_sync_record_for_category_with_deleted_threads(self):
|
|
|
+ def test_sync_record_for_category_deleted_threads(self):
|
|
|
"""unread category reverts to read after its emptied"""
|
|
|
self.post_thread(self.user.joined_on + timedelta(days=1))
|
|
|
self.post_thread(self.user.joined_on + timedelta(days=1))
|
|
@@ -133,7 +133,7 @@ class CategoriesTrackerTests(ReadTrackerTests):
|
|
|
categoriestracker.make_read_aware(self.user, self.categories)
|
|
|
self.assertTrue(self.category.is_read)
|
|
|
|
|
|
- def test_sync_record_for_category_with_many_threads(self):
|
|
|
+ def test_sync_record_for_category_many_threads(self):
|
|
|
"""sync_record sets unread flag on category with many threads"""
|
|
|
self.post_thread(self.user.joined_on + timedelta(days=1))
|
|
|
self.post_thread(self.user.joined_on - timedelta(days=1))
|
|
@@ -152,6 +152,21 @@ class CategoriesTrackerTests(ReadTrackerTests):
|
|
|
categoriestracker.make_read_aware(self.user, self.categories)
|
|
|
self.assertFalse(self.category.is_read)
|
|
|
|
|
|
+ def test_sync_record_for_category_threads_behind_cutoff(self):
|
|
|
+ """
|
|
|
+ sync_record sets read flag on category with only thread being behind cutoff
|
|
|
+ """
|
|
|
+ self.post_thread(timezone.now() - timedelta(days=180))
|
|
|
+
|
|
|
+ read_thread = self.post_thread(timezone.now())
|
|
|
+
|
|
|
+ threadstracker.make_read_aware(self.user, read_thread)
|
|
|
+ threadstracker.read_thread(self.user, read_thread, read_thread.last_post)
|
|
|
+
|
|
|
+ category = Category.objects.get(pk=self.category.pk)
|
|
|
+ categoriestracker.make_read_aware(self.user, [category])
|
|
|
+ self.assertTrue(category.is_read)
|
|
|
+
|
|
|
def test_read_leaf_category(self):
|
|
|
"""read_category reads leaf category for user"""
|
|
|
categoriestracker.read_category(self.user, self.category)
|
|
@@ -281,3 +296,10 @@ class ThreadsTrackerTests(ReadTrackerTests):
|
|
|
for post in posts[:-1]:
|
|
|
self.assertTrue(post.is_read)
|
|
|
self.assertTrue(posts[-1].is_new)
|
|
|
+
|
|
|
+ # last post read will change readstate of categories
|
|
|
+ threadstracker.make_read_aware(self.user, self.thread)
|
|
|
+ threadstracker.read_thread(self.user, self.thread, posts[-1])
|
|
|
+
|
|
|
+ categoriestracker.make_read_aware(self.user, self.categories)
|
|
|
+ self.assertTrue(self.category.is_read)
|