Skip to content

Instantly share code, notes, and snippets.

@vitorfs
Created Oct 8, 2017
Embed
What would you like to do?
from django.test import TestCase
from django.urls import resolve, reverse
from ..models import Board
from ..views import BoardListView
class HomeTests(TestCase):
def setUp(self):
self.board = Board.objects.create(name='Django', description='Django board.')
url = reverse('home')
self.response = self.client.get(url)
def test_home_view_status_code(self):
self.assertEquals(self.response.status_code, 200)
def test_home_url_resolves_home_view(self):
view = resolve('/')
self.assertEquals(view.func.view_class, BoardListView)
def test_home_view_contains_link_to_topics_page(self):
board_topics_url = reverse('board_topics', kwargs={'pk': self.board.pk})
self.assertContains(self.response, 'href="{0}"'.format(board_topics_url))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment