def testRecord(self): h = self._makeHttp('www.google.com') recorder = dalton.Recorder(caller=h) with recorder.recording(): h.request('GET', '/') resp = h.getresponse() body = resp.read() assert len(recorder._interaction) == 1
def testEmptySave(self): h = self._makeHttp('www.google.com') recorder = dalton.Recorder(caller=h) with recorder.recording(): pass # does not do any request assert len(recorder._interaction) == 0 test_dir = os.path.join(here, 'test_recordings', 'empty_test') recorder.save(test_dir)
def testSave(self): h = self._makeHttp('www.google.com') params = urllib.parse.urlencode({'q': 'dalton'}) recorder = dalton.Recorder(use_global=True) with recorder.recording(): h.request('GET', '/') resp = h.getresponse() body = resp.read() h.request('POST', '/', body=params) resp = h.getresponse() body = resp.read() test_dir = os.path.join(here, 'test_recordings', 'google_test') recorder.save(test_dir) assert len(recorder._interaction) == 2 assert os.path.exists(test_dir) assert os.path.isdir(test_dir) assert os.path.exists(os.path.join(test_dir, '__init__.py')) assert os.path.exists(os.path.join(test_dir, 'step_1_request.txt'))