fix tests

This commit is contained in:
Jack Robison 2019-05-08 14:47:04 -04:00
parent 761a2b235c
commit a2a1ef34ab
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 35 additions and 19 deletions

View file

@ -172,7 +172,15 @@ class CommandTestCase(IntegrationTestCase):
return json.loads(jsonrpc_dumps_pretty(value, ledger=self.ledger))['result'] return json.loads(jsonrpc_dumps_pretty(value, ledger=self.ledger))['result']
async def stream_create(self, name='hovercraft', bid='1.0', data=b'hi!', confirm=True, **kwargs): async def stream_create(self, name='hovercraft', bid='1.0', data=b'hi!', confirm=True, **kwargs):
with tempfile.NamedTemporaryFile() as file: file = tempfile.NamedTemporaryFile()
def cleanup():
try:
file.close()
except FileNotFoundError:
pass
self.addCleanup(cleanup)
file.write(data) file.write(data)
file.flush() file.flush()
claim = await self.out( claim = await self.out(
@ -187,9 +195,17 @@ class CommandTestCase(IntegrationTestCase):
async def stream_update(self, claim_id, data=None, confirm=True, **kwargs): async def stream_update(self, claim_id, data=None, confirm=True, **kwargs):
if data: if data:
with tempfile.NamedTemporaryFile() as file: file = tempfile.NamedTemporaryFile()
file.write(data) file.write(data)
file.flush() file.flush()
def cleanup():
try:
file.close()
except FileNotFoundError:
pass
self.addCleanup(cleanup)
claim = await self.out( claim = await self.out(
self.daemon.jsonrpc_stream_update(claim_id, file_path=file.name, **kwargs) self.daemon.jsonrpc_stream_update(claim_id, file_path=file.name, **kwargs)
) )

View file

@ -97,7 +97,7 @@ class RangeRequests(CommandTestCase):
async def test_range_requests_no_padding_size_from_claim(self): async def test_range_requests_no_padding_size_from_claim(self):
size = ((MAX_BLOB_SIZE - 1) * 4) - 14 size = ((MAX_BLOB_SIZE - 1) * 4) - 14
await self.test_range_requests_0_padded_bytes(size, padding=b'', file_size=size, await self.test_range_requests_0_padded_bytes(size, padding=b'', file_size=size,
expected_range=f"bytes 0-{size}/{size+1}") expected_range=f"bytes 0-{size-1}/{size}")
async def test_range_requests_15_padded_bytes(self): async def test_range_requests_15_padded_bytes(self):
await self.test_range_requests_0_padded_bytes( await self.test_range_requests_0_padded_bytes(