Skip to content

Commit 10fac4c

Browse files
committed
updates to tests
1 parent 53031fa commit 10fac4c

File tree

6 files changed

+49
-50
lines changed

6 files changed

+49
-50
lines changed

tests/conftest.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from datetime import datetime
2+
from random import randint
3+
from string import ascii_letters
4+
5+
import pytest
6+
7+
8+
@pytest.fixture
9+
def rand_gen():
10+
11+
def gen(field_type):
12+
if field_type is str:
13+
return "".join(ascii_letters[randint(0,
14+
len(ascii_letters) - 1)]
15+
for _ in range(16))
16+
17+
if field_type is datetime:
18+
return datetime.now()
19+
20+
raise Exception("Can't random generate for field type '%r'" %
21+
field_type)
22+
23+
return gen

tests/integration/conftest.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,6 @@ def image_url(client):
134134
return client.upload_data(requests.get(IMG_URL).content, sign=True)
135135

136136

137-
@pytest.fixture
138-
def rand_gen():
139-
140-
def gen(field_type):
141-
if field_type is str:
142-
return "".join(ascii_letters[randint(0,
143-
len(ascii_letters) - 1)]
144-
for _ in range(16))
145-
146-
if field_type is datetime:
147-
return datetime.now()
148-
149-
raise Exception("Can't random generate for field type '%r'" %
150-
field_type)
151-
152-
return gen
153-
154137

155138
@pytest.fixture
156139
def project(client, rand_gen):
@@ -258,15 +241,13 @@ def configured_project(project, client, rand_gen, image_url):
258241

259242

260243
@pytest.fixture
261-
def configured_project_with_label(client, rand_gen, image_url):
244+
def configured_project_with_label(client, rand_gen, image_url, project, dataset, datarow):
262245
"""Project with a connected dataset, having one datarow
263246
Project contains an ontology with 1 bbox tool
264247
Additionally includes a create_label method for any needed extra labels
265248
One label is already created and yielded when using fixture
266249
"""
267-
project = client.create_project(name=rand_gen(str))
268-
dataset = client.create_dataset(name=rand_gen(str), projects=project)
269-
data_row = dataset.create_data_row(row_data=image_url)
250+
project.datasets.connect(dataset)
270251
editor = list(
271252
project.client.get_labeling_frontends(
272253
where=LabelingFrontend.name == "editor"))[0]
@@ -280,7 +261,7 @@ def configured_project_with_label(client, rand_gen, image_url):
280261
"uuid": str(uuid.uuid4()),
281262
"schemaId": ontology.tools[0].feature_schema_id,
282263
"dataRow": {
283-
"id": data_row.uid
264+
"id": datarow.uid
284265
},
285266
"bbox": {
286267
"top": 20,
@@ -302,10 +283,7 @@ def create_label():
302283
project.create_label = create_label
303284
project.create_label()
304285
label = next(project.labels())
305-
yield [project, dataset, data_row, label]
306-
dataset.delete()
307-
project.delete()
308-
data_row.delete()
286+
yield [project, dataset, datarow, label]
309287

310288
for label in project.labels():
311289
label.delete()

tests/integration/test_label.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ def test_labels(configured_project_with_label):
1818

1919
label.delete()
2020

21-
# Labels are not visible in the project immediately.
22-
time.sleep(5)
23-
2421
assert list(project.labels()) == []
2522
assert list(data_row.labels()) == []
2623

tests/integration/test_ontology.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
import json
66
import time
77

8-
8+
@pytest.mark.skip(reason="normalized ontology contains Relationship, "
9+
"which is not finalized yet. introduce this back when"
10+
"Relationship feature is complete and we introduce"
11+
"a Relationship object to the ontology that we can parse"
12+
)
913
def test_from_project_ontology(project) -> None:
1014
o = OntologyBuilder.from_project(project)
1115
assert o.asdict() == project.ontology().normalized

tests/integration/test_review.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ def test_reviews(configured_project_with_label):
1010
assert set(label.reviews()) == set()
1111

1212
r1 = label.create_review(score=-1.0)
13-
# They work on data that was created in the editor but not with project.create_label
14-
# assert r1.project() == project
15-
# assert r1.label() == label
1613
assert r1.score == -1.0
1714
assert set(label.reviews()) == {r1}
1815

tests/unit/conftest.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
from datetime import datetime
2-
from random import randint
3-
from string import ascii_letters
1+
# from datetime import datetime
2+
# from random import randint
3+
# from string import ascii_letters
44

5-
import pytest
5+
# import pytest
66

7-
IMG_URL = "https://picsum.photos/200/300"
7+
# IMG_URL = "https://picsum.photos/200/300"
88

99

10-
@pytest.fixture
11-
def rand_gen():
10+
# @pytest.fixture
11+
# def rand_gen():
1212

13-
def gen(field_type):
14-
if field_type is str:
15-
return "".join(ascii_letters[randint(0,
16-
len(ascii_letters) - 1)]
17-
for _ in range(16))
13+
# def gen(field_type):
14+
# if field_type is str:
15+
# return "".join(ascii_letters[randint(0,
16+
# len(ascii_letters) - 1)]
17+
# for _ in range(16))
1818

19-
if field_type is datetime:
20-
return datetime.now()
19+
# if field_type is datetime:
20+
# return datetime.now()
2121

22-
raise Exception("Can't random generate for field type '%r'" %
23-
field_type)
22+
# raise Exception("Can't random generate for field type '%r'" %
23+
# field_type)
2424

25-
return gen
25+
# return gen

0 commit comments

Comments
 (0)