Sunday, February 2, 2020

Test -Error :AssertionError: 404 != 200

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+unsubscribe@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.

No comments:

Post a Comment