comparison polls/tests/test_views.py @ 1206:02181fa5ac9d modernize tip

Update to Django 1.9.
author Brian Neal <bgneal@gmail.com>
date Wed, 22 Jan 2025 17:58:16 -0600
parents 8789299c75b1
children
comparison
equal deleted inserted replaced
1205:510ef3cbf3e6 1206:02181fa5ac9d
97 response = self.client.get(reverse('polls-vote', kwargs={'poll_id': 97 response = self.client.get(reverse('polls-vote', kwargs={'poll_id':
98 poll.id}), follow=True) 98 poll.id}), follow=True)
99 99
100 self.assertEqual(len(response.redirect_chain), 1) 100 self.assertEqual(len(response.redirect_chain), 1)
101 if response.redirect_chain: 101 if response.redirect_chain:
102 self.assertEqual(response.redirect_chain[0][0], 102 self.assertEqual(
103 'http://testserver' + reverse('polls-detail', kwargs={'poll_id': poll.id})) 103 response.redirect_chain[0][0],
104 reverse('polls-detail', kwargs={'poll_id': poll.id}))
104 self.assertEqual(response.redirect_chain[0][1], 302) 105 self.assertEqual(response.redirect_chain[0][1], 302)
105 106
106 self.assertEqual(response.status_code, 200) 107 self.assertEqual(response.status_code, 200)
107 108
108 def testVoteActive(self): 109 def testVoteActive(self):
118 response = self.client.get(reverse('polls-vote', kwargs={'poll_id': 119 response = self.client.get(reverse('polls-vote', kwargs={'poll_id':
119 poll.id}), follow=True) 120 poll.id}), follow=True)
120 121
121 self.assertEqual(len(response.redirect_chain), 1) 122 self.assertEqual(len(response.redirect_chain), 1)
122 if response.redirect_chain: 123 if response.redirect_chain:
123 self.assertEqual(response.redirect_chain[0][0], 124 self.assertEqual(
124 'http://testserver' + reverse('polls-detail', kwargs={'poll_id': poll.id})) 125 response.redirect_chain[0][0],
126 reverse('polls-detail', kwargs={'poll_id': poll.id}))
125 self.assertEqual(response.redirect_chain[0][1], 302) 127 self.assertEqual(response.redirect_chain[0][1], 302)
126 128
127 self.assertEqual(response.status_code, 404) 129 self.assertEqual(response.status_code, 404)
128 130
129 def testVoteDisabled(self): 131 def testVoteDisabled(self):
144 {'poll_id': poll.id}, 146 {'poll_id': poll.id},
145 follow=True) 147 follow=True)
146 148
147 self.assertEqual(len(response.redirect_chain), 1) 149 self.assertEqual(len(response.redirect_chain), 1)
148 if response.redirect_chain: 150 if response.redirect_chain:
149 self.assertEqual(response.redirect_chain[0][0], 151 self.assertEqual(
150 'http://testserver' + reverse('polls-detail', kwargs={'poll_id': poll.id})) 152 response.redirect_chain[0][0],
153 reverse('polls-detail', kwargs={'poll_id': poll.id}))
151 self.assertEqual(response.redirect_chain[0][1], 302) 154 self.assertEqual(response.redirect_chain[0][1], 302)
152 155
153 self.assertEqual(response.status_code, 200) 156 self.assertEqual(response.status_code, 200)
154 157
155 choice = Choice.objects.get(pk=1) 158 choice = Choice.objects.get(pk=1)
163 {'choices': 1}, 166 {'choices': 1},
164 follow=True) 167 follow=True)
165 168
166 self.assertEqual(len(response.redirect_chain), 1) 169 self.assertEqual(len(response.redirect_chain), 1)
167 if response.redirect_chain: 170 if response.redirect_chain:
168 self.assertEqual(response.redirect_chain[0][0], 171 self.assertEqual(
169 'http://testserver' + reverse('polls-detail', kwargs={'poll_id': poll.id})) 172 response.redirect_chain[0][0],
173 reverse('polls-detail', kwargs={'poll_id': poll.id}))
170 self.assertEqual(response.redirect_chain[0][1], 302) 174 self.assertEqual(response.redirect_chain[0][1], 302)
171 175
172 self.assertEqual(response.status_code, 200) 176 self.assertEqual(response.status_code, 200)
173 177
174 choice = Choice.objects.get(pk=1) 178 choice = Choice.objects.get(pk=1)