-
-
Save vitorfs/6b3cd0769f805ab38626f5bd97b4e5e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
from django.test import TestCase | |
from django.urls import resolve, reverse | |
from ..models import Board, Post, Topic | |
from ..views import PostListView | |
class TopicPostsTests(TestCase): | |
def setUp(self): | |
board = Board.objects.create(name='Django', description='Django board.') | |
user = User.objects.create_user(username='john', email='[email protected]', password='123') | |
topic = Topic.objects.create(subject='Hello, world', board=board, starter=user) | |
Post.objects.create(message='Lorem ipsum dolor sit amet', topic=topic, created_by=user) | |
url = reverse('topic_posts', kwargs={'pk': board.pk, 'topic_pk': topic.pk}) | |
self.response = self.client.get(url) | |
def test_status_code(self): | |
self.assertEquals(self.response.status_code, 200) | |
def test_view_function(self): | |
view = resolve('/boards/1/topics/1/') | |
self.assertEquals(view.func.view_class, PostListView) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment