Coverage for /home/ubuntu/hidebound/python/hidebound/core/test_specifications.py: 100%
30 statements
« prev ^ index » next coverage.py v7.5.4, created at 2024-07-05 23:50 +0000
« prev ^ index » next coverage.py v7.5.4, created at 2024-07-05 23:50 +0000
1from typing import Any, Dict, List # noqa F401
3from schematics.types import IntType, ListType, StringType
5from hidebound.core.specification_base import FileSpecificationBase
6from hidebound.core.specification_base import SequenceSpecificationBase
7import hidebound.core.traits as tr
8import hidebound.core.validators as vd
9# ------------------------------------------------------------------------------
12class Spec001(SequenceSpecificationBase):
13 asset_name_fields = ['project', 'specification', 'descriptor', 'version'] # type: List[str]
14 filename_fields = [
15 'project', 'specification', 'descriptor', 'version', 'coordinate',
16 'frame', 'extension'
17 ] # type: List[str]
18 descriptor = ListType(
19 StringType(),
20 required=True,
21 validators=[vd.is_descriptor, vd.is_homogenous]
22 ) # type: ListType
23 frame = ListType(
24 IntType(),
25 required=True,
26 validators=[vd.is_frame]
27 ) # type: ListType
28 extension = ListType(
29 StringType(),
30 required=True,
31 validators=[vd.is_extension, lambda x: vd.is_eq(x, 'png')]
32 ) # type: ListType
33 coordinate = ListType(
34 ListType(IntType(), required=True, validators=[vd.is_coordinate])
35 ) # type: ListType
37 height = ListType(IntType(), required=True) # type: ListType
38 width = ListType(IntType(), required=True) # type: ListType
39 channels = ListType(IntType(), required=True) # type: ListType
40 file_traits = dict(
41 width=tr.get_image_width,
42 height=tr.get_image_height,
43 channels=tr.get_num_image_channels
44 ) # type: Dict[str, Any]
47class Spec002(SequenceSpecificationBase):
48 asset_name_fields = ['project', 'specification', 'descriptor', 'version'] # type: List[str]
49 filename_fields = [
50 'project', 'specification', 'descriptor', 'version', 'frame',
51 'extension'
52 ] # type: List[str]
53 frame = ListType(
54 IntType(),
55 required=True,
56 validators=[vd.is_frame, lambda x: vd.is_gt(x, -1)]
57 ) # type: ListType
58 extension = ListType(
59 StringType(),
60 required=True,
61 validators=[vd.is_extension, lambda x: vd.is_eq(x, 'jpg')]
62 ) # type: ListType
63 width = ListType(
64 IntType(),
65 required=True,
66 validators=[lambda x: vd.is_eq(x, 1024)]
67 ) # type: ListType
68 height = ListType(
69 IntType(),
70 required=True,
71 validators=[lambda x: vd.is_eq(x, 1024)]
72 ) # type: ListType
73 channels = ListType(
74 IntType(),
75 required=True,
76 validators=[lambda x: vd.is_eq(x, 3)]
77 ) # type: ListType
78 file_traits = dict(
79 width=tr.get_image_width,
80 height=tr.get_image_height,
81 channels=tr.get_num_image_channels
82 ) # type: Dict[str, Any]
85class Vdb001(FileSpecificationBase):
86 filename_fields = [
87 'project', 'specification', 'descriptor', 'version', 'extension'
88 ] # type: List[str]
89 extension = ListType(
90 StringType(),
91 required=True,
92 validators=[vd.is_extension, lambda x: vd.is_eq(x, 'vdb')]
93 ) # type: ListType
94# ------------------------------------------------------------------------------
97SPECIFICATIONS = [
98 Spec001,
99 Spec002,
100 Vdb001,
101] # type: List[type]