Skip to content

Commit

Permalink
Adding Unicode support and tests to MemcachedCache
Browse files Browse the repository at this point in the history
  • Loading branch information
ezturner committed Aug 5, 2018
1 parent 82eaed4 commit 4c725a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions rc_django/cache_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def getCache(self, service, url, headers):

values = json.loads(data)
if "b64_data" in data:
values["data"] = b64decode(values["b64_data"])
values["data"] = b64decode(values["b64_data"].decode('utf-8'))
response = MockHTTP()
response.status = values["status"]
response.data = values["data"]
Expand All @@ -213,7 +213,7 @@ def processResponse(self, service, url, response):
for header in response.headers:
header_data[header] = response.getheader(header)

b64_data = b64encode(response.data)
b64_data = b64encode(response.data.encode('utf-8'))
data = json.dumps({"status": response.status,
"b64_data": b64_data,
"headers": header_data})
Expand Down
6 changes: 3 additions & 3 deletions rc_django/tests/cache_implementation/test_memcached.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def load(self, method, url, headers, body):
response = MockHTTP()
if url == "/same":
response.status = 200
response.data = "Body Content"
response.data = "Body Content§"
else:
response.status = 404
return response
Expand All @@ -42,12 +42,12 @@ def test_memcached(self):
response = hit["response"]

self.assertEquals(response.status, 200)
self.assertEquals(response.data, "Body Content")
self.assertEquals(response.data, "Body Content§")

hit = cache.getCache('mem', '/same', {})

self.assertEquals(response.status, 200)
self.assertEquals(response.data, "Body Content")
self.assertEquals(response.data, "Body Content§")

@skipIf(not getattr(settings, 'RESTCLIENTS_TEST_MEMCACHED', False),
"Needs configuration to test memcached cache")
Expand Down

0 comments on commit 4c725a2

Please sign in to comment.