Skip to content

Commit

Permalink
add truss transfer test
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfeil committed Jan 29, 2025
1 parent 42a8775 commit fe5cff9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions truss/tests/templates/core/server/test_lazy_data_resolver_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,26 @@ def test_lazy_data_resolver_v2():
with pytest.raises(Exception):
# LAZY_DATA_RESOLVER_PATH does not exist
# should raise an exception
LazyDataResolverV2(Path("/tmp"))
LazyDataResolverV2(Path("/tmp")).fetch()

try:
LAZY_DATA_RESOLVER_PATH.mkdir(parents=True, exist_ok=True)
except Exception as e:
pytest.skip(f"Unable to create {LAZY_DATA_RESOLVER_PATH}: {e}")
pytest.skip(
f"Unable to create {LAZY_DATA_RESOLVER_PATH} due to missing os permissions: {e}"
)

# without LAZY_DATA_RESOLVER_PATH -> does not create folder / file
with tempfile.TemporaryDirectory() as tempdir:
data_dir = Path(tempdir)
resolver = LazyDataResolverV2(data_dir)
resolver = LazyDataResolverV2(data_dir).fetch()
assert not (data_dir / TARGET_FILE).exists()

# with LAZY_DATA_RESOLVER_PATH -> fetches data
with tempfile.TemporaryDirectory() as tempdir:
data_dir = Path(tempdir)
write_bptr_manifest_to_file()
resolver = LazyDataResolverV2(data_dir)
resolver = LazyDataResolverV2(data_dir).fetch()
resolver.fetch()
assert (data_dir / TARGET_FILE).exists()
assert (data_dir / TARGET_FILE).stat().st_size == 1482
Expand All @@ -68,7 +70,7 @@ def test_lazy_data_resolver_v2():
with tempfile.TemporaryDirectory() as tempdir:
data_dir = Path(tempdir)
write_bptr_manifest_to_file(expiration_timestamp=int(time.time()) - 1)
resolver = LazyDataResolverV2(data_dir)
resolver = LazyDataResolverV2(data_dir).fetch()
with pytest.raises(Exception):
resolver.fetch()

Expand Down

0 comments on commit fe5cff9

Please sign in to comment.