from django.test import TestCase from infoscreen.models import Rotation from infoscreen.models import SossoInfoItem from django.http import HttpRequest, HttpResponse import infoscreen.views class InfoscreenTestCase(TestCase): ''' Test cases for testing infoscreen methods ''' def setUp(self): ''' Create some dummy models ''' Rotation.objects.create(name="test_rot") SossoInfoItem.objects.create() def test_rotation_created(self): ''' Check if the dummy model actually exists ''' rot = Rotation.objects.get(name="test_rot") self.assertIsNotNone(rot) def test_sosso_infoitem_created(self): ''' Check if the dummy model actually exists ''' item = SossoInfoItem.objects.get() self.assertIsNotNone(item) def test_get_infoitems(self): ''' Check if infoItems returns a response with non-zero content length That would mean that something meaningful has been included in the response ''' req = HttpRequest() resp = infoscreen.views.info_items(req) content = resp.content.decode('utf-8') self.assertTrue(len(content) > 0)