-
Notifications
You must be signed in to change notification settings - Fork 47
Closed
Description
By following the readme file, I tried to use Mocket to mock zip and image file upload, but it threw an error. I looked into other related issues, but couldn't find any proper solution.
#upload_test.py
import json
from mocket import mocketize
from mocket.mockhttp import Entry
import requests
import pytest
@pytest.fixture
def response():
return {
"integer": 1,
"string": "asd",
"boolean": False,
}
@mocketize # use its decorator
def test_json(response):
url_to_mock = 'https://testme.org/json'
Entry.single_register(
Entry.POST,
url_to_mock,
body=response,
headers={'content-type': 'application/json'}
)
data = {}
file_obj = open('./test/data/sdk-skill.zip', 'rb')
files = { 'content': file_obj }
resp = requests.post(url_to_mock, files=files, data=data, verify=False)
mocked_response = resp.json()
assert response == mocked_response
When I run pytest test/unit/upload_test.py
, it gives
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 123: invalid start byte
Metadata
Metadata
Assignees
Labels
No labels