mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-19 13:07:56 +00:00
Hook up more IStorageServer tests that can now pass with HTTP.
This commit is contained in:
parent
c72e7b0585
commit
48a9bf7457
@ -1042,7 +1042,7 @@ class _FakeRemoteReference(object):
|
||||
@attr.s
|
||||
class _HTTPBucketWriter(object):
|
||||
"""
|
||||
Emulate a ``RIBucketWriter``.
|
||||
Emulate a ``RIBucketWriter``, but use HTTP protocol underneath.
|
||||
"""
|
||||
client = attr.ib(type=StorageClientImmutables)
|
||||
storage_index = attr.ib(type=bytes)
|
||||
@ -1069,6 +1069,25 @@ class _HTTPBucketWriter(object):
|
||||
return defer.succeed(None)
|
||||
|
||||
|
||||
|
||||
@attr.s
|
||||
class _HTTPBucketReader(object):
|
||||
"""
|
||||
Emulate a ``RIBucketReader``.
|
||||
"""
|
||||
client = attr.ib(type=StorageClientImmutables)
|
||||
storage_index = attr.ib(type=bytes)
|
||||
share_number = attr.ib(type=int)
|
||||
|
||||
def read(self, offset, length):
|
||||
return self.client.read_share_chunk(
|
||||
self.storage_index, self.share_number, offset, length
|
||||
)
|
||||
|
||||
def advise_corrupt_share(self, reason):
|
||||
pass # TODO in later ticket
|
||||
|
||||
|
||||
# WORK IN PROGRESS, for now it doesn't actually implement whole thing.
|
||||
@implementer(IStorageServer) # type: ignore
|
||||
@attr.s
|
||||
@ -1117,8 +1136,18 @@ class _HTTPStorageServer(object):
|
||||
})
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def get_buckets(
|
||||
self,
|
||||
storage_index,
|
||||
):
|
||||
pass
|
||||
immutable_client = StorageClientImmutables(self._http_client)
|
||||
share_numbers = yield immutable_client.list_shares(
|
||||
storage_index
|
||||
)
|
||||
defer.returnValue({
|
||||
share_num: _FakeRemoteReference(_HTTPBucketReader(
|
||||
immutable_client, storage_index, share_num
|
||||
))
|
||||
for share_num in share_numbers
|
||||
})
|
||||
|
@ -1149,8 +1149,6 @@ class HTTPImmutableAPIsTests(
|
||||
"test_get_buckets_skips_unfinished_buckets",
|
||||
"test_matching_overlapping_writes",
|
||||
"test_non_matching_overlapping_writes",
|
||||
"test_read_bucket_at_offset",
|
||||
"test_written_shares_are_readable",
|
||||
"test_written_shares_are_allocated",
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user