Skip to content

Add to "We should add a test for that..." #110

Open

Description

@riseriyo

Suggestion: add to "We should add a test for that... " under section, Updating our views,

Change to:
"We should add a test for that in our class HomePageTests"

Activity

  1. michaelerobertsjr commented on Oct 18, 2014

    @michaelerobertsjr

    In the code example to add tests, I would also suggest that you clearify the code example. It should be made clear that the test file already has existing code that the test and import should be appended with:

    from django.contrib.auth import get_user_model
    .
    .
    .
    .
    class HomePageTests(TestCase):

    """Test whether our blog entries show up on the homepage"""
    
    def setUp(self):
        self.user = get_user_model().objects.create(username='some_user')
    
    def test_one_entry(self):
        Entry.objects.create(title='1-title', body='1-body', author=self.user)
        response = self.client.get('/')
        self.assertContains(response, '1-title')
        self.assertContains(response, '1-body')
    
    def test_two_entries(self):
        Entry.objects.create(title='1-title', body='1-body', author=self.user)
        Entry.objects.create(title='2-title', body='2-body', author=self.user)
        response = self.client.get('/')
        self.assertContains(response, '1-title')
        self.assertContains(response, '1-body')
        self.assertContains(response, '2-title')
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions