Skip to content

Commit

Permalink
[qa] black
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBldy committed Sep 13, 2023
1 parent c88735e commit 390bbc0
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 35 deletions.
10 changes: 6 additions & 4 deletions tests/models/test_metadata_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down Expand Up @@ -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"}
Expand Down
2 changes: 1 addition & 1 deletion tests/tiles/test_route_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions tests/utils/test_movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions zou/app/blueprints/crud/metadata_descriptor.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,7 +11,7 @@

from zou.app.services.exception import (
ArgumentsException,
DepartmentNotFoundException
DepartmentNotFoundException,
)


Expand Down
4 changes: 1 addition & 3 deletions zou/app/blueprints/previews/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 10 additions & 8 deletions zou/app/services/preview_files_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)
from zou.app.services.exception import (
ArgumentsException,
PreviewFileNotFoundException
PreviewFileNotFoundException,
)
from zou.app.utils import fs

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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}",
Expand All @@ -743,4 +746,3 @@ def reset_picture_file_metadata():
str(preview_file.id),
e,
)

Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###

0 comments on commit 390bbc0

Please sign in to comment.