Esempio n. 1
0
 def test_subcategory_has_new_messages__new_post(self):
     SubCategoryReadInfoPrototype.read_all_in_subcategory(
         subcategory=self.subcategory, account=self.account)
     self.assertFalse(self.get_read_state().subcategory_has_new_messages(
         self.subcategory))
     PostPrototype.create(self.thread, self.account_2, 'post-new-text')
     self.assertTrue(self.get_read_state().subcategory_has_new_messages(
         self.subcategory))
Esempio n. 2
0
    def test_subcategory_has_new_messages__new_post_from_request_from_read_account(self):
        SubCategoryReadInfoPrototype.read_all_in_subcategory(subcategory=self.subcategory, account=self.account)
        self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))

        self.request_login(self.account.email)
        self.client.post(url('forum:threads:create-post', self.thread.id), {'text': 'thread3-test-post'})

        self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))
Esempio n. 3
0
    def test_thread_has_new_messages__category_read(self):
        read_state = self.get_read_state()
        self.assertTrue(read_state.thread_is_new(self.thread))

        SubCategoryReadInfoPrototype.read_all_in_subcategory(self.subcategory, self.account)
        read_state = self.get_read_state()

        self.assertFalse(read_state.thread_has_new_messages(self.thread))
Esempio n. 4
0
 def test_subcategory_has_new_messages__new_thread(self):
     SubCategoryReadInfoPrototype.read_all_in_subcategory(
         subcategory=self.subcategory, account=self.account)
     self.assertFalse(self.get_read_state().subcategory_has_new_messages(
         self.subcategory))
     ThreadPrototype.create(self.subcategory, 'new-threwad', self.account_2,
                            'thread-new-text')
     self.assertTrue(self.get_read_state().subcategory_has_new_messages(
         self.subcategory))
Esempio n. 5
0
    def test_thread_has_new_messages__category_read(self):
        read_state = self.get_read_state()
        self.assertTrue(read_state.thread_is_new(self.thread))

        SubCategoryReadInfoPrototype.read_all_in_subcategory(
            self.subcategory, self.account)
        read_state = self.get_read_state()

        self.assertFalse(read_state.thread_has_new_messages(self.thread))
Esempio n. 6
0
    def test_subcategory_has_new_messages__new_post_from_request(self):
        SubCategoryReadInfoPrototype.read_all_in_subcategory(
            subcategory=self.subcategory, account=self.account)
        self.assertFalse(self.get_read_state().subcategory_has_new_messages(
            self.subcategory))

        self.request_login(self.account_2.email)
        self.client.post(url('forum:threads:create-post', self.thread.id),
                         {'text': 'thread3-test-post'})

        self.assertTrue(self.get_read_state().subcategory_has_new_messages(
            self.subcategory))
Esempio n. 7
0
 def test_read_all_in_subcategory__unexisted_info(self):
     self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 0)
     read_info = SubCategoryReadInfoPrototype.read_all_in_subcategory(self.subcategory, self.account)
     self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 1)
     self.assertEqual(read_info.subcategory_id, self.subcategory.id)
     self.assertEqual(read_info.account_id, self.account.id)
     self.assertTrue(read_info.read_at > datetime.datetime.now() - datetime.timedelta(seconds=1))
     self.assertTrue(read_info.all_read_at > datetime.datetime.now() - datetime.timedelta(seconds=1))
Esempio n. 8
0
 def test_read_all_in_subcategory__unexisted_info(self):
     self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 0)
     read_info = SubCategoryReadInfoPrototype.read_all_in_subcategory(self.subcategory, self.account)
     self.assertEqual(SubCategoryReadInfoPrototype._db_count(), 1)
     self.assertEqual(read_info.subcategory_id, self.subcategory.id)
     self.assertEqual(read_info.account_id, self.account.id)
     self.assertTrue(read_info.read_at > datetime.datetime.now() - datetime.timedelta(seconds=1))
     self.assertTrue(read_info.all_read_at > datetime.datetime.now() - datetime.timedelta(seconds=1))
Esempio n. 9
0
 def test_subcategory_has_new_messages__read_all(self):
     SubCategoryReadInfoPrototype.read_all_in_subcategory(
         subcategory=self.subcategory, account=self.account)
     self.assertFalse(self.get_read_state().subcategory_has_new_messages(
         self.subcategory))
Esempio n. 10
0
 def read_all__all(self):
     for subcategory in SubCategoryPrototype.subcategories_visible_to_account(
             account=self.account):
         SubCategoryReadInfoPrototype.read_all_in_subcategory(
             subcategory=subcategory, account=self.account)
     return self.json_ok()
Esempio n. 11
0
 def read_all__one(self):
     SubCategoryReadInfoPrototype.read_all_in_subcategory(
         subcategory=self.subcategory, account=self.account)
     return self.json_ok()
Esempio n. 12
0
 def read_all__all(self):
     for subcategory in SubCategoryPrototype.subcategories_visible_to_account(account=self.account):
         SubCategoryReadInfoPrototype.read_all_in_subcategory(subcategory=subcategory, account=self.account)
     return self.json_ok()
Esempio n. 13
0
 def read_all__one(self):
     SubCategoryReadInfoPrototype.read_all_in_subcategory(subcategory=self.subcategory, account=self.account)
     return self.json_ok()
Esempio n. 14
0
 def test_subcategory_has_new_messages__new_post(self):
     SubCategoryReadInfoPrototype.read_all_in_subcategory(subcategory=self.subcategory, account=self.account)
     self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))
     PostPrototype.create(self.thread, self.account_2, 'post-new-text')
     self.assertTrue(self.get_read_state().subcategory_has_new_messages(self.subcategory))
Esempio n. 15
0
 def test_subcategory_has_new_messages__new_thread(self):
     SubCategoryReadInfoPrototype.read_all_in_subcategory(subcategory=self.subcategory, account=self.account)
     self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))
     ThreadPrototype.create(self.subcategory, 'new-threwad', self.account_2, 'thread-new-text')
     self.assertTrue(self.get_read_state().subcategory_has_new_messages(self.subcategory))
Esempio n. 16
0
 def test_subcategory_has_new_messages__read_all(self):
     SubCategoryReadInfoPrototype.read_all_in_subcategory(subcategory=self.subcategory, account=self.account)
     self.assertFalse(self.get_read_state().subcategory_has_new_messages(self.subcategory))