david / django-invitation-backend (http://code.welldev.org/django-invitation/)

A fork of django-invitation to use the new django-registration-backends branch. See http://bitbucket.org/ubernostrum/django-registr... for the reasons.

commit 12: 797ed1fbe4e8
parent 11: 70cf85b95b41
branch: default
Using TestCase.assertTemplateUsed rather than assertEqual on response.template.name. In a realistic environment, templates will often use inheritance, and so response.template would be a list, and assertEqual tests wouldn't pass. Using TestCase.assertTemplateUsed gives the same testing benefits, while making the tests more likely to work without changes in a real environment.
David Montgomery / davidlmontgomery
14 months ago

Changed (Δ28 bytes):

raw changeset »

invitation/tests.py (4 lines added, 4 lines removed)

Up to file-list invitation/tests.py:

@@ -166,22 +166,22 @@ class InvitationViewTests(InvitationTest
166
166
        response = self.client.get(reverse('invitation_invited',
167
167
                                           kwargs={ 'invitation_key': self.sample_key.key }))
168
168
        self.assertEqual(response.status_code, 200)
169
        self.assertEqual(response.template.name, 'invitation/invited.html')
169
        self.assertTemplateUsed(response, 'invitation/invited.html')
170
170
171
171
        # Expired key use the wrong key template.
172
172
        response = self.client.get(reverse('invitation_invited',
173
173
                                           kwargs={ 'invitation_key': self.expired_key.key }))
174
174
        self.assertEqual(response.status_code, 200)
175
        self.assertEqual(response.template.name, 'invitation/wrong_invitation_key.html')
175
        self.assertTemplateUsed(response, 'invitation/wrong_invitation_key.html')
176
176
177
177
        # Invalid key use the wrong key template.
178
178
        response = self.client.get(reverse('invitation_invited',
179
179
                                           kwargs={ 'invitation_key': 'foo' }))
180
180
        self.assertEqual(response.status_code, 200)
181
        self.assertEqual(response.template.name, 'invitation/wrong_invitation_key.html')
181
        self.assertTemplateUsed(response, 'invitation/wrong_invitation_key.html')
182
182
183
183
        # Nonexistent key use the wrong key template.
184
184
        response = self.client.get(reverse('invitation_invited',
185
185
                                           kwargs={ 'invitation_key': sha.new('foo').hexdigest() }))
186
186
        self.assertEqual(response.status_code, 200)
187
        self.assertEqual(response.template.name, 'invitation/wrong_invitation_key.html')
187
        self.assertTemplateUsed(response, 'invitation/wrong_invitation_key.html')