Add some unit tests
This commit is contained in:
+30
-2
@@ -1,12 +1,40 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from infoscreen.models import Rotation
|
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):
|
def setUp(self):
|
||||||
Rotation.objects.create(name="test_rot")
|
Rotation.objects.create(name="test_rot")
|
||||||
|
SossoInfoItem.objects.create()
|
||||||
|
|
||||||
|
'''
|
||||||
|
Check if the dummy model actually exists
|
||||||
|
'''
|
||||||
def test_rotation_created(self):
|
def test_rotation_created(self):
|
||||||
rot = Rotation.objects.get(name="test_rot")
|
rot = Rotation.objects.get(name="test_rot")
|
||||||
self.assertIsNotNone(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)
|
||||||
|
|||||||
@@ -1,3 +1,11 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from members.models import Member
|
||||||
|
|
||||||
# Create your tests here.
|
# Create your tests here.
|
||||||
|
class MemberRegisterTestCase(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
memb = Member.objects.create(first_name="Tidus", last_name="Tester")
|
||||||
|
|
||||||
|
def test_member_created(self):
|
||||||
|
members = Member.objects.get(first_name="Tidus")
|
||||||
|
self.assertTrue(members)
|
||||||
|
|||||||
Reference in New Issue
Block a user