def test_get_update_args_owner_sync(mocker):
    """
    Given:
        -  a dict indicating changed fields (delta) with closeReason set to Other and a closeNotes
        - the incident status - set to 2 == Closed
    When
        - running get_update_args
    Then
        - update_args status has the correct status (resolved_other)
        - the resolve_comment is the same as the closeNotes
    """
    from PaloAltoNetworks_XDR import get_update_args
    mocker.patch.object(demisto,
                        'params',
                        return_value={
                            "sync_owners": True,
                            "mirror_direction": "Incoming"
                        })
    mocker.patch.object(demisto,
                        'findUser',
                        return_value={
                            "email": "*****@*****.**",
                            'username': '******'
                        })
    delta = {'owner': 'username'}

    update_args = get_update_args(delta, 1)

    assert update_args.get('assigned_user_mail') == '*****@*****.**'
def test_get_update_args_close_incident():
    """
    Given:
        -  a dict indicating changed fields (delta) with a change in owner
        - the incident status - set to 1 == Active
    When
        - running get_update_args
    Then
        - update_args assigned_user_mail has the correct associated mail
    """
    from PaloAltoNetworks_XDR import get_update_args
    delta = {'closeReason': 'Other', "closeNotes": "Not Relevant"}
    update_args = get_update_args(delta, 2)
    assert update_args.get('status') == 'resolved_other'
    assert update_args.get('resolve_comment') == 'Not Relevant'
def test_get_update_args_unassgning_user():
    """
    Given:
        -  a dict indicating changed fields (delta) with assigned_user_mail set to "None"
        - the incident status - set to 1 == Active
    When
        - running get_update_args
    Then
        - update_args have assigned_user_mail and assigned_user_pretty_name set to None and unassign_user set to 'true'
    """
    from PaloAltoNetworks_XDR import get_update_args
    delta = {'assigned_user_mail': 'None'}
    update_args = get_update_args(delta, 1)
    assert update_args.get('assigned_user_mail') is None
    assert update_args.get('assigned_user_pretty_name') is None
    assert update_args.get('unassign_user') == 'true'