本文整理汇总了Python中buildslave.test.fake.remote.FakeRemote.callRemote方法的典型用法代码示例。如果您正苦于以下问题:Python FakeRemote.callRemote方法的具体用法?Python FakeRemote.callRemote怎么用?Python FakeRemote.callRemote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buildslave.test.fake.remote.FakeRemote
的用法示例。
在下文中一共展示了FakeRemote.callRemote方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestBot
# 需要导入模块: from buildslave.test.fake.remote import FakeRemote [as 别名]
# 或者: from buildslave.test.fake.remote.FakeRemote import callRemote [as 别名]
class TestBot(unittest.TestCase):
def setUp(self):
self.basedir = os.path.abspath("basedir")
if os.path.exists(self.basedir):
shutil.rmtree(self.basedir)
os.makedirs(self.basedir)
self.real_bot = base.BotBase(self.basedir, False)
self.real_bot.startService()
self.bot = FakeRemote(self.real_bot)
def tearDown(self):
d = defer.succeed(None)
if self.real_bot and self.real_bot.running:
d.addCallback(lambda _: self.real_bot.stopService())
if os.path.exists(self.basedir):
shutil.rmtree(self.basedir)
return d
def test_getCommands(self):
d = self.bot.callRemote("getCommands")
def check(cmds):
# just check that 'shell' is present..
self.assertTrue("shell" in cmds)
d.addCallback(check)
return d
def test_getVersion(self):
d = self.bot.callRemote("getVersion")
def check(vers):
self.assertEqual(vers, buildslave.version)
d.addCallback(check)
return d
def test_getSlaveInfo(self):
infodir = os.path.join(self.basedir, "info")
os.makedirs(infodir)
open(os.path.join(infodir, "admin"), "w").write("testy!")
open(os.path.join(infodir, "foo"), "w").write("bar")
open(os.path.join(infodir, "environ"), "w").write("something else")
d = self.bot.callRemote("getSlaveInfo")
def check(info):
self.assertEqual(
info,
dict(
admin="testy!",
foo="bar",
environ=os.environ,
system=os.name,
basedir=self.basedir,
slave_commands=self.real_bot.remote_getCommands(),
version=self.real_bot.remote_getVersion(),
),
)
d.addCallback(check)
return d
def test_getSlaveInfo_nodir(self):
d = self.bot.callRemote("getSlaveInfo")
def check(info):
self.assertEqual(set(info.keys()), set(["environ", "system", "basedir", "slave_commands", "version"]))
d.addCallback(check)
return d
def test_setBuilderList_empty(self):
d = self.bot.callRemote("setBuilderList", [])
def check(builders):
self.assertEqual(builders, {})
d.addCallback(check)
return d
def test_setBuilderList_single(self):
d = self.bot.callRemote("setBuilderList", [("mybld", "myblddir")])
def check(builders):
self.assertEqual(list(builders), ["mybld"])
self.assertTrue(os.path.exists(os.path.join(self.basedir, "myblddir")))
# note that we test the SlaveBuilder instance below
d.addCallback(check)
return d
def test_setBuilderList_updates(self):
d = defer.succeed(None)
slavebuilders = {}
def add_my(_):
#.........这里部分代码省略.........
示例2: TestSlaveBuilder
# 需要导入模块: from buildslave.test.fake.remote import FakeRemote [as 别名]
# 或者: from buildslave.test.fake.remote.FakeRemote import callRemote [as 别名]
class TestSlaveBuilder(command.CommandTestMixin, unittest.TestCase):
@defer.inlineCallbacks
def setUp(self):
self.basedir = os.path.abspath("basedir")
if os.path.exists(self.basedir):
shutil.rmtree(self.basedir)
os.makedirs(self.basedir)
self.bot = base.BotBase(self.basedir, False)
self.bot.startService()
# get a SlaveBuilder object from the bot and wrap it as a fake remote
builders = yield self.bot.remote_setBuilderList([("sb", "sb")])
self.sb = FakeRemote(builders["sb"])
self.setUpCommand()
def tearDown(self):
self.tearDownCommand()
d = defer.succeed(None)
if self.bot and self.bot.running:
d.addCallback(lambda _: self.bot.stopService())
if os.path.exists(self.basedir):
shutil.rmtree(self.basedir)
return d
def test_print(self):
return self.sb.callRemote("print", "Hello, SlaveBuilder.")
def test_setMaster(self):
# not much to check here - what the SlaveBuilder does with the
# master is not part of the interface (and, in fact, it does very little)
return self.sb.callRemote("setMaster", mock.Mock())
def test_shutdown(self):
# don't *actually* shut down the reactor - that would be silly
stop = mock.Mock()
self.patch(reactor, "stop", stop)
d = self.sb.callRemote("shutdown")
def check(_):
self.assertTrue(stop.called)
d.addCallback(check)
return d
def test_startBuild(self):
return self.sb.callRemote("startBuild")
def test_startCommand(self):
# set up a fake step to receive updates
st = FakeStep()
# patch runprocess to handle the 'echo', below
self.patch_runprocess(
Expect(["echo", "hello"], os.path.join(self.basedir, "sb", "workdir"))
+ {"hdr": "headers"}
+ {"stdout": "hello\n"}
+ {"rc": 0}
+ 0
)
d = defer.succeed(None)
def do_start(_):
return self.sb.callRemote(
"startCommand", FakeRemote(st), "13", "shell", dict(command=["echo", "hello"], workdir="workdir")
)
d.addCallback(do_start)
d.addCallback(lambda _: st.wait_for_finish())
def check(_):
self.assertEqual(
st.actions,
[
["update", [[{"hdr": "headers"}, 0]]],
["update", [[{"stdout": "hello\n"}, 0]]],
["update", [[{"rc": 0}, 0]]],
["update", [[{"elapsed": 1}, 0]]],
["complete", None],
],
)
d.addCallback(check)
return d
def test_startCommand_interruptCommand(self):
# set up a fake step to receive updates
st = FakeStep()
# patch runprocess to pretend to sleep (it will really just hang forever,
# except that we interrupt it)
self.patch_runprocess(
Expect(["sleep", "10"], os.path.join(self.basedir, "sb", "workdir")) + {"hdr": "headers"} + {"wait": True}
)
d = defer.succeed(None)
#.........这里部分代码省略.........
示例3: TestPBSlaveBuilder
# 需要导入模块: from buildslave.test.fake.remote import FakeRemote [as 别名]
# 或者: from buildslave.test.fake.remote.FakeRemote import callRemote [as 别名]
class TestPBSlaveBuilder(unittest.TestCase):
def setUp(self):
self.slavebuilder = FakeSlaveBuilder()
self.pbbuilder = bot.PBSlaveBuilder(self.slavebuilder)
self.sb = FakeRemote(self.pbbuilder)
def tearDown(self):
pass
def test_startBuild(self):
self.slavebuilder.startBuild = Mock()
self.sb.callRemote("startBuild")
self.slavebuilder.startBuild.assert_called_with()
def test_shutdown(self):
# don't *actually* shut down the reactor - that would be silly
stop = mock.Mock()
self.patch(reactor, "stop", stop)
d = self.sb.callRemote("shutdown")
def check(_):
self.assertTrue(stop.called)
d.addCallback(check)
return d
def test_setMaster(self):
# not much to check here - what the SlaveBuilder does with the
# master is not part of the interface (and, in fact, it does very little)
return self.sb.callRemote("setMaster", mock.Mock())
def test_startCommand(self):
st = FakeStep()
self.slavebuilder.startCommand = Mock()
self.sb.callRemote("startCommand", FakeRemote(st),
"13", "shell", dict(
command=[ 'echo', 'hello' ],
workdir='workdir',
))
self.slavebuilder.startCommand.assert_called_with("13", "shell", dict(
command=[ 'echo', 'hello' ],
workdir='workdir',
) )
def test_interruptCommand(self):
self.slavebuilder.interruptCommand = Mock()
self.sb.callRemote("interruptCommand", "13", "tl/dr" )
self.slavebuilder.interruptCommand.assert_called_with("13", "tl/dr")
def test_print(self):
self.slavebuilder.printMessage = Mock()
self.sb.callRemote("print", "Hello, SlaveBuilder.")
self.slavebuilder.printMessage.assert_called_with("Hello, SlaveBuilder.")
def test_sendUpdates(self):
st = FakeStep()
self.pbbuilder.remoteStep = FakeRemote(st)
self.pbbuilder.remoteStep.callRemote("update", [[{'hdr': 'headers'}, 0]])
self.assertEqual(st.actions, [
['update', [[{'hdr': 'headers'}, 0]]]
])
def test_sendComplete(self):
st = FakeStep()
self.pbbuilder.remoteStep = FakeRemote(st)
f = Mock()
self.pbbuilder.remoteStep.callRemote("complete", f)
self.assertEqual(st.actions, [['complete', f]])
示例4: TestSlaveBuilder
# 需要导入模块: from buildslave.test.fake.remote import FakeRemote [as 别名]
# 或者: from buildslave.test.fake.remote.FakeRemote import callRemote [as 别名]
class TestSlaveBuilder(command.CommandTestMixin, unittest.TestCase):
@defer.deferredGenerator
def setUp(self):
self.basedir = os.path.abspath("basedir")
if os.path.exists(self.basedir):
shutil.rmtree(self.basedir)
os.makedirs(self.basedir)
self.bot = bot.Bot(self.basedir, False)
self.bot.startService()
# get a SlaveBuilder object from the bot and wrap it as a fake remote
wfd = defer.waitForDeferred(
self.bot.remote_setBuilderList([('sb', 'sb')]))
yield wfd
builders = wfd.getResult()
self.sb = FakeRemote(builders['sb'])
self.setUpCommand()
def tearDown(self):
self.tearDownCommand()
d = defer.succeed(None)
if self.bot and self.bot.running:
d.addCallback(lambda _: self.bot.stopService())
if os.path.exists(self.basedir):
shutil.rmtree(self.basedir)
return d
def test_print(self):
return self.sb.callRemote("print", "Hello, SlaveBuilder.")
def test_setMaster(self):
# not much to check here - what the SlaveBuilder does with the
# master is not part of the interface (and, in fact, it does very little)
return self.sb.callRemote("setMaster", mock.Mock())
def test_shutdown(self):
# don't *actually* shut down the reactor - that would be silly
stop = mock.Mock()
self.patch(reactor, "stop", stop)
d = self.sb.callRemote("shutdown")
def check(_):
self.assertTrue(stop.called)
d.addCallback(check)
return d
def test_startBuild(self):
return self.sb.callRemote("startBuild")
def test_startCommand(self):
# set up a fake step to receive updates
st = FakeStep()
# patch runprocess to handle the 'echo', below
self.patch_runprocess(
Expect(['echo', 'hello'], os.path.join(self.basedir, 'sb', 'workdir'))
+ {'hdr': 'headers'} + {'stdout': 'hello\n'} + {'rc': 0}
+ 0,
)
d = defer.succeed(None)
def do_start(_):
return self.sb.callRemote("startCommand", FakeRemote(st),
"13", "shell", dict(
command=['echo', 'hello'],
workdir='workdir',
))
d.addCallback(do_start)
d.addCallback(lambda _: st.wait_for_finish())
def check(_):
self.assertEqual(st.actions, [
['update', [[{'hdr': 'headers'}, 0]]],
['update', [[{'stdout': 'hello\n'}, 0]]],
['update', [[{'rc': 0}, 0]]],
['update', [[{'elapsed': 1}, 0]]],
['complete', None],
])
d.addCallback(check)
return d
def test_startCommand_interruptCommand(self):
# set up a fake step to receive updates
st = FakeStep()
# patch runprocess to pretend to sleep (it will really just hang forever,
# except that we interrupt it)
self.patch_runprocess(
Expect(['sleep', '10'], os.path.join(self.basedir, 'sb', 'workdir'))
+ {'hdr': 'headers'}
+ {'wait': True}
)
d = defer.succeed(None)
#.........这里部分代码省略.........
示例5: TestBot
# 需要导入模块: from buildslave.test.fake.remote import FakeRemote [as 别名]
# 或者: from buildslave.test.fake.remote.FakeRemote import callRemote [as 别名]
class TestBot(unittest.TestCase):
def setUp(self):
self.basedir = os.path.abspath("basedir")
if os.path.exists(self.basedir):
shutil.rmtree(self.basedir)
os.makedirs(self.basedir)
self.real_bot = bot.Bot(self.basedir, False)
self.real_bot.startService()
self.bot = FakeRemote(self.real_bot)
def tearDown(self):
d = defer.succeed(None)
if self.real_bot and self.real_bot.running:
d.addCallback(lambda _ : self.real_bot.stopService())
if os.path.exists(self.basedir):
shutil.rmtree(self.basedir)
return d
def test_getCommands(self):
d = self.bot.callRemote("getCommands")
def check(cmds):
# just check that 'shell' is present..
self.assertTrue('shell' in cmds)
d.addCallback(check)
return d
def test_getVersion(self):
d = self.bot.callRemote("getVersion")
def check(vers):
self.assertEqual(vers, buildslave.version)
d.addCallback(check)
return d
def test_getSlaveInfo(self):
infodir = os.path.join(self.basedir, "info")
os.makedirs(infodir)
open(os.path.join(infodir, "admin"), "w").write("testy!")
open(os.path.join(infodir, "foo"), "w").write("bar")
d = self.bot.callRemote("getSlaveInfo")
def check(info):
self.assertEqual(info, dict(admin='testy!', foo='bar'))
d.addCallback(check)
return d
def test_getSlaveInfo_nodir(self):
d = self.bot.callRemote("getSlaveInfo")
def check(info):
self.assertEqual(info, {})
d.addCallback(check)
return d
def test_setBuilderList_empty(self):
d = self.bot.callRemote("setBuilderList", [])
def check(builders):
self.assertEqual(builders, {})
d.addCallback(check)
return d
def test_setBuilderList_single(self):
d = self.bot.callRemote("setBuilderList", [ ('mybld', 'myblddir') ])
def check(builders):
self.assertEqual(builders.keys(), ['mybld'])
self.assertTrue(os.path.exists(os.path.join(self.basedir, 'myblddir')))
# note that we test the SlaveBuilder instance below
d.addCallback(check)
return d
def test_setBuilderList_updates(self):
d = defer.succeed(None)
slavebuilders = {}
def add_my(_):
d = self.bot.callRemote("setBuilderList", [
('mybld', 'myblddir') ])
def check(builders):
self.assertEqual(builders.keys(), ['mybld'])
self.assertTrue(os.path.exists(os.path.join(self.basedir, 'myblddir')))
slavebuilders['my'] = builders['mybld']
d.addCallback(check)
return d
d.addCallback(add_my)
def add_your(_):
d = self.bot.callRemote("setBuilderList", [
('mybld', 'myblddir'), ('yourbld', 'yourblddir') ])
def check(builders):
self.assertEqual(sorted(builders.keys()), sorted(['mybld', 'yourbld']))
self.assertTrue(os.path.exists(os.path.join(self.basedir, 'myblddir')))
self.assertTrue(os.path.exists(os.path.join(self.basedir, 'yourblddir')))
# 'my' should still be the same slavebuilder object
self.assertEqual(id(slavebuilders['my']), id(builders['mybld']))
slavebuilders['your'] = builders['yourbld']
d.addCallback(check)
return d
d.addCallback(add_your)
#.........这里部分代码省略.........