def test_automatic_update_on_post_deleting(self): old_time = datetime.datetime.now() self.test_automatic_update_on_post_creating() PostPrototype._db_get_object(2).delete(self.checked_account) self.subcategory.update() self.assertEqual(self.subcategory.posts_count, 1) self.assertEqual(self.subcategory._model.last_poster.id, self.account.id) self.assertEqual(self.subcategory._model.last_thread.id, self.thread_2.id) self.assertTrue(self.subcategory.updated_at < old_time) PostPrototype._db_get_object(1).delete(self.checked_account) self.subcategory.update() self.assertEqual(self.subcategory.posts_count, 1) self.assertEqual(self.subcategory._model.last_poster.id, self.account.id) self.assertEqual(self.subcategory._model.last_thread.id, self.thread_1.id) self.assertTrue(self.subcategory.updated_at < old_time)
def test_automatic_update_on_post_deleting(self): old_time = datetime.datetime.now() self.test_automatic_update_on_post_creating() PostPrototype._db_get_object(1).delete(self.checked_account) self.thread.update() self.assertEqual(self.thread.posts_count, 1) self.assertEqual(self.thread._model.last_poster.id, self.account.id) self.assertTrue(self.thread.updated_at < old_time)
def test_create_post_success(self): self.assertEqual(ThreadReadInfoPrototype._db_count(), 0) response = self.client.post(url('forum:threads:create-post', self.thread3.id), {'text': 'thread3-test-post'}) post = PostPrototype._db_get_object(4) self.check_ajax_ok(response, data={'next_url': url('forum:threads:show', self.thread3.id) + ('?page=1#m%d' % post.id)}) self.assertEqual(Post.objects.all().count(), 5) self.assertEqual(ThreadReadInfoPrototype._db_count(), 1) self.assertEqual(ThreadReadInfoPrototype._db_get_object(0).thread_id, self.thread3.id)
def test_create_post_success(self): self.assertEqual(ThreadReadInfoPrototype._db_count(), 0) response = self.client.post(url('forum:threads:create-post', self.thread3.id), {'text': 'thread3-test-post'}) post = PostPrototype._db_get_object(4) self.check_ajax_ok(response, data={'next_url': url('forum:threads:show', self.thread3.id) + ('?page=1#m%d' % post.id)}) self.assertEqual(Post.objects.all().count(), 5) self.assertEqual(ThreadReadInfoPrototype._db_count(), 1) self.assertEqual(ThreadReadInfoPrototype._db_get_object(0).thread_id, self.thread3.id)
def test_update_thread_on_delete(self): with mock.patch('the_tale.forum.prototypes.ThreadPrototype.update') as thread_update: PostPrototype._db_get_object(0).delete(self.checked_account) self.assertEqual(thread_update.call_count, 1)
def test_update_thread_on_delete(self): with mock.patch('the_tale.forum.prototypes.ThreadPrototype.update') as thread_update: PostPrototype._db_get_object(0).delete(self.checked_account) self.assertEqual(thread_update.call_count, 1)