ceph/orchestra/test/test_remote.py
Tommi Virtanen dc9aaacfb2 Add a pretty wrapper on top of Paramiko and run.run.
Most importantly right now, it knows its name, and can
prettyprint it.
2011-05-31 14:33:00 -07:00

53 lines
1.2 KiB
Python

from nose.tools import eq_ as eq
import fudge
import fudge.inspector
import nose
from .. import remote
def test_shortname():
r = remote.Remote(
name='jdoe@xyzzy.example.com',
shortname='xyz',
ssh=fudge.Fake('SSHConnection'),
)
eq(r.shortname, 'xyz')
eq(str(r), 'xyz')
def test_shortname_default():
r = remote.Remote(
name='jdoe@xyzzy.example.com',
ssh=fudge.Fake('SSHConnection'),
)
eq(r.shortname, 'jdoe@xyzzy.example.com')
eq(str(r), 'jdoe@xyzzy.example.com')
@nose.with_setup(fudge.clear_expectations)
@fudge.with_fakes
def test_run():
ssh = fudge.Fake('SSHConnection')
run = fudge.Fake('run')
args = [
'something',
'more',
]
foo = object()
ret = object()
run.expects_call().with_args(
client=fudge.inspector.arg.passes_test(lambda v: v is ssh),
args=fudge.inspector.arg.passes_test(lambda v: v is args),
foo=fudge.inspector.arg.passes_test(lambda v: v is foo),
).returns(ret)
r = remote.Remote(name='jdoe@xyzzy.example.com', ssh=ssh)
# monkey patch ook ook
r._runner = run
got = r.run(
args=args,
foo=foo,
)
assert got is ret