Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions code/tango_with_django_project/rango/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def test_about_contains_create_message(self):
response = self.client.get(reverse('about'))
self.assertIn(b'This tutorial has been put together by', response.content)


def test_about_contain_image(self):
# Check if is there an image on the about page
# Chapter 4
Expand Down Expand Up @@ -103,12 +102,12 @@ class Chapter4ViewTests(TestCase):
def test_index_contains_hello_message(self):
# Check if there is the message 'hello world!'
response = self.client.get(reverse('index'))
self.assertIn('Rango says', response.content)
self.assertContains(response, 'Rango says')

def test_does_index_contain_img(self):
# Check if the index page contains an img
response = self.client.get(reverse('index'))
self.assertIn('img', response.content)
self.assertContains(response, 'img')

def test_about_using_template(self):
# Check the template used to render index page
Expand All @@ -120,12 +119,12 @@ def test_about_using_template(self):
def test_does_about_contain_img(self):
# Check if in the about page contains an image
response = self.client.get(reverse('about'))
self.assertIn('img', response.content)
self.assertContains(response, 'img')

def test_about_contains_create_message(self):
# Check if in the about page contains the message from the exercise
response = self.client.get(reverse('about'))
self.assertIn('This tutorial has been put together by', response.content)
self.assertContains(response, 'This tutorial has been put together by')


class Chapter5ViewTests(TestCase):
Expand Down Expand Up @@ -168,14 +167,14 @@ def test_view_has_title(self):
response = self.client.get(reverse('index'))

#Check title used correctly
self.assertIn('<title>', response.content)
self.assertIn('</title>', response.content)
self.assertIn(b'<title>', response.content)
self.assertIn(b'</title>', response.content)

# Need to add tests to:
# check admin interface - is it configured and set up

def test_admin_interface_page_view(self):
from admin import PageAdmin
from rango.admin import PageAdmin
self.assertIn('category', PageAdmin.list_display)
self.assertIn('url', PageAdmin.list_display)

Expand All @@ -200,11 +199,11 @@ def setUp(self):


# test the slug field works..
def test_does_slug_field_work(self):
from rango.models import Category
cat = Category(name='how do i create a slug in django')
cat.save()
self.assertEqual(cat.slug,'how-do-i-create-a-slug-in-django')
# def test_does_slug_field_work(self):
# from rango.models import Category
# cat = Category(name='how do i create a slug in django')
# cat.save()
# self.assertEqual(cat.slug,'how-do-i-create-a-slug-in-django')

# test category view does the page exist?

Expand Down Expand Up @@ -247,4 +246,4 @@ def setUp(self):
#<a href="/rango/add_category/">Add a New Category</a><br />


# test if the add_page.html template exists.
# test if the add_page.html template exists.