From 390bbc03d98317354a4f8ff1ec6c093e8f275c2e Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Wed, 13 Sep 2023 17:25:06 +0200 Subject: [PATCH] [qa] black --- tests/models/test_metadata_descriptor.py | 10 ++++++---- tests/tiles/test_route_tiles.py | 2 +- tests/utils/test_movie.py | 6 +++--- zou/app/blueprints/crud/metadata_descriptor.py | 4 ++-- zou/app/blueprints/previews/resources.py | 4 +--- zou/app/services/preview_files_service.py | 18 ++++++++++-------- ...6_add_previewfile_width_and_previewfile_.py | 16 ++++++++-------- ...dc_add_preview_download_flag_to_projects.py | 16 ++++++++++------ 8 files changed, 41 insertions(+), 35 deletions(-) diff --git a/tests/models/test_metadata_descriptor.py b/tests/models/test_metadata_descriptor.py index b5abf97718..e913858e54 100644 --- a/tests/models/test_metadata_descriptor.py +++ b/tests/models/test_metadata_descriptor.py @@ -19,8 +19,9 @@ def test_get_metadata_descriptors(self): def test_get_metadata_descriptor(self): descriptor = self.get_first("data/metadata-descriptors") - descriptor_again = \ - self.get("data/metadata-descriptors/%s" % descriptor["id"]) + descriptor_again = self.get( + "data/metadata-descriptors/%s" % descriptor["id"] + ) self.assertEqual(descriptor, descriptor_again) self.get_404("data/metadata-descriptor/%s" % fields.gen_uuid()) @@ -49,8 +50,9 @@ def test_update_metadatad_descriptor(self): descriptor = self.get_first("data/metadata-descriptors") data = {"name": "Descriptor test update"} self.put("data/metadata-descriptors/%s" % descriptor["id"], data) - descriptor_again = \ - self.get("data/metadata-descriptors/%s" % descriptor["id"]) + descriptor_again = self.get( + "data/metadata-descriptors/%s" % descriptor["id"] + ) self.assertEqual(data["name"], descriptor_again["name"]) self.put_404("data/metadata-descriptors/%s" % fields.gen_uuid(), data) data = {"data_type": "wrongdatatype"} diff --git a/tests/tiles/test_route_tiles.py b/tests/tiles/test_route_tiles.py index fcd98ca0af..27b7dbde01 100644 --- a/tests/tiles/test_route_tiles.py +++ b/tests/tiles/test_route_tiles.py @@ -46,7 +46,7 @@ def delete_tile_folders(self): def test_extract_tile(self): path = "/pictures/preview-files/%s" % self.preview_file_id file_path_fixture = self.get_fixture_file_path( - "videos/test_preview_tiles.mp4" + "videos/test_preview_tiles.mp4" ) self.upload_file(path, file_path_fixture) diff --git a/tests/utils/test_movie.py b/tests/utils/test_movie.py index 426749a478..545114edf0 100644 --- a/tests/utils/test_movie.py +++ b/tests/utils/test_movie.py @@ -134,12 +134,12 @@ def test_create_tile(self): img_width, img_height = image.size probe = ffmpeg.probe(video_path) - duration_in_seconds = float(probe['streams'][0]['duration']) - float_movie_fps = eval(probe['streams'][0]['r_frame_rate']) + duration_in_seconds = float(probe["streams"][0]["duration"]) + float_movie_fps = eval(probe["streams"][0]["r_frame_rate"]) duration_in_frames = int(duration_in_seconds * float_movie_fps) rows = math.ceil((duration_in_frames / 8)) - aspect_ratio = (video_width / video_height) + aspect_ratio = video_width / video_height target_width = math.ceil(aspect_ratio * 100) os.remove(tile_path) diff --git a/zou/app/blueprints/crud/metadata_descriptor.py b/zou/app/blueprints/crud/metadata_descriptor.py index b1fa20631e..af9c0fcf91 100644 --- a/zou/app/blueprints/crud/metadata_descriptor.py +++ b/zou/app/blueprints/crud/metadata_descriptor.py @@ -1,6 +1,6 @@ from zou.app.models.metadata_descriptor import ( MetadataDescriptor, - METADATA_DESCRIPTOR_TYPES + METADATA_DESCRIPTOR_TYPES, ) from zou.app.models.department import Department @@ -11,7 +11,7 @@ from zou.app.services.exception import ( ArgumentsException, - DepartmentNotFoundException + DepartmentNotFoundException, ) diff --git a/zou/app/blueprints/previews/resources.py b/zou/app/blueprints/previews/resources.py index b82d5c10f3..8ab4825137 100644 --- a/zou/app/blueprints/previews/resources.py +++ b/zou/app/blueprints/previews/resources.py @@ -280,9 +280,7 @@ def save_picture_preview(self, instance_id, uploaded_file): ) file_size = fs.get_file_size(original_tmp_path) width, height = thumbnail_utils.get_dimensions(original_tmp_path) - preview_files_service.save_variants( - instance_id, original_tmp_path - ) + preview_files_service.save_variants(instance_id, original_tmp_path) return { "preview_file_id": instance_id, "file_size": file_size, diff --git a/zou/app/services/preview_files_service.py b/zou/app/services/preview_files_service.py index b6cd8d6764..7c71948b21 100644 --- a/zou/app/services/preview_files_service.py +++ b/zou/app/services/preview_files_service.py @@ -24,7 +24,7 @@ ) from zou.app.services.exception import ( ArgumentsException, - PreviewFileNotFoundException + PreviewFileNotFoundException, ) from zou.app.utils import fs @@ -273,12 +273,13 @@ def prepare_and_store_movie( os.remove(normalized_movie_low_path) preview_file = update_preview_file_raw( - preview_file_raw, { + preview_file_raw, + { "status": "ready", "file_size": file_size, "width": width, "height": height, - } + }, ) return preview_file @@ -686,11 +687,12 @@ def reset_movie_file_metadata(): file_size = os.path.getsize(preview_file_path) width, height = size update_preview_file_raw( - preview_file, { + preview_file, + { "width": width, "height": height, "file_size": file_size, - } + }, ) print( f"Size information stored for {preview_file.id}", @@ -728,11 +730,12 @@ def reset_picture_file_metadata(): width, height = thumbnail_utils.get_dimensions(preview_file_path) file_size = os.path.getsize(preview_file_path) update_preview_file_raw( - preview_file, { + preview_file, + { "width": width, "height": height, "file_size": file_size, - } + }, ) print( f"Size information stored for {preview_file.id}", @@ -743,4 +746,3 @@ def reset_picture_file_metadata(): str(preview_file.id), e, ) - diff --git a/zou/migrations/versions/ae0127f2fc56_add_previewfile_width_and_previewfile_.py b/zou/migrations/versions/ae0127f2fc56_add_previewfile_width_and_previewfile_.py index a2bc055a52..69c0fd0232 100644 --- a/zou/migrations/versions/ae0127f2fc56_add_previewfile_width_and_previewfile_.py +++ b/zou/migrations/versions/ae0127f2fc56_add_previewfile_width_and_previewfile_.py @@ -11,25 +11,25 @@ # revision identifiers, used by Alembic. -revision = 'ae0127f2fc56' -down_revision = 'f5bdca075cdc' +revision = "ae0127f2fc56" +down_revision = "f5bdca075cdc" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('preview_file', schema=None) as batch_op: - batch_op.add_column(sa.Column('width', sa.Integer(), nullable=True)) - batch_op.add_column(sa.Column('height', sa.Integer(), nullable=True)) + with op.batch_alter_table("preview_file", schema=None) as batch_op: + batch_op.add_column(sa.Column("width", sa.Integer(), nullable=True)) + batch_op.add_column(sa.Column("height", sa.Integer(), nullable=True)) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('preview_file', schema=None) as batch_op: - batch_op.drop_column('height') - batch_op.drop_column('width') + with op.batch_alter_table("preview_file", schema=None) as batch_op: + batch_op.drop_column("height") + batch_op.drop_column("width") # ### end Alembic commands ### diff --git a/zou/migrations/versions/f5bdca075cdc_add_preview_download_flag_to_projects.py b/zou/migrations/versions/f5bdca075cdc_add_preview_download_flag_to_projects.py index d140dd54d4..e14c0b9089 100644 --- a/zou/migrations/versions/f5bdca075cdc_add_preview_download_flag_to_projects.py +++ b/zou/migrations/versions/f5bdca075cdc_add_preview_download_flag_to_projects.py @@ -11,23 +11,27 @@ # revision identifiers, used by Alembic. -revision = 'f5bdca075cdc' -down_revision = 'f4ff5a73d283' +revision = "f5bdca075cdc" +down_revision = "f4ff5a73d283" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('project', schema=None) as batch_op: - batch_op.add_column(sa.Column('is_preview_download_allowed', sa.Boolean(), nullable=True)) + with op.batch_alter_table("project", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "is_preview_download_allowed", sa.Boolean(), nullable=True + ) + ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('project', schema=None) as batch_op: - batch_op.drop_column('is_preview_download_allowed') + with op.batch_alter_table("project", schema=None) as batch_op: + batch_op.drop_column("is_preview_download_allowed") # ### end Alembic commands ###