本文整理汇总了Python中stubo.model.stub.Stub.set_module方法的典型用法代码示例。如果您正苦于以下问题:Python Stub.set_module方法的具体用法?Python Stub.set_module怎么用?Python Stub.set_module使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stubo.model.stub.Stub
的用法示例。
在下文中一共展示了Stub.set_module方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_it_with_module
# 需要导入模块: from stubo.model.stub import Stub [as 别名]
# 或者: from stubo.model.stub.Stub import set_module [as 别名]
def test_it_with_module(self):
module = {"system_date": "2013-08-07", "version": 1, "name": "mymodule"}
scenario_name = 'foo'
self._make_scenario('localhost:foo')
from stubo.model.stub import create, Stub, response_hash
stub = Stub(create('<test>match this</test>', '<test>OK</test>'),
'localhost:foo')
stub.set_module(module)
doc = dict(scenario='localhost:foo', stub=stub)
self.scenario.insert_stub(doc, stateful=True)
cache = self._get_cache()
session = cache.create_session_cache('foo', 'bar')
self._func(session, stub)
self.assertEqual(self.hash.get('localhost:foo:request',
'bar:1'),
[[u'1'], u'', None, u'2013-09-05', module, u'12b0a0eced1ec13b53d186be7bd4909fa94d1916cca4daa25bd24d48'])
示例2: test_update_dormat_session_with_stubs_and_module
# 需要导入模块: from stubo.model.stub import Stub [as 别名]
# 或者: from stubo.model.stub.Stub import set_module [as 别名]
def test_update_dormat_session_with_stubs_and_module(self):
self.hash.set('localhost:foo', 'bar', {'status' : 'dormant',
'session' : 'bar',
'scenario' : 'localhost:foo'})
module = {"system_date": "2013-09-24", "version": 1, "name": "funcky"}
self._make_scenario('localhost:foo')
from stubo.model.stub import create, Stub
stub = Stub(create('<test>match this</test>', '<test>OK</test>'),
'localhost:foo')
stub.set_module(module)
doc = dict(scenario='localhost:foo', stub=stub)
self.scenario.insert_stub(doc, stateful=True)
self._get_cache().create_session_cache('foo', 'bar')
session = self.hash.get('localhost:foo', 'bar')
self.assertTrue('stubs' in session)
stubs = session['stubs']
self.assertEqual(len(stubs), 1)
from stubo.model.stub import StubCache
stub = StubCache(stubs[0], session["scenario"], session['session'])
self.assertEqual(stub.module(), module)