def test_get(db, session): # pylint: disable=unused-argument """Verify that the get() returns correct results as expected.""" # get from method for notf-user user_id = 'notf-user' method_res = Notification.get(user_id) query_res = get_user_notifications( session, user_id) # check if the results are really same assert len(query_res) == len(method_res)
def get(self, **kwargs): """Get method handler for notification route.""" user_id = kwargs.get('user_id') if user_id: notifications = NotificationModel.get(user_id) response = Notifications().dump(dict(notifications=notifications)).data return Response(json.dumps(response), status=200, mimetype='application/json') else: err = {'error': ['user_id cannot be empty']} return Response(json.dumps(ErrorResponse().dump(err).data), status=422, mimetype='application/json')