Test -Error :AssertionError: 404 != 200

705 views
Skip to first unread message

Body Abdo

unread,
Feb 2, 2020, 10:05:19 AM2/2/20
to Django users
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')




Integr@te System

unread,
Feb 2, 2020, 2:00:57 PM2/2/20
to django...@googlegroups.com
Hi man,

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


--
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...@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.
Reply all
Reply to author
Forward
0 new messages