fewer magic numbers (and a fix to upload encoding)

This commit is contained in:
meejah 2019-08-24 12:53:36 -06:00
parent 20f907f5d3
commit 0f6d6659e9
2 changed files with 13 additions and 7 deletions

View File

@ -77,19 +77,18 @@ def test_put(alice):
use PUT to create a file
"""
FILE_CONTENTS = u"added via PUT"
FILE_CONTENTS = b"added via PUT" * 20
resp = requests.put(
util.node_url(alice.node_dir, u"uri"),
files={
u"file": FILE_CONTENTS,
},
data=FILE_CONTENTS,
)
cap = allmydata.uri.from_string(resp.text.strip().encode('ascii'))
cfg = alice.get_config()
assert isinstance(cap, allmydata.uri.CHKFileURI)
assert cap.size == 153
assert cap.total_shares == 4
assert cap.needed_shares == 2
assert cap.size == len(FILE_CONTENTS)
assert cap.total_shares == int(cfg.get_config("client", "shares.total"))
assert cap.needed_shares == int(cfg.get_config("client", "shares.needed"))
def test_helper_status(storage_nodes):

View File

@ -17,6 +17,7 @@ from allmydata.util.configutil import (
set_config,
write_config,
)
from allmydata import client
import pytest_twisted
@ -164,6 +165,12 @@ class TahoeProcess(object):
def node_dir(self):
return self._node_dir
def get_config(self):
return client.read_config(
self._node_dir,
u"portnum",
)
def __str__(self):
return "<TahoeProcess in '{}'>".format(self._node_dir)