Commit dc6df21e authored by HERBERT Ryan's avatar HERBERT Ryan
Browse files

test/controllers/notification.py fixed remaining issues with notification controller tests

parent 4553850f
......@@ -12,7 +12,7 @@ class NotificationController(unittest.TestCase):
def __init__(self, p):
global auth, session, request
unittest.TestCase(self, p)
unittest.TestCase.__init__(self, p)
def setUp(self):
# Load the to-be-tested file
......@@ -42,11 +42,11 @@ class NotificationController(unittest.TestCase):
def testIndex(self):
res = index()
self.assertTrue(res.hasKey('message'), "index has returned an incomplete response")
self.assertTrue(res.has_key('message'), "index has returned an incomplete response")
def testAdd(self):
res = add()
self.assertTrue(res.hasKey('message'), "add has returned an incomplete response")
self.assertNotEqual(res.has_key('message'), "add has returned an incomplete response")
def test1AddForm(self):
request.vars['title'] = "test title"
......@@ -56,40 +56,38 @@ class NotificationController(unittest.TestCase):
request.vars['expiration'] = '2100-10-30'
res = add_form()
self.assertTrue(res.hasKey('message'), "add_form has returned an incomplete response")
self.assertNotEqual(res.find('notification added'), -1, "add notification failed")
query = db(db.notification.id > 0).select()
self.assertTrue(query, "add_form was unable to create a notification")
def testEdit(self):
request.vars['id'] = fake_notification_id
res = edit()
assertTrue(res.hasKey('message'), "edit returned an incomplete response")
self.assertTrue(res.has_key('message'), "edit returned an incomplete response")
def test1EditForm(self):
date = date.today()
today.replace(year = today.year+1)
def test2EditForm(self):
curdate = date.today()
curdate.replace(year = curdate.year+1)
request.vars['id'] = fake_notification_id
request.vars['title'] = "test title"
request.vars['message_content'] = "test content"
request.vars['message_type'] = "type"
request.vars['priority'] = "header"
request.vars['expiration'] = date.__str__()
request.vars['expiration'] = str(curdate)
res = edit_form()
note = db.notification[fake_notification_id]
self.assertTrue(res.hasKey('message'), "edit_form returned an incomplete response")
self.assertNotEquals(res.find('notification updated'), -1, "edit_form returned an incomplete response")
self.assertTrue(note.title == "test title", "edit_form was unable to update the title")
self.assertTrue(note.message_content == "test content", "edit_form was unable to update the message content")
def test3Delete(self):
def test4Delete(self):
notification_id = db(db.notification.title=="test title").select()[0].id
request.vars['id'] = str(notification_id)
res = delete()
self.assertTrue(res.hasKey('message'), "edit returned an incomplete response")
self.assertNotEqual(res.find("notification " + str(notification_id) + " deleted"), -1, "delete returned an incomplete response")
def test2GetActiveNotifications(self):
def test3GetActiveNotifications(self):
#TODO Improve this test
res = get_active_notifications()
assertTrue(res != "[]", "get active notifications returned no notifications")
self.assertNotEqual(res, "[]", "get active notifications returned no notifications")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment