def test_get_single(db, session): # pylint: disable=unused-argument """Verify that the get_single() returns correct results as expected from database table. """ # add a notification for user user_id = 'notf-user' request_id = 225 request_type = 'registration' request_status = 3 message = 'this is a test notification' notification = Notification(user_id=user_id, request_id=request_id, request_type=request_type, request_status=request_status, message=message) notification.add() notification_id = get_notification_id(session, request_id) notification_data = Notification.get_single(notification_id) notification_data_raw = get_single_notification(session, notification_id) # verify results of both assert notification_data_raw.id == notification_data.id assert notification_data_raw.user_id == notification_data.user_id assert notification_data_raw.request_id == notification_data.request_id assert notification_data_raw.request_status == notification_data.request_status assert notification_data_raw.message == notification_data.message
def test_exists(db, session): # pylint: disable=unused-argument """Verify that exists() responds correctly while checking for existence of notifications.""" # add a new notification user_id = 'notf-user' request_id = 224 request_type = 'registration' request_status = 7 message = 'this is a test notification' notification = Notification(user_id=user_id, request_id=request_id, request_type=request_type, request_status=request_status, message=message) notification.add() # get notification id notification_id = get_notification_id(session, request_id) notification_bool = Notification.exists(notification_id) # check if it really exists res = exists_notification(session, notification_id) assert res is notification_bool
def test_mark_read(db, session): # pylint: disable=unused-argument """Verify that mark_read() mark marked_read column as True.""" # add a notification user_id = 'notf-user' request_id = 226 request_type = 'registration' request_status = 3 message = 'this is a test notification' notification = Notification(user_id=user_id, request_id=request_id, request_type=request_type, request_status=request_status, message=message) notification.add() # get notification id notification_id = get_notification_id(session, request_id) notification_data = get_single_notification(session, notification_id) assert notification_data.marked_read is False # call mark_read() Notification.mark_read(notification_id) notification_data = get_single_notification(session, notification_id) assert notification_data.marked_read is True