From c92af4f7d7eac87ab416dd22478e05dfd5c68ff9 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Thu, 12 Jan 2017 23:24:55 +0200 Subject: [PATCH] Add some unit tests --- infoscreen/tests.py | 32 ++++++++++++++++++++++++++++++-- members/tests.py | 8 ++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/infoscreen/tests.py b/infoscreen/tests.py index da6a5a8..9c15d22 100644 --- a/infoscreen/tests.py +++ b/infoscreen/tests.py @@ -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) diff --git a/members/tests.py b/members/tests.py index 7ce503c..437021c 100644 --- a/members/tests.py +++ b/members/tests.py @@ -1,3 +1,11 @@ from django.test import TestCase +from members.models import Member # 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)