Skip to content

Commit 6c96f16

Browse files
author
Dani Reinón
committed
chore: create uuid fixture and doc it well
1 parent a3f159b commit 6c96f16

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Diff for: tests/test_storage.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@ def finalizer():
3434
request.addfinalizer(finalizer)
3535

3636

37+
@pytest.fixture
38+
def uuid() -> str:
39+
# Get the first 8 digits part to make it shorter
40+
uuid = uuid4().hex[:8]
41+
return f"pytest-{uuid}"
42+
43+
3744
@pytest.fixture(scope="module")
38-
def bucket(storage_client: SupabaseStorageClient) -> str:
45+
def bucket(storage_client: SupabaseStorageClient, uuid: str) -> str:
3946
"""Creates a test bucket which will be used in the whole storage tests run and deleted at the end"""
40-
bucket_id = f"pytest-{uuid4().hex[:8]}"
47+
bucket_id = uuid
4148
storage_client.create_bucket(id=bucket_id)
4249

4350
yield bucket_id
@@ -55,7 +62,7 @@ def storage_file_client(
5562

5663

5764
@pytest.fixture
58-
def file(tmp_path: Path) -> Dict[str, str]:
65+
def file(tmp_path: Path, uuid: str) -> Dict[str, str]:
5966
"""Creates a different test file (same content but different path) for each test"""
6067
file_name = "test_image.svg"
6168
file_content = (
@@ -71,7 +78,7 @@ def file(tmp_path: Path) -> Dict[str, str]:
7178
b'</linearGradient> <linearGradient id="paint1_linear" x1="36.1558" y1="30.578" x2="54.4844" y2="65.0806" '
7279
b'gradientUnits="userSpaceOnUse"> <stop/> <stop offset="1" stop-opacity="0"/> </linearGradient> </defs> </svg>'
7380
)
74-
bucket_folder = uuid4().hex[:8]
81+
bucket_folder = uuid
7582
bucket_path = f"{bucket_folder}/{file_name}"
7683
file_path = tmp_path / file_name
7784
with open(file_path, "wb") as f:

0 commit comments

Comments
 (0)