Skip to content
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.

Commit

Permalink
Used the first() queryset method
Browse files Browse the repository at this point in the history
  • Loading branch information
claudep committed Jun 16, 2017
1 parent 8112496 commit fd52ff2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/testapp/tests/test_comment_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def testCreateValidComment(self):
response = self.client.post("/post/", data, REMOTE_ADDR=address)
self.assertEqual(response.status_code, 302)
self.assertEqual(Comment.objects.count(), 1)
c = Comment.objects.all()[0]
c = Comment.objects.first()
self.assertEqual(c.ip_address, address)
self.assertEqual(c.comment, "This is my comment")

Expand All @@ -136,7 +136,7 @@ def testCreateValidCommentIPv6(self):
response = self.client.post("/post/", data, REMOTE_ADDR=address)
self.assertEqual(response.status_code, 302)
self.assertEqual(Comment.objects.count(), 1)
c = Comment.objects.all()[0]
c = Comment.objects.first()
self.assertEqual(c.ip_address, address)
self.assertEqual(c.comment, "This is my comment")

Expand All @@ -156,7 +156,7 @@ def testCreateValidCommentIPv6Unpack(self):
response = self.client.post("/post/", data, REMOTE_ADDR=address)
self.assertEqual(response.status_code, 302)
self.assertEqual(Comment.objects.count(), 1)
c = Comment.objects.all()[0]
c = Comment.objects.first()
# We trim the '::ffff:' bit off because it is an IPv4 addr
self.assertEqual(c.ip_address, address[7:])
self.assertEqual(c.comment, "This is my comment")
Expand All @@ -169,7 +169,7 @@ def testPostAsAuthenticatedUser(self):
response = self.client.post("/post/", data, REMOTE_ADDR="1.2.3.4")
self.assertEqual(response.status_code, 302)
self.assertEqual(Comment.objects.count(), 1)
c = Comment.objects.all()[0]
c = Comment.objects.first()
self.assertEqual(c.ip_address, "1.2.3.4")
u = User.objects.get(username='normaluser')
self.assertEqual(c.user, u)
Expand Down Expand Up @@ -255,7 +255,7 @@ def receive(sender, **kwargs):

signals.comment_will_be_posted.connect(receive)
self.testCreateValidComment()
c = Comment.objects.all()[0]
c = Comment.objects.first()
self.assertFalse(c.is_public)

def testCommentNext(self):
Expand Down Expand Up @@ -291,7 +291,7 @@ def testCommentDoneView(self):
pk = int(match.group('pk'))
response = self.client.get(location)
self.assertTemplateUsed(response, "comments/posted.html")
self.assertEqual(response.context[0]["comment"], Comment.objects.get(pk=pk))
self.assertEqual(response.context["comment"], Comment.objects.get(pk=pk))

def testCommentNextWithQueryString(self):
"""
Expand Down

0 comments on commit fd52ff2

Please sign in to comment.