Skip to content

Commit de29802

Browse files
committed
adding sync tests
1 parent bb88179 commit de29802

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/integration/test_data_rows.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from labelbox import DataRow
99
from labelbox.schema.data_row_metadata import DataRowMetadataField
10+
from labelbox.exceptions import MalformedQueryException
1011
import labelbox.exceptions
1112

1213
SPLIT_SCHEMA_ID = "cko8sbczn0002h2dkdaxb5kal"
@@ -645,3 +646,52 @@ def test_data_row_bulk_creation_with_same_global_keys(dataset, sample_image):
645646
assert task.status == "COMPLETE"
646647
assert len(list(dataset.data_rows())) == 1
647648
assert list(dataset.data_rows())[0].global_key == global_key_1
649+
650+
651+
def test_data_row_bulk_creation_sync_with_unique_global_keys(
652+
dataset, sample_image):
653+
global_key_1 = str(uuid.uuid4())
654+
global_key_2 = str(uuid.uuid4())
655+
global_key_3 = str(uuid.uuid4())
656+
657+
dataset.create_data_rows_sync([
658+
{
659+
DataRow.row_data: sample_image,
660+
DataRow.global_key: global_key_1
661+
},
662+
{
663+
DataRow.row_data: sample_image,
664+
DataRow.global_key: global_key_2
665+
},
666+
{
667+
DataRow.row_data: sample_image,
668+
DataRow.global_key: global_key_3
669+
},
670+
])
671+
672+
assert {row.global_key for row in dataset.data_rows()
673+
} == {global_key_1, global_key_2, global_key_3}
674+
675+
676+
def test_data_row_rulk_creation_sync_with_same_global_keys(
677+
dataset, sample_image):
678+
global_key_1 = str(uuid.uuid4())
679+
680+
with pytest.raises(labelbox.exceptions.MalformedQueryException):
681+
dataset.create_data_rows_sync([{
682+
DataRow.row_data: sample_image,
683+
DataRow.global_key: global_key_1
684+
}, {
685+
DataRow.row_data: sample_image,
686+
DataRow.global_key: global_key_1
687+
}])
688+
689+
assert len(list(dataset.data_rows())) == 0
690+
691+
dataset.create_data_rows_sync([{
692+
DataRow.row_data: sample_image,
693+
DataRow.global_key: global_key_1
694+
}])
695+
696+
assert len(list(dataset.data_rows())) == 1
697+
assert list(dataset.data_rows())[0].global_key == global_key_1

0 commit comments

Comments
 (0)