def test_is_ip_public_returncode_invalid_return_false(mocker):
    subprocess_output = b''
    subprocess_mock = SubprocessOutputMock(returncode=1, stdout=subprocess_output)
    mocker.patch.object(subprocess, 'run', return_value=subprocess_mock)
    node_info = NodeInformation('1.2.3.4', 'myenode')
    validator = NodeValidator(node_info)

    is_valid = validator.is_ip_public()

    assert not is_valid
def test_is_ip_public_return_false(mocker):
    subprocess_output = b'''
        Starting Nmap 7.80 ( https://nmap.org ) at 2020-05-29 12:40 CEST
        Nmap scan report for XXXX (2.1.4.5)
        Host is up (0.045s latency).

        PORT      STATE SERVICE
        21000/tcp closed  irtrans

        Nmap done: 1 IP address (1 host up) scanned in 0.25 seconds
    '''
    subprocess_mock = SubprocessOutputMock(returncode=0, stdout=subprocess_output)
    mocker.patch.object(subprocess, 'run', return_value=subprocess_mock)
    node_info = NodeInformation('1.2.3.4', 'myenode')
    validator = NodeValidator(node_info)

    is_valid = validator.is_ip_public()

    assert not is_valid