self._distro = Distribution(lsb_info.stdout.getvalue().strip())
return self._distro
+ @property
+ def arch(self):
+ if not hasattr(self, '_arch'):
+ proc = self.run(args=['uname', '-p'], stdout=StringIO())
+ proc.wait()
+ self._arch = proc.stdout.getvalue().strip()
+ return self._arch
+
class Distribution(object):
"""
import fudge
import fudge.inspector
+from cStringIO import StringIO, OutputType
from textwrap import dedent
from .. import remote
assert got is ret
assert got.remote is r
+ @fudge.with_fakes
+ def test_arch(self):
+ fudge.clear_expectations()
+ ssh = fudge.Fake('SSHConnection')
+ ssh.expects('get_transport').returns_fake().expects('getpeername')\
+ .returns(('name', 22))
+ run = fudge.Fake('run')
+ args = [
+ 'uname',
+ '-p',
+ ]
+ stdout = StringIO('test_arch')
+ stdout.seek(0)
+ ret = RemoteProcess(
+ client=ssh,
+ args='fakey',
+ )
+ # status = self._stdout_buf.channel.recv_exit_status()
+ ret._stdout_buf = fudge.Fake()
+ ret._stdout_buf.channel = fudge.Fake()
+ ret._stdout_buf.channel.expects('recv_exit_status').returns(0)
+ ret.stdout = stdout
+ r = remote.Remote(name='jdoe@xyzzy.example.com', ssh=ssh)
+ run.expects_call().with_args(
+ client=ssh,
+ args=args,
+ stdout=fudge.inspector.arg.passes_test(
+ lambda v: isinstance(v, OutputType)),
+ name=r.shortname,
+ ).returns(ret)
+ # monkey patch ook ook
+ r._runner = run
+ assert r.arch == 'test_arch'
+
class TestDistribution(object):
lsb_centos = dedent("""