2011-05-31 21:33:00 +00:00
|
|
|
from nose.tools import eq_ as eq
|
|
|
|
|
|
|
|
import fudge
|
|
|
|
import fudge.inspector
|
|
|
|
import nose
|
|
|
|
|
|
|
|
from .. import remote
|
2011-06-03 21:44:29 +00:00
|
|
|
from ..run import RemoteProcess
|
2011-05-31 21:33:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
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()
|
2011-06-03 21:44:29 +00:00
|
|
|
ret = RemoteProcess(
|
|
|
|
command='fakey',
|
|
|
|
stdin=None,
|
|
|
|
stdout=None,
|
|
|
|
stderr=None,
|
|
|
|
exitstatus=None,
|
|
|
|
)
|
2011-05-31 21:33:00 +00:00
|
|
|
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
|
2011-06-03 21:44:29 +00:00
|
|
|
assert got.remote is r
|