Added tests for example2 admin index.

This commit is contained in:
Andrews Medina 2013-06-05 22:35:57 -03:00
parent d2d65bdb3f
commit 25a9d72322
3 changed files with 23 additions and 16 deletions

View file

@ -1,16 +0,0 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)

View file

@ -0,0 +1 @@
from test_views import *

View file

@ -0,0 +1,22 @@
from django.contrib.auth import get_user_model
from django.core.urlresolvers import reverse
from django.test import TestCase, Client
class BaseIntegrationTest(TestCase):
"""
Base TestCase for integration tests.
"""
def setUp(self):
self.client = Client()
self.user = get_user_model()(username='user', is_staff=True,
is_superuser=True)
self.user.set_password("password")
self.user.save()
self.client.login(username='user', password='password')
class AdminIndexTest(BaseIntegrationTest):
def test_view_ok(self):
response = self.client.get(reverse("admin2:dashboard"))
self.assertContains(response, reverse("admin2:polls_poll_index"))