human
Complete this python program:
def _TestQueryNotifications(tester, user_cookie, request_dict):
assistant
#Here is the Python code you requested.

    """Called by the ServiceTester in order to test query_notifications
    service API call.
    """
    validator = tester.validator
    (user_id, device_id) = tester.GetIdsFromCookie(user_cookie)
    def _MakeNotificationDict(notification):
        'Create    a    viewpoint    dict    from    the    followed    object    plus    its\n                referenced    viewpoint    object.\n                '
        notification_dict = {'notification_id': notification.notification_id, 'name': notification.name, 'sender_id': notification.sender_id, 'timestamp': notification.timestamp}
        util.SetIfNotNone(notification_dict, 'op_id', notification.op_id)
        if ((notification.update_seq is not None) or (notification.viewed_seq is not None)):
            vp_dict = notification_dict.setdefault('inline', {}).setdefault('viewpoint', {})
            vp_dict['viewpoint_id'] = notification.viewpoint_id
            util.SetIfNotNone(vp_dict, 'update_seq', notification.update_seq)
            util.SetIfNotNone(vp_dict, 'viewed_seq', notification.viewed_seq)
        if (notification.activity_id is not None):
            viewpoint_id = notification.viewpoint_id
            activity = validator.GetModelObject(Activity, DBKey(viewpoint_id, notification.activity_id))
            activity_dict = activity.MakeMetadataDict()
            notification_dict.setdefault('inline', {})['activity'] = activity_dict
            if ((activity.name == 'post_comment') and (notification.invalidate is None)):
                comment_id = activity_dict['post_comment']['comment_id']
                comment = validator.GetModelObject(Comment, DBKey(viewpoint_id, comment_id))
                notification_dict['inline']['comment'] = comment._asdict()
        invalidate = notification.GetInvalidate()
        if (invalidate is not None):
            invalidate.pop('headers')
            notification_dict['invalidate'] = invalidate
        return notification_dict
    def _MakeUsageDict():
        "Lookup    the    user's    accounting    entries    and    build    a    USAGE_METADATA    dict."
        validator.ValidateAccounting()
       ...