Skip to content

Commit

Permalink
tests: more
Browse files Browse the repository at this point in the history
  • Loading branch information
phi-friday committed Nov 6, 2024
1 parent eb5b0ca commit aa310c8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/tests/test_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,39 @@ async def test_fetch(self, value, key, filepath):
fetch = await self.disk.afetch(mode=mode, filename=filename, value=db_value)

assert fetch == value

@pytest.mark.parametrize(
"value",
[
pytest.param((None,) * 2**20, id="tuple"),
pytest.param("hello" * 2**20, id="long_str"),
pytest.param(b"world" * 2**20, id="long_bytes"),
],
)
@pytest.mark.parametrize("key", [True, False])
@pytest.mark.parametrize("filepath", [True, False])
async def test_remove(self, value, key, filepath):
params = {}
if key:
params["key"] = value
if filepath:
params["filepath"] = self.origin_disk.prepare(value, **params)
_, _, filename, _ = await self.disk.astore(value, **params)

assert filename
file = self.origin_disk.directory / filename
assert file.exists()

await self.disk.aremove(filename)
assert not file.exists()

@value_params
@pytest.mark.parametrize("key", [True, False])
def test_filename(self, value, key):
params = {}
if key:
params["key"] = value

filename = self.origin_disk.filename(value=value, **params)
assert isinstance(filename, Path)
assert filename.is_relative_to(self.origin_disk.directory)

0 comments on commit aa310c8

Please sign in to comment.