Skip to content

Commit

Permalink
ajout du test unitaire
Browse files Browse the repository at this point in the history
  • Loading branch information
artragis committed Oct 27, 2015
1 parent 7071ac2 commit 994a803
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions zds/forum/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,41 @@ def test_success_create_topic_with_a_post_in_get_method(self):
self.assertEqual(forum, response.context['forum'])
self.assertIsNotNone(response.context['form'])

def test_last_read_topic_url(self):
profile = ProfileFactory()
profile2 = ProfileFactory()
notvisited = ProfileFactory()
category, forum = create_category()
self.assertTrue(self.client.login(username=profile.user.username, password='hostel77'))
data = {
'title': 'Title of the topic',
'subtitle': 'Subtitle of the topic',
'text': 'A new post!'
}
self.client.post(reverse('topic-new') + '?forum={}'.format(forum.pk), data, follow=False)
self.client.logout()
self.assertTrue(self.client.login(username=profile2.user.username, password='hostel77'))
data = {
'title': 'Title of the topic',
'subtitle': 'Subtitle of the topic',
'text': 'A new post!'
}
self.client.post(reverse('topic-new') + '?forum={}'.format(forum.pk), data, follow=False)
self.client.logout()
self.assertTrue(self.client.login(username=profile.user.username, password='hostel77'))
topic = Topic.objects.last()
post = Post.objects.filter(topic__pk=topic.pk).first()
# for user
url = topic.resolve_last_read_post_absolute_url()
self.assertEquals(url, topic.get_absolute_url() + "?page=1#p" + str(post.pk))

# for anonymous
self.client.logout()
self.assertEquals(url, topic.get_absolute_url() + "?page=1#p" + str(post.pk))
# for no visit
self.assertTrue(self.client.login(username=notvisited.user.username, password='hostel77'))
self.assertEquals(url, topic.get_absolute_url() + "?page=1#p" + str(post.pk))

def test_success_create_topic_with_post_in_preview_in_ajax(self):
profile = ProfileFactory()
category, forum = create_category()
Expand Down

0 comments on commit 994a803

Please sign in to comment.