Hi man,

How about pk you expect to test by declare in test.py with '/post/264, so
!= 200 in result!?


On Sun, Feb 2, 2020, 22:05 Body Abdo <bodyabdo201...@gmail.com> wrote:

> Dear all
>
> I can't do the test -error is
> self.assertEqual(response.status_code, 200)
> AssertionError: 404 != 200
> My code is
> views.py
>
> class DetailPageView(DetailView):
>     model = Series
>     
> template_name='/var/www/project/tapelss/movies/archive/templates/archive/detail.html'
>
>
> urls.py
>
> app_name = 'archive'
> urlpatterns =[
>     path('',views.indexing, name ='indexing'),
>     path('post/<int:pk>/', DetailPageView.as_view(), name='post_detail'),
>     path('post',HomePageView.as_view(), name ='home'),
>     path('page',views.page, name= 'page'),
>
>
> tests.py
>
> def test_post_detail_view(self):
>     response = self.client.get('/post/264/')
>     no_response = self.client.get('/post/1000000/')
>     self.assertEqual(response.status_code, 200)
>     self.assertEqual(no_response.status_code, 404)
>     self.assertContains(response,'Nice body content')
>     self.assertTemplateUsed(response, 'detail.html')
>
>
>
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/284f9aed-8da2-4697-936c-a86a380f00a5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/284f9aed-8da2-4697-936c-a86a380f00a5%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP5HUWqTPBf%3DYpHWBZOVdXWmyTfY2KwhWiy7V%3DqREY_nYuRdpw%40mail.gmail.com.

Reply via email to