Skip to content

Commit

Permalink
Add tests to check the home page contexts in each variant
Browse files Browse the repository at this point in the history
These tests can function as smoke tests for the front page, and
check that the elements we expect are present in the context for
core, South Africa and Nigeria.  (These could be extended to check
that the values of those context variables are as expected, based
on the db data, but for the moment this is better than nothing.)
  • Loading branch information
mhl committed Apr 2, 2014
1 parent 8bd6f47 commit 288fc6d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pombola/core/tests/test_views.py
@@ -1,7 +1,15 @@
from django_webtest import WebTest
from django.test import TestCase

from pombola.core import models

class HomeViewTest(TestCase):

def test_homepage_context(self):
response = self.client.get('/')
self.assertIn('featured_person', response.context)
self.assertIn('featured_persons', response.context)

class PositionViewTest(WebTest):
def tearDown(self):
self.position.delete()
Expand Down
15 changes: 14 additions & 1 deletion pombola/nigeria/tests.py
Expand Up @@ -2,9 +2,22 @@
import doctest
from . import views

from django.test import TestCase

from nose.plugins.attrib import attr

# Needed to run the doc tests in views.py

def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(views))
return suite
return suite

@attr(country='nigeria')
class HomeViewTest(TestCase):

def test_homepage_context(self):
response = self.client.get('/')
self.assertIn('featured_person', response.context)
self.assertIn('featured_persons', response.context)
self.assertIn('editable_content', response.context)
9 changes: 9 additions & 0 deletions pombola/south_africa/tests.py
Expand Up @@ -28,6 +28,15 @@

from nose.plugins.attrib import attr

@attr(country='south_africa')
class HomeViewTest(TestCase):

def test_homepage_context(self):
response = self.client.get('/')
self.assertIn('featured_person', response.context)
self.assertIn('featured_persons', response.context)
self.assertIn('news_categories', response.context)

@attr(country='south_africa')
class ConstituencyOfficesTestCase(WebTest):
def setUp(self):
Expand Down
1 change: 1 addition & 0 deletions run-tests
Expand Up @@ -15,6 +15,7 @@ update_exit_code() {
TEST_SETTINGS_MODULES=(
'pombola.settings.tests'
'pombola.settings.tests_kenya'
'pombola.settings.tests_nigeria'
'pombola.settings.tests_south_africa'
)

Expand Down

0 comments on commit 288fc6d

Please sign in to comment.