twisted.web expects bytes.

This commit is contained in:
Itamar Turner-Trauring 2020-11-03 10:40:53 -05:00
parent 672c440091
commit 60992174ff

View File

@ -3,11 +3,8 @@ A storage server plugin the test suite can use to validate the
functionality. functionality.
""" """
from future.utils import native_str from future.utils import native_str, native_str_to_bytes
from six import ensure_str
from json import (
dumps,
)
import attr import attr
@ -35,6 +32,9 @@ from allmydata.interfaces import (
from allmydata.client import ( from allmydata.client import (
AnnounceableStorageServer, AnnounceableStorageServer,
) )
from allmydata.util.jsonbytes import (
dumps,
)
class RIDummy(RemoteInterface): class RIDummy(RemoteInterface):
@ -84,8 +84,8 @@ class DummyStorage(object):
""" """
items = configuration.items(self._client_section_name, []) items = configuration.items(self._client_section_name, [])
resource = Data( resource = Data(
dumps(dict(items)), native_str_to_bytes(dumps(dict(items))),
b"text/json", ensure_str("text/json"),
) )
# Give it some dynamic stuff too. # Give it some dynamic stuff too.
resource.putChild(b"counter", GetCounter()) resource.putChild(b"counter", GetCounter())
@ -102,7 +102,7 @@ class GetCounter(Resource, object):
value = 0 value = 0
def render_GET(self, request): def render_GET(self, request):
self.value += 1 self.value += 1
return dumps({"value": self.value}) return native_str_to_bytes(dumps({"value": self.value}))
@implementer(RIDummy) @implementer(RIDummy)