コード例 #1
0
def target():
    t = Target('target_id',
               '/target/path',
               host='bkp.example.net',
               user='******')
    t.available = Mock(return_value=True)
    return t
コード例 #2
0
def test_ping_works_ok(m_sh, ping, host, sh, expected):
    '64 bytes from localhost icmp_seq=1 '
    m_sh.ping.bake.return_value = m_sh
    m_sh.side_effect = [sh]
    t = Target('target_id', '/some/path', host=host, ping=ping)
    rval = ping_works(t, min_ping=1)
    assert rval == expected
コード例 #3
0
def test_ssh_works_fail(m_sh):
    m_sh.ssh.bake.return_value = m_sh
    m_sh.bake.return_value = m_sh
    m_sh.exit.side_effect = Exception('TEST')
    t = Target('target_id', '/some/path')
    rval = ssh_works(t, timeout=1)
    assert rval == False
コード例 #4
0
ファイル: test_target.py プロジェクト: jakubgs/rbackup
def test_target_constructor(m_getuser):
    m_getuser.return_value = 'mock_user'
    t = Target('target_id', '/some/path')
    assert t.id == 'target_id'
    assert t.dest == '/some/path'
    assert t.user == 'mock_user'
    assert t.host == 'localhost'
    assert t.port == 22
    assert t.ping == False
コード例 #5
0
def test_print_config():
    assets = {
        'asset_1': Asset('asset_1', '/some/path'),
        'asset_2': Asset('asset_1', '/moar/paths', target='target_1'),
    }
    targets = {
        'target_1': Target('target_1', '/another/path'),
    }
    util.print_config(assets, targets)
コード例 #6
0
ファイル: test_target.py プロジェクト: jakubgs/rbackup
def test_target_constructor():
    data = {
        'id': 'target_id',
        'dest': '/some/path',
        'user': '******',
        'host': 'bkp.example.net',
        'port': 666,
        'ping': True,
    }
    t = Target.from_dict(data)
    assert t.id == 'target_id'
    assert t.dest == '/some/path'
    assert t.user == 'test_user'
    assert t.host == 'bkp.example.net'
    assert t.port == 666
    assert t.ping == True
コード例 #7
0
ファイル: test_target.py プロジェクト: jakubgs/rbackup
def test_available(m_ssh_works, m_ping_works, ssh, ping):
    m_ssh_works.return_value = ssh
    m_ping_works.return_value = ping
    t = Target('target_id', '/some/path')
    rval = t.available()
    assert rval == (ssh and ping)
コード例 #8
0
def test_ssh_works_ok(m_sh):
    t = Target('target_id', '/some/path')
    rval = ssh_works(t, timeout=1)
    assert rval == True
コード例 #9
0
def test_ssh_works_local(m_sh):
    t = Target('local', '/some/path')
    rval = ssh_works(t, timeout=1)
    assert rval == True