def test_get_line():
    sl = SourceLog(ssh_params={'hostname': 'localhost',
                               },
                   filepath=PATH_TEST_LOG,
                   )
    sl.p = DummyProcess()
    line = sl.get_line().rstrip()
    assert line == 'line1'
def test__assemble_ssh_command1():
    sl = SourceLog(ssh_params={'hostname': 'localhost',
                               },
                   filepath=PATH_TEST_LOG,
                   )
    sl._assemble_ssh_command()
    assert sl.ssh_params['host'] == 'localhost'
    assert sl.ssh_cmd == 'ssh  localhost "tail --follow=name %s"' % PATH_TEST_LOG
def test__assemble_ssh_command2():
    sl = SourceLog(ssh_params={'hostname': 'localhost',
                               'host': 'local',
                               'identityfile': '/home/smithers/.ssh/id_rsa',
                               },
                   filepath=PATH_TEST_LOG,
                   )
    sl._assemble_ssh_command()
    assert sl.ssh_params['host'] == 'local'
    assert sl.ssh_cmd == 'ssh -oidentityfile=/home/smithers/.ssh/id_rsa localhost "tail --follow=name %s"' % PATH_TEST_LOG
def test_get_line():
    sl = SourceLog(
        ssh_params={
            'hostname': 'localhost',
        },
        filepath=PATH_TEST_LOG,
    )
    sl.p = DummyProcess()
    line = sl.get_line().rstrip()
    assert line == 'line1'
def test__assemble_ssh_command1():
    sl = SourceLog(
        ssh_params={
            'hostname': 'localhost',
        },
        filepath=PATH_TEST_LOG,
    )
    sl._assemble_ssh_command()
    assert sl.ssh_params['host'] == 'localhost'
    assert sl.ssh_cmd == 'ssh  localhost "tail --follow=name %s"' % PATH_TEST_LOG
def test__assemble_ssh_command2():
    sl = SourceLog(
        ssh_params={
            'hostname': 'localhost',
            'host': 'local',
            'identityfile': '/home/smithers/.ssh/id_rsa',
        },
        filepath=PATH_TEST_LOG,
    )
    sl._assemble_ssh_command()
    assert sl.ssh_params['host'] == 'local'
    assert sl.ssh_cmd == 'ssh -oidentityfile=/home/smithers/.ssh/id_rsa localhost "tail --follow=name %s"' % PATH_TEST_LOG