Example #1
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
Example #2
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"
Example #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
Example #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
Example #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'
Example #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'