Sunday, August 5, 2018

Re: response.status 404 testing problem

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
>

--
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/dd876785-ecba-2a99-cf1f-676dabdeda08%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment