|
| 1 | +from pathlib import Path |
| 2 | +import filecmp |
| 3 | + |
| 4 | +import superannotate as sa |
| 5 | + |
| 6 | +import pytest |
| 7 | + |
| 8 | +PROJECT_NAME1 = "test image qual setting1" |
| 9 | +PROJECT_NAME2 = "test image qual setting2" |
| 10 | + |
| 11 | + |
| 12 | +def test_image_quality_setting1(tmpdir): |
| 13 | + tmpdir = Path(tmpdir) |
| 14 | + |
| 15 | + projects = sa.search_projects(PROJECT_NAME1, return_metadata=True) |
| 16 | + for project in projects: |
| 17 | + sa.delete_project(project) |
| 18 | + |
| 19 | + project = sa.create_project(PROJECT_NAME1, "test", "Vector") |
| 20 | + |
| 21 | + sa.upload_images_from_folder_to_project( |
| 22 | + project, "./tests/sample_project_vector" |
| 23 | + ) |
| 24 | + |
| 25 | + sa.download_image(project, "example_image_1.jpg", tmpdir, variant="lores") |
| 26 | + |
| 27 | + assert not filecmp.cmp( |
| 28 | + tmpdir / "example_image_1.jpg___lores.jpg", |
| 29 | + "./tests/sample_project_vector/example_image_1.jpg", |
| 30 | + shallow=False |
| 31 | + ) |
| 32 | + |
| 33 | + |
| 34 | +def test_image_quality_setting2(tmpdir): |
| 35 | + tmpdir = Path(tmpdir) |
| 36 | + |
| 37 | + projects = sa.search_projects(PROJECT_NAME2, return_metadata=True) |
| 38 | + for project in projects: |
| 39 | + sa.delete_project(project) |
| 40 | + |
| 41 | + project = sa.create_project(PROJECT_NAME2, "test", "Vector") |
| 42 | + |
| 43 | + sa.set_project_default_image_quality_in_editor(project, "original") |
| 44 | + |
| 45 | + sa.upload_images_from_folder_to_project( |
| 46 | + project, "./tests/sample_project_vector" |
| 47 | + ) |
| 48 | + |
| 49 | + sa.download_image(project, "example_image_1.jpg", tmpdir, variant="lores") |
| 50 | + |
| 51 | + assert filecmp.cmp( |
| 52 | + tmpdir / "example_image_1.jpg___lores.jpg", |
| 53 | + "./tests/sample_project_vector/example_image_1.jpg", |
| 54 | + shallow=False |
| 55 | + ) |
0 commit comments