コード例 #1
0
ファイル: test_str.py プロジェクト: c-pher/PyWinOS
def test_str(host, username, password):
    tool = WinOSClient(host, username, password)
    response = tool.__str__()
    print(response)
    assert 'Local host' in response
    assert host in response
    assert username in response
    assert password in response
コード例 #2
0
def test_ping_no_ip():
    tool = WinOSClient(host='')
    response = tool.ping()

    if os.name == 'nt':
        assert response.stdout == 'IP address must be specified.', \
            'IP address must be specified.'
    else:
        assert 'Usage: ping' in response.stderr
コード例 #3
0
ファイル: test_local.py プロジェクト: c-pher/PyWinOS
def test_run_cmd_invalid_command():
    tool = WinOSClient(host='')
    response = tool.run_cmd_local('whoamia')
    assert not response.ok, 'Response is OK. Must be False'
    assert not response.stdout, 'STDOUT is not empty. Must be empty'

    if os.name == 'nt':
        assert 'is not recognized as an internal' in response.stderr, \
            'Response is OK. Must be False'
    else:
        assert 'whoamia: not found' in response.stderr
コード例 #4
0
ファイル: test_local.py プロジェクト: c-pher/PyWinOS
def test_run_cmd_local(command):
    tool = WinOSClient(host='')
    response = tool.run_cmd_local(command=command)
    assert response.ok, 'Response is not OK'
コード例 #5
0
ファイル: test_local.py プロジェクト: c-pher/PyWinOS
def test_get_local_hostname_ip():
    tool = WinOSClient(host='')
    response = tool.get_local_hostname_ip()
    ip_regex = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$')

    assert ip_regex.match(response.ip), 'IP address not found'
コード例 #6
0
def test_ping_remote_host_with_no_ip_in_method():
    tool = WinOSClient(host='8.8.8.8')
    response = tool.ping()
    print(response)
    assert not response.exited, 'Exit code is not 0'
コード例 #7
0
def test_ping_packets_number(number):
    tool = WinOSClient(host='8.8.8.8')
    response = tool.ping(packets_number=number)
    assert number == response.stdout.count('from 8.8.8.8')
コード例 #8
0
def test_ping_remote_host_with_no_ip_in_class():
    tool = WinOSClient()
    response = tool.ping(host='8.8.8.8')
    assert not response.exited, 'Exit code is not 0'
コード例 #9
0
def test_version():
    tool = WinOSClient()
    response = tool.version
    assert response == __version__
コード例 #10
0
def test_is_host_available_remote():
    tool = WinOSClient('8.8.8.8')
    response = tool.is_host_available(port=53)
    assert response, 'Response is not True'
コード例 #11
0
def test_is_host_unavailable_remote():
    tool = WinOSClient('8.8.8.8')
    response = tool.is_host_available(port=22)
    assert not response, 'Response is not False'
コード例 #12
0
def test_is_host_available_locally():
    """Execute method locally. Must be True"""

    tool = WinOSClient(host='')
    response = tool.is_host_available()
    assert response, 'Local host is available always'
コード例 #13
0
def test_get_absolute_path():
    tool = WinOSClient()
    response = tool.get_absolute_path('')
    assert response
コード例 #14
0
def test_clean_directory_without_path():
    with pytest.raises(FileNotFoundError):
        tool = WinOSClient()
        response = tool.clean_directory('')
        assert 'The system cannot find the path specified:' in response
コード例 #15
0
ファイル: conftest.py プロジェクト: c-pher/PyWinOS
def client_local() -> WinOSClient:
    return WinOSClient()
コード例 #16
0
ファイル: test_session.py プロジェクト: c-pher/PyWinOS
def test_session():
    """Host and credentials are mandatory"""

    with pytest.raises(AttributeError):
        assert WinOSClient().session