class APIExample(object): def __init__(self, stubo_dc, **kwargs): self.stubo = Stubo(dc=stubo_dc, **kwargs) def record(self, scenario, session_name): self.stubo.delete_stubs(scenario=scenario) response = self.stubo.begin_session(scenario=scenario, session=session_name, mode='record') #stub = StubData('hello', 'goodbye') import json stub = StubData(json.dumps(dict(x='hello')), json.dumps(dict(y='goodbye'))) response = self.stubo.put_stub(session=session_name, json=stub.payload) self.stubo.end_session(scenario=scenario, session=session_name) return response def play(self, scenario, session_name): self.stubo.begin_session(scenario=scenario, session=session_name, mode='playback') #response = self.stubo.get_response(session=session_name, data='hello') response = self.stubo.get_response(session=session_name, json=dict(x='hello')) self.stubo.end_session(scenario=scenario, session=session_name) return response
def tearDown(self): from stubolib.api import Stubo stubo = Stubo(dc) stubo.delete_stubs(scenario=self.scenario, force=True)
def __init__(self, stubo_dc, **kwargs): self.stubo = Stubo(dc=stubo_dc, **kwargs)