# -*- coding: utf-8 -*- from __future__ import unicode_literals import socket from django.test import SimpleTestCase class DjangoAdminTestCase(SimpleTestCase): def test_djangoadmin(self): response = self.client.get('/djangoadmin', follow=True) self.assertContains(response, 'Django administration') class RootTestCase(SimpleTestCase): def setUp(self): super(RootTestCase, self).setUp() self.response = self.client.get('/') def test_root_template(self): response = self.response self.assertTemplateUsed(response, 'base/root.html') def test_root_context(self): response = self.response self.assertIn('hostname', response.context) hostname = socket.gethostname() self.assertEqual(response.context['hostname'], hostname) def test_root_content(self): response = self.response hostname = socket.gethostname().capitalize() self.assertContains(response, hostname)