Advertisement
mutchuloko

Errors msgpack

Jun 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. import falcon
  2. import msgpack
  3. from falcon import testing
  4. import pytest
  5.  
  6. from look.app import api
  7.  
  8.  
  9. @pytest.fixture
  10. def client():
  11.     return testing.TestClient(api)
  12.  
  13.  
  14. def test_list_images(client):
  15.     doc = {
  16.         'images': [
  17.             {
  18.                 'href': '/images/1eaf6ef1-7f2d-4ecc-a8d5-6e8adba7cc0e.png'
  19.             }
  20.         ]
  21.     }
  22.  
  23.     response: falcon.testing.client.Result = client.simulate_get('/images')
  24.  
  25.     '''
  26.        Solução do site do falcon
  27.        Estou usando raw=False pois a lib fala que o encoding está deprecado
  28.        
  29.        result_doc = msgpack.unpackb(response.content, raw=False)
  30.    '''
  31.  
  32.     '''
  33.        Minha solução
  34.        Estou usando raw=False pois a lib fala que o encoding está deprecado
  35.    '''
  36.     result_doc = msgpack.unpackb(msgpack.packb(response.json, use_bin_type=True), raw=False)
  37.  
  38.     assert result_doc == doc
  39.     assert response.status == falcon.HTTP_OK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement