当前位置: 首页>>代码示例>>Python>>正文


Python Stub.response_ids方法代码示例

本文整理汇总了Python中stubo.model.stub.Stub.response_ids方法的典型用法代码示例。如果您正苦于以下问题:Python Stub.response_ids方法的具体用法?Python Stub.response_ids怎么用?Python Stub.response_ids使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stubo.model.stub.Stub的用法示例。


在下文中一共展示了Stub.response_ids方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_update_dormant_session_with_stubs

# 需要导入模块: from stubo.model.stub import Stub [as 别名]
# 或者: from stubo.model.stub.Stub import response_ids [as 别名]
 def test_update_dormant_session_with_stubs(self):
     self.hash.set('somehost:foo', 'bar', {'status' : 'dormant',
                                           'session' : 'bar',
                                           'scenario' : 'localhost:foo'})
     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')
     doc = dict(scenario='localhost:foo', stub=stub)
     self.scenario.insert_stub(doc, stateful=True)  
     
     cache = self._get_cache()
     cache.create_session_cache('foo', 'bar')  
     session = self.hash.get('localhost:foo', 'bar') 
     self.assertEqual(session["status"], "playback")
     self.assertEqual(session['session'], 'bar')
     self.assertEqual(session["scenario"], "localhost:foo")
     
     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.contains_matchers(), ["<test>match this</test>"])
     self.assertEqual(stub.response_ids(), [response_hash('<test>OK</test>',
                                                          stub)])        
开发者ID:JohnFDavenport,项目名称:stubo-app,代码行数:29,代码来源:test_cache.py

示例2: test_new_session_with_state

# 需要导入模块: from stubo.model.stub import Stub [as 别名]
# 或者: from stubo.model.stub.Stub import response_ids [as 别名]
 def test_new_session_with_state(self):
     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')
     doc = dict(scenario='localhost:foo', stub=stub)
     self.scenario.insert_stub(doc, stateful=True)  
     
     stub2 = Stub(create('<test>match this</test>', '<test>BAD</test>'),
                 'localhost:foo')
     doc2 = dict(scenario='localhost:foo', stub=stub2)
     self.scenario.insert_stub(doc2, stateful=True)  
     
     cache = self._get_cache()
     cache.create_session_cache('foo', 'bar')  
     session = self.hash.get('localhost:foo', 'bar') 
     self.assertEqual(session["status"], "playback")
     self.assertEqual(session['session'], 'bar')
     self.assertEqual(session["scenario"], "localhost:foo")
     
     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'])
     responses = stub.response_ids()
     self.assertEqual(len(responses), 2)
     self.assertEqual(stub.contains_matchers(), ["<test>match this</test>"])
     self.assertEqual(responses, [response_hash('<test>OK</test>', stub), 
                                  response_hash('<test>BAD</test>', stub2)])          
     self.assertEqual(self.hash.get_raw('localhost:sessions', 'bar'), 'foo')    
开发者ID:JohnFDavenport,项目名称:stubo-app,代码行数:34,代码来源:test_cache.py


注:本文中的stubo.model.stub.Stub.response_ids方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。