From a34886de698447edba850243aef3e2bc12cebae0 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Wed, 29 Nov 2017 17:41:30 +0100 Subject: [PATCH] unit tests for object to string methods for Holiday, Room, Item, Subject classes --- smash/web/tests/models/test_holiday.py | 16 ++++++++++++++++ smash/web/tests/models/test_item.py | 15 +++++++++++++++ smash/web/tests/models/test_room.py | 15 +++++++++++++++ smash/web/tests/models/test_subject.py | 12 ++++++++---- 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 smash/web/tests/models/test_holiday.py create mode 100644 smash/web/tests/models/test_item.py create mode 100644 smash/web/tests/models/test_room.py diff --git a/smash/web/tests/models/test_holiday.py b/smash/web/tests/models/test_holiday.py new file mode 100644 index 00000000..73fcbb25 --- /dev/null +++ b/smash/web/tests/models/test_holiday.py @@ -0,0 +1,16 @@ +import logging + +from django.test import TestCase + +from web.models import Holiday +from web.tests import create_worker + +logger = logging.getLogger(__name__) + + +class HolidayTests(TestCase): + def test_str(self): + holiday = Holiday(person=create_worker()) + + self.assertIsNotNone(str(holiday)) + self.assertIsNotNone(unicode(holiday)) diff --git a/smash/web/tests/models/test_item.py b/smash/web/tests/models/test_item.py new file mode 100644 index 00000000..a3d53bd9 --- /dev/null +++ b/smash/web/tests/models/test_item.py @@ -0,0 +1,15 @@ +import logging + +from django.test import TestCase + +from web.models import Item + +logger = logging.getLogger(__name__) + + +class ItemTests(TestCase): + def test_str(self): + item = Item(name="test item") + + self.assertIsNotNone(str(item)) + self.assertIsNotNone(unicode(item)) diff --git a/smash/web/tests/models/test_room.py b/smash/web/tests/models/test_room.py new file mode 100644 index 00000000..470aed6a --- /dev/null +++ b/smash/web/tests/models/test_room.py @@ -0,0 +1,15 @@ +import logging + +from django.test import TestCase + +from web.models import Room + +logger = logging.getLogger(__name__) + + +class RoomTests(TestCase): + def test_str(self): + room = Room(room_number=4, address="some street 2/3", city="Luxembourg") + + self.assertIsNotNone(str(room)) + self.assertIsNotNone(unicode(room)) diff --git a/smash/web/tests/models/test_subject.py b/smash/web/tests/models/test_subject.py index 8bfdafdd..5e290ada 100644 --- a/smash/web/tests/models/test_subject.py +++ b/smash/web/tests/models/test_subject.py @@ -1,9 +1,7 @@ from django.test import TestCase -from web.models import Appointment -from web.models import Visit -from web.tests.functions import create_study_subject, create_appointment -from web.tests.functions import create_visit +from web.models import Appointment, Visit +from web.tests.functions import create_study_subject, create_appointment, create_subject, create_visit class SubjectModelTests(TestCase): @@ -20,3 +18,9 @@ class SubjectModelTests(TestCase): self.assertTrue(subject.dead) self.assertTrue(visit_finished) self.assertEquals(Appointment.APPOINTMENT_STATUS_CANCELLED, appointment_status) + + def test_str(self): + subject = create_subject() + + self.assertIsNotNone(str(subject)) + self.assertIsNotNone(unicode(subject)) -- GitLab