Add some unit tests
This commit is contained in:
+30
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user