Skip to content

Commit

Permalink
testing almost all formats whether they make folders for subsets
Browse files Browse the repository at this point in the history
  • Loading branch information
Eldies committed Jul 16, 2024
1 parent 6179abe commit b737547
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions tests/python/rest_api/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,32 @@ def test_can_export_and_import_dataset_after_deleting_related_storage(

self._test_import_project(admin_user, project_id, "CVAT 1.1", import_data)

@pytest.mark.parametrize("export_format", ["COCO 1.0", "COCO Keypoints 1.0"])
def test_creates_subfolders_in_coco_export(self, tasks, admin_user, export_format):
@pytest.mark.parametrize(
"export_format, subset_path_template",
[
("COCO 1.0", "images/{subset}/"),
("COCO Keypoints 1.0", "images/{subset}/"),
('CVAT for images 1.1', "images/{subset}/"),
('CVAT for video 1.1', "images/{subset}/"),
('Datumaro 1.0', "images/{subset}/"),
('Datumaro 3D 1.0', "point_clouds/{subset}/"),
('LabelMe 3.0', "{subset}/"),
('MOTS PNG 1.0', "{subset}/images/"),
('YOLO 1.1', "obj_{subset}_data/"),
('CamVid 1.0', "{subset}/"),
('WiderFace 1.0', "WIDER_{subset}/images/"),
('VGGFace2 1.0', "{subset}/"),
('Market-1501 1.0', "bounding_box_{subset}/"),
('ICDAR Recognition 1.0', "{subset}/images/"),
('ICDAR Localization 1.0', "{subset}/images/"),
('ICDAR Segmentation 1.0', "{subset}/images/"),
('KITTI 1.0', "{subset}/image_2/"),
('LFW 1.0', "{subset}/images/"),
('Cityscapes 1.0', "imgsFine/leftImg8bit/{subset}/"),
('Open Images V6 1.0', "images/{subset}/"),
],
)
def test_creates_subfolders_for_subsets_on_export(self, tasks, admin_user, export_format, subset_path_template):
group_key_func = itemgetter("project_id")
subsets = ["Train", "Validation"]
project_id = next(
Expand All @@ -831,9 +855,10 @@ def test_creates_subfolders_in_coco_export(self, tasks, admin_user, export_forma
response = self._test_export_project(admin_user, project_id, format=export_format)
with zipfile.ZipFile(io.BytesIO(response.data)) as zip_file:
for subset in subsets:
folder_prefix = subset_path_template.format(subset=subset)
assert (
len([f for f in zip_file.namelist() if f.startswith(f"images/{subset}/")]) > 0
)
len([f for f in zip_file.namelist() if f.startswith(folder_prefix)]) > 0
), f"No {folder_prefix} in {zip_file.namelist()}"


@pytest.mark.usefixtures("restore_db_per_function")
Expand Down Expand Up @@ -1025,8 +1050,8 @@ def test_admin_can_add_skeleton(self, projects, admin_user):
}
],
"svg": '<circle r="1.5" stroke="black" fill="#b3b3b3" cx="48.794559478759766" '
'cy="36.98698806762695" stroke-width="0.1" data-type="element node" '
'data-element-id="1" data-node-id="1" data-label-name="597501"></circle>',
'cy="36.98698806762695" stroke-width="0.1" data-type="element node" '
'data-element-id="1" data-node-id="1" data-label-name="597501"></circle>',
}

prev_lc = get_method(admin_user, "labels", project_id=project["id"]).json()["count"]
Expand Down Expand Up @@ -1133,7 +1158,7 @@ def test_if_supervisor_or_worker_cannot_see_project_preview(
for user in find_users(role=role, exclude_privilege="admin")
for project in projects
if project["organization"] == user["org"]
and not is_project_staff(user["id"], project["id"])
and not is_project_staff(user["id"], project["id"])
)
)

Expand All @@ -1149,8 +1174,8 @@ def test_if_maintainer_or_owner_can_see_project_preview(
for user in find_users(role=role, exclude_privilege="admin")
for project in projects
if project["organization"] == user["org"]
and not is_project_staff(user["id"], project["id"])
and project["tasks"]["count"] > 0
and not is_project_staff(user["id"], project["id"])
and project["tasks"]["count"] > 0
)
)

Expand Down

0 comments on commit b737547

Please sign in to comment.