Skip to content

Commit

Permalink
Added test for serialising plain text labels
Browse files Browse the repository at this point in the history
  • Loading branch information
clinton-encord committed Jan 6, 2025
1 parent 3ee74fc commit f573bf6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
14 changes: 1 addition & 13 deletions tests/objects/data/plain_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,7 @@
"objectHash": "textObjectHash",
"featureHash": "textObjectFeatureNodeHash",
"classifications": [],
"range": [],
"range_html": [
{
"start": {
"node": "start_node",
"offset": 5,
},
"end": {
"node": "end_node",
"offset": 10,
},
}
],
"range": [[0, 5]],
"createdBy": "user1Hash",
"createdAt": "Tue, 05 Nov 2024 09:41:37 ",
"lastEditedBy": "user1Hash",
Expand Down
18 changes: 18 additions & 0 deletions tests/objects/test_label_structure_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from tests.objects.data.ontology_with_many_dynamic_classifications import (
ontology as ontology_with_many_dynamic_classifications,
)
from tests.objects.data.plain_text import PLAIN_TEXT_LABELS


def ontology_from_dict(ontology_structure_dict: Dict):
Expand Down Expand Up @@ -177,6 +178,23 @@ def test_serialise_html_text():
)


def test_serialise_plain_text():
label_row_metadata_dict = asdict(FAKE_LABEL_ROW_METADATA)
label_row_metadata_dict["frames_per_second"] = 1000
label_row_metadata_dict["data_type"] = "plain_text"
label_row_metadata = LabelRowMetadata(**label_row_metadata_dict)

label_row = LabelRowV2(label_row_metadata, Mock(), ontology_from_dict(all_ontology_types))
label_row.from_labels_dict(PLAIN_TEXT_LABELS)

actual = label_row.to_encord_dict()
deep_diff_enhanced(
PLAIN_TEXT_LABELS,
actual,
exclude_regex_paths=[r"\['reviews'\]", r"\['isDeleted'\]"],
)


def test_serialise_dicom_with_dynamic_classifications():
label_row_metadata_dict = asdict(FAKE_LABEL_ROW_METADATA)
label_row_metadata_dict["duration"] = None
Expand Down

0 comments on commit f573bf6

Please sign in to comment.