Skip to content

Commit eb25861

Browse files
committed
add test fixture
1 parent 261c40d commit eb25861

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

tests/test_dataset.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import pytest
2-
31
from pathlib import Path
4-
2+
import pytest
53
from nucleus import Dataset, DatasetItem, UploadResponse
64
from nucleus.constants import (
75
NEW_ITEMS,
@@ -13,16 +11,17 @@
1311
)
1412

1513

16-
TEST_DATASET_NAME = '[PyTest] Test Dataset'
14+
TEST_DATASET_NAME = "[PyTest] Test Dataset"
1715
TEST_IMG_URLS = [
18-
's3://scaleapi-attachments/BDD/BDD/bdd100k/images/100k/train/6dd63871-831611a6.jpg',
19-
's3://scaleapi-attachments/BDD/BDD/bdd100k/images/100k/train/82c1005c-e2d1d94f.jpg',
20-
's3://scaleapi-attachments/BDD/BDD/bdd100k/images/100k/train/7f2e1814-6591087d.jpg',
21-
's3://scaleapi-attachments/BDD/BDD/bdd100k/images/100k/train/06924f46-1708b96f.jpg',
22-
's3://scaleapi-attachments/BDD/BDD/bdd100k/images/100k/train/89b42832-10d662f4.jpg',
16+
"s3://scaleapi-attachments/BDD/BDD/bdd100k/images/100k/train/6dd63871-831611a6.jpg",
17+
"s3://scaleapi-attachments/BDD/BDD/bdd100k/images/100k/train/82c1005c-e2d1d94f.jpg",
18+
"s3://scaleapi-attachments/BDD/BDD/bdd100k/images/100k/train/7f2e1814-6591087d.jpg",
19+
"s3://scaleapi-attachments/BDD/BDD/bdd100k/images/100k/train/06924f46-1708b96f.jpg",
20+
"s3://scaleapi-attachments/BDD/BDD/bdd100k/images/100k/train/89b42832-10d662f4.jpg",
2321
]
2422

25-
@pytest.fixture(scope='module')
23+
24+
@pytest.fixture(scope="module")
2625
def dataset(CLIENT):
2726
ds = CLIENT.create_dataset(TEST_DATASET_NAME)
2827
yield ds
@@ -66,28 +65,29 @@ def check_is_expected_response(response):
6665
# With reference ids and metadata:
6766
ds_items_with_metadata = []
6867
for i, url in enumerate(TEST_IMG_URLS):
69-
ds_items_with_metadata.append(DatasetItem(
70-
image_location=url,
71-
reference_id=Path(url).name,
72-
metadata={
73-
'made_with_pytest': True,
74-
'example_int': i,
75-
'example_str': 'hello',
76-
'example_float': 0.5,
77-
'example_dict': {
78-
'nested': True,
68+
ds_items_with_metadata.append(
69+
DatasetItem(
70+
image_location=url,
71+
reference_id=Path(url).name,
72+
metadata={
73+
"made_with_pytest": True,
74+
"example_int": i,
75+
"example_str": "hello",
76+
"example_float": 0.5,
77+
"example_dict": {
78+
"nested": True,
79+
},
80+
"example_list": ["hello", i, False],
7981
},
80-
'example_list': ['hello', i, False],
81-
}
82-
))
82+
)
83+
)
8384

8485
response = dataset.append(ds_items_with_metadata)
8586
check_is_expected_response(response)
8687

87-
def test_dataset_list_autotags(CLIENT):
88+
89+
def test_dataset_list_autotags(CLIENT, dataset):
8890
# Creation
89-
ds = CLIENT.create_dataset(TEST_DATASET_NAME)
90-
assert isinstance(ds, Dataset)
9191
# List of Autotags should be empty
92-
autotag_response = CLIENT.list_autotags(ds.id)
92+
autotag_response = CLIENT.list_autotags(dataset.id)
9393
assert autotag_response == []

0 commit comments

Comments
 (0)