Files
web2.0-backend/infoscreen/tests.py
T
2017-01-19 17:55:59 +02:00

41 lines
1.1 KiB
Python

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