Monday, August 6, 2018

Re: response.status 404 testing problem

Had a thought overnight ... maybe the 301 (permanently redirected) is
because the staging server is using https and the server redirects from
http to https.

I'll start looking there.

If anyone has any advice on best practice for this I'd love to hear it.

Thanks

Mike

On 6/08/2018 2:08 PM, Mike Dewhirst wrote:
> Forgot to mention ...
>
> dev = Django 1.11.15, Python 3.6 and 2.7 on Windows 10
> staging = Django 1.11.15, Python 2.7 on Ubuntu 16.04 (no GUI) Apache 2.4
>
> Sorry
>
> Mike
>
> On 6/08/2018 1:44 PM, Mike Dewhirst wrote:
>> I have a test which succeeds in development but fails with Apache in
>> staging ...
>>
>> Here is the test ...
>>
>>     def test_course_view_not_found_status_code(self):
>>         # no course exists with pk of 99
>>         response = self.client.get(reverse('course:course_view',
>> kwargs={'pk': 99}))
>>         self.assertEquals(response.status_code, 404)
>>
>> The status code from the staging server with Apache is 301 <-- Huh?
>>
>> The test class tearDown() deletes all courses between each test.
>>
>> Here is the view ...
>>
>> def course_view(request, pk=None):
>>     course = get_object_or_404(Course, pk=pk)
>>     # login is needed if there are questions/answers
>>     if course.login_needed or request.user.is_authenticated:
>>         return course_login_required(request, course=course)
>>     else:
>>         return course_login_not_required(request, course=course)
>>
>> What am I doing wrong?
>>
>> Thanks
>>
>> Mike
>>
>


--

Climate Pty Ltd
PO Box 308
Mount Eliza
Vic 3930
Australia +61

T: 03 9034 3977
M: 0411 704 143


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6f5096c6-6273-9358-de9f-0990f031c97a%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment