Port to Python 3.

This commit is contained in:
Itamar Turner-Trauring
2020-09-14 14:13:07 -04:00
parent 6196a1c650
commit 1d508c74e8
3 changed files with 32 additions and 3 deletions

View File

@ -29,8 +29,9 @@ import itertools
from allmydata import interfaces
from allmydata.util import fileutil, hashutil, base32
from allmydata.storage.server import StorageServer
from allmydata.storage.shares import get_share_file
from allmydata.storage.mutable import MutableShareFile
from allmydata.storage.immutable import BucketWriter, BucketReader
from allmydata.storage.immutable import BucketWriter, BucketReader, ShareFile
from allmydata.storage.common import DataTooLargeError, storage_index_to_dir, \
UnknownMutableContainerVersionError, UnknownImmutableContainerVersionError, \
si_b2a, si_a2b
@ -54,7 +55,7 @@ from .common_py3 import FakeCanary, LoggingServiceParent, ShouldFailMixin
class UtilTests(unittest.TestCase):
"""Tests for allmydata.storage.common."""
"""Tests for allmydata.storage.common and .shares."""
def test_encoding(self):
"""b2a/a2b are the same as base32."""
@ -71,6 +72,22 @@ class UtilTests(unittest.TestCase):
self.assertEqual(parts[0], parts[1][:2])
self.assertIsInstance(path, native_str)
def test_get_share_file_mutable(self):
"""A mutable share is identified by get_share_file()."""
path = self.mktemp()
msf = MutableShareFile(path)
msf.create(b"12", b"abc") # arbitrary values
loaded = get_share_file(path)
self.assertIsInstance(loaded, MutableShareFile)
self.assertEqual(loaded.home, path)
def test_get_share_file_immutable(self):
"""An immutable share is identified by get_share_file()."""
path = self.mktemp()
_ = ShareFile(path, max_size=1000, create=True)
loaded = get_share_file(path)
self.assertIsInstance(loaded, ShareFile)
self.assertEqual(loaded.home, path)
class FakeStatsProvider(object):