Browse Source

[FIX] emc_api: decode response from bytes to utf-8

pull/71/head
robin.keunen 5 years ago
parent
commit
47bee47693
  1. 3
      easy_my_coop_api/services/subscription_request_service.py
  2. 4
      easy_my_coop_api/tests/common.py
  3. 4
      easy_my_coop_api/tests/test_ping.py
  4. 4
      easy_my_coop_api/tests/test_subscription_requests.py

3
easy_my_coop_api/services/subscription_request_service.py

@ -51,7 +51,8 @@ class SubscriptionRequestService(Component):
} }
return response return response
def create(self, **params):
def create(self, **params): # pylint: disable=method-required-super
params = self._prepare_create(params) params = self._prepare_create(params)
sr = self.env["subscription.request"].create(params) sr = self.env["subscription.request"].create(params)
return self._to_dict(sr) return self._to_dict(sr)

4
easy_my_coop_api/tests/common.py

@ -73,8 +73,8 @@ class BaseEMCRestCase(BaseRestCase):
def http_get_content(self, route, headers=None): def http_get_content(self, route, headers=None):
response = self.http_get(route, headers=headers) response = self.http_get(route, headers=headers)
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
return json.loads(response.content)
content = response.content.decode("utf-8")
return json.loads(content)
def http_post(self, url, data, headers=None): def http_post(self, url, data, headers=None):
headers = _add_api_key(headers) headers = _add_api_key(headers)

4
easy_my_coop_api/tests/test_ping.py

@ -30,12 +30,12 @@ class TestPing(BaseEMCRestCase):
url = "http://%s:%s%s" % (HOST, PORT, path) url = "http://%s:%s%s" % (HOST, PORT, path)
response = requests.get(url) response = requests.get(url)
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
content = json.loads(response.content)
content = json.loads(response.content.decode("utf-8"))
self.assertTrue("message" in content) self.assertTrue("message" in content)
def test_search_route(self): def test_search_route(self):
response = self.http_get("/api/ping") response = self.http_get("/api/ping")
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
content = json.loads(response.content)
content = json.loads(response.content.decode("utf-8"))
self.assertTrue("message" in content) self.assertTrue("message" in content)

4
easy_my_coop_api/tests/test_subscription_requests.py

@ -113,7 +113,7 @@ class TestSRController(BaseEMCRestCase):
response = self.http_post(url, data=data) response = self.http_post(url, data=data)
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
content = json.loads(response.content)
content = json.loads(response.content.decode("utf-8"))
content.pop("id") # can't know id in advance content.pop("id") # can't know id in advance
expected = { expected = {
@ -135,7 +135,7 @@ class TestSRController(BaseEMCRestCase):
response = self.http_post(url, data=data) response = self.http_post(url, data=data)
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
content = json.loads(response.content)
content = json.loads(response.content.decode("utf-8"))
expected = self.demo_request_1_dict expected = self.demo_request_1_dict
expected["state"] = "done" expected["state"] = "done"

Loading…
Cancel
Save