Beispiel #1
0
 def deserialize(self):
     """Turn a serialized interaction into a Response."""
     r = util.deserialize_response(self.json['response'])
     r.request = util.deserialize_prepared_request(self.json['request'])
     extract_cookies_to_jar(r.cookies, r.request, r.raw)
     self.recorded_at = datetime.strptime(self.json['recorded_at'],
                                          '%Y-%m-%dT%H:%M:%S')
     self.recorded_response = r
Beispiel #2
0
 def deserialize(self):
     """Turn a serialized interaction into a Response."""
     r = util.deserialize_response(self.json['response'])
     r.request = util.deserialize_prepared_request(self.json['request'])
     extract_cookies_to_jar(r.cookies, r.request, r.raw)
     self.recorded_at = datetime.strptime(
         self.json['recorded_at'], '%Y-%m-%dT%H:%M:%S'
     )
     self.recorded_response = r
Beispiel #3
0
 def test_deserialize_response_old(self):
     """For the previous version of Betamax and backwards compatibility."""
     s = {
         'body': {
             'string': decode('foo'),
             'encoding': 'utf-8'
         },
         'headers': {
             'Content-Type': decode('application/json')
         },
         'url': 'http://example.com/',
         'status_code': 200,
         'recorded_at': '2013-08-31T00:00:01'
     }
     r = util.deserialize_response(s)
     assert r.content == b'foo'
     assert r.encoding == 'utf-8'
     assert r.headers == {'Content-Type': 'application/json'}
     assert r.url == 'http://example.com/'
     assert r.status_code == 200
Beispiel #4
0
 def test_deserialize_response_old(self):
     """For the previous version of Betamax and backwards compatibility."""
     s = {
         'body': {
             'string': decode('foo'),
             'encoding': 'utf-8'
         },
         'headers': {
             'Content-Type': decode('application/json')
         },
         'url': 'http://example.com/',
         'status_code': 200,
         'recorded_at': '2013-08-31T00:00:01'
     }
     r = util.deserialize_response(s)
     assert r.content == b'foo'
     assert r.encoding == 'utf-8'
     assert r.headers == {'Content-Type': 'application/json'}
     assert r.url == 'http://example.com/'
     assert r.status_code == 200
Beispiel #5
0
 def test_deserialize_response_new(self):
     """This adheres to the correct cassette specification."""
     s = {
         'body': {
             'string': decode('foo'),
             'encoding': 'utf-8'
         },
         'headers': {
             'Content-Type': [decode('application/json')]
         },
         'url': 'http://example.com/',
         'status': {'code': 200, 'message': 'OK'},
         'recorded_at': '2013-08-31T00:00:01'
     }
     r = util.deserialize_response(s)
     assert r.content == b'foo'
     assert r.encoding == 'utf-8'
     assert r.headers == {'Content-Type': 'application/json'}
     assert r.url == 'http://example.com/'
     assert r.status_code == 200
     assert r.reason == 'OK'
Beispiel #6
0
 def test_deserialize_response_new(self):
     """This adheres to the correct cassette specification."""
     s = {
         'body': {
             'string': decode('foo'),
             'encoding': 'utf-8'
         },
         'headers': {
             'Content-Type': [decode('application/json')]
         },
         'url': 'http://example.com/',
         'status': {'code': 200, 'message': 'OK'},
         'recorded_at': '2013-08-31T00:00:01'
     }
     r = util.deserialize_response(s)
     assert r.content == b'foo'
     assert r.encoding == 'utf-8'
     assert r.headers == {'Content-Type': 'application/json'}
     assert r.url == 'http://example.com/'
     assert r.status_code == 200
     assert r.reason == 'OK'
Beispiel #7
0
 def deserialize(self):
     """Turn a serialized interaction into a Response."""
     r = util.deserialize_response(self.data['response'])
     r.request = util.deserialize_prepared_request(self.data['request'])
     extract_cookies_to_jar(r.cookies, r.request, r.raw)
     return r
Beispiel #8
0
 def deserialize(self):
     """Turn a serialized interaction into a Response."""
     r = util.deserialize_response(self.json['response'])
     r.request = util.deserialize_prepared_request(self.json['request'])
     extract_cookies_to_jar(r.cookies, r.request, r.raw)
     return r