Add some unit tests

This commit is contained in:
Jan Tuomi
2017-01-12 23:24:55 +02:00
parent e45bd5b454
commit c92af4f7d7
2 changed files with 38 additions and 2 deletions
+30 -2
View File
@@ -1,12 +1,40 @@
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 RotationTestCase(TestCase):
'''
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)
# Create your tests here.
'''
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.infoItems(req)
content = resp.content.decode('utf-8')
self.assertTrue(len(content) > 0)