elody 0.0.63__py3-none-any.whl → 0.0.162__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. elody/client.py +70 -23
  2. elody/csv.py +118 -21
  3. elody/error_codes.py +112 -0
  4. elody/exceptions.py +14 -0
  5. elody/job.py +95 -0
  6. elody/loader.py +33 -5
  7. elody/migration/__init__.py +0 -0
  8. elody/migration/base_object_migrator.py +18 -0
  9. elody/object_configurations/__init__.py +0 -0
  10. elody/object_configurations/base_object_configuration.py +174 -0
  11. elody/object_configurations/elody_configuration.py +144 -0
  12. elody/object_configurations/job_configuration.py +65 -0
  13. elody/policies/authentication/base_user_tenant_validation_policy.py +48 -15
  14. elody/policies/authorization/filter_generic_objects_policy.py +68 -22
  15. elody/policies/authorization/filter_generic_objects_policy_v2.py +166 -0
  16. elody/policies/authorization/generic_object_detail_policy.py +10 -27
  17. elody/policies/authorization/generic_object_mediafiles_policy.py +82 -0
  18. elody/policies/authorization/generic_object_metadata_policy.py +8 -27
  19. elody/policies/authorization/generic_object_relations_policy.py +12 -29
  20. elody/policies/authorization/generic_object_request_policy.py +56 -55
  21. elody/policies/authorization/generic_object_request_policy_v2.py +133 -0
  22. elody/policies/authorization/mediafile_derivatives_policy.py +92 -0
  23. elody/policies/authorization/mediafile_download_policy.py +71 -0
  24. elody/policies/authorization/multi_tenant_policy.py +14 -6
  25. elody/policies/authorization/tenant_request_policy.py +3 -1
  26. elody/policies/helpers.py +37 -0
  27. elody/policies/permission_handler.py +217 -199
  28. elody/policies/tenant_id_resolver.py +375 -0
  29. elody/schemas.py +0 -3
  30. elody/util.py +165 -11
  31. {elody-0.0.63.dist-info → elody-0.0.162.dist-info}/METADATA +16 -11
  32. elody-0.0.162.dist-info/RECORD +47 -0
  33. {elody-0.0.63.dist-info → elody-0.0.162.dist-info}/WHEEL +1 -1
  34. {elody-0.0.63.dist-info → elody-0.0.162.dist-info}/top_level.txt +1 -0
  35. tests/__init_.py +0 -0
  36. tests/data.py +74 -0
  37. tests/unit/__init__.py +0 -0
  38. tests/unit/test_csv.py +410 -0
  39. tests/unit/test_utils.py +293 -0
  40. elody-0.0.63.dist-info/RECORD +0 -27
  41. {elody-0.0.63.dist-info → elody-0.0.162.dist-info}/LICENSE +0 -0
@@ -0,0 +1,47 @@
1
+ __init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ elody/__init__.py,sha256=d0Q6Fn44e7wFfLabDOBxpcJ1DPKWlFunGYDUBmO-4hA,22
3
+ elody/client.py,sha256=Es0iloHq9aOiMgXfwssEiV1Nqvvd6Z3RfsyoJvIZ48I,8280
4
+ elody/csv.py,sha256=roWvNsfZrGceHvorZCX5lGq-9Ptgu8jSLmBbr7fXILw,13543
5
+ elody/error_codes.py,sha256=6ZupdNjCtTdtYWzn7yugndE3NxPcoZt3n7rOwR3zLWM,3919
6
+ elody/exceptions.py,sha256=5KSw2sPCZz3lDIJX4LiR2iL9n4m4KIil04D1d3X5rd0,968
7
+ elody/job.py,sha256=QnN6Q45yqRimziqJX9SHrTVFVvky5mAc1WEza9ia8_w,2811
8
+ elody/loader.py,sha256=Mr7zyP5DP5psYerf2-DnP90GiqtFlKZpcLIPD7P4pSU,5242
9
+ elody/schemas.py,sha256=WtKdZEAX-PtEuAaRohyS3Md8H4-8yKVXMkHfCQ2SDR4,4676
10
+ elody/util.py,sha256=1Ty4A3OVSmwawqjKyYW5zkhSwX-jZsC0_XllO_DL05M,8684
11
+ elody/validator.py,sha256=G7Ya538EJHCFzOxEri2OcFMabfLBCtTKxuf4os_KuNw,260
12
+ elody/migration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ elody/migration/base_object_migrator.py,sha256=n8uvgGfjEUy60G47RD7Y-oxp1vHLOauwPMDl87LcxtU,436
14
+ elody/object_configurations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ elody/object_configurations/base_object_configuration.py,sha256=L8K2AW-A3Bo4_Q_jl3S4hnwEGuZo3XmJH5Izditf6CM,6538
16
+ elody/object_configurations/elody_configuration.py,sha256=Bp3OSHBHuyPs-ubIULzl9wqZd3akYD2idh3mhYo7zu0,5339
17
+ elody/object_configurations/job_configuration.py,sha256=simi4TBiZ5cQePlzFHAd-C-khViWN9VUbAOKq9FYwk8,2057
18
+ elody/policies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ elody/policies/helpers.py,sha256=AV3wtvthJafW6ueEYGxggB5kk5knWTWzh3zq29Y1-ws,1434
20
+ elody/policies/permission_handler.py,sha256=1aXA_xfRxdTfHZY5xRwQqJp5pjSzBrhko4eGRT38WLQ,9505
21
+ elody/policies/tenant_id_resolver.py,sha256=BIl6lr9AH6Q_aZSsxF24B7ramkIZH-R-8bpLrTvYLtM,13796
22
+ elody/policies/authentication/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ elody/policies/authentication/base_user_tenant_validation_policy.py,sha256=fxvrB4iG6fehBh6b4XS8AWewtNsCABgSooma5ljjZk4,5144
24
+ elody/policies/authentication/multi_tenant_policy.py,sha256=jmV1RTsApt2IV8BgSRcfnIjWHhDtFjW4OHJgWNUDKRw,3822
25
+ elody/policies/authorization/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ elody/policies/authorization/filter_generic_objects_policy.py,sha256=XjKGM__WKG7n-QaopQGwSyvamQkye1DD6a-8mx2Xkwc,6518
27
+ elody/policies/authorization/filter_generic_objects_policy_v2.py,sha256=96lNmlxgzN8Lu4mXLRxAN-_pfGnK8BF5bXa-iSJofE0,6356
28
+ elody/policies/authorization/generic_object_detail_policy.py,sha256=kk49gIyOCasHH1U8T1-dJUQSW-R37N4wPQi0tMTWvBA,3455
29
+ elody/policies/authorization/generic_object_mediafiles_policy.py,sha256=bo9OL13-6vLhfG6dc_hg_EfynOk0fUbTZg-DmwTtBkU,2883
30
+ elody/policies/authorization/generic_object_metadata_policy.py,sha256=K-tNO1QIrlACupFSiZ12gH-N7T0s3y2hpPIpiKC_maQ,2783
31
+ elody/policies/authorization/generic_object_relations_policy.py,sha256=NRhywIntTpR69R_Lf1-sKfgWdXd7NW2K-lL8cGqWhhQ,3708
32
+ elody/policies/authorization/generic_object_request_policy.py,sha256=H9VGCMLyXO1k4n6ZOHOKcQ6K5ofLjjKe9KVTHH2FPIY,4863
33
+ elody/policies/authorization/generic_object_request_policy_v2.py,sha256=0bAjeq2uDunUDybOYApmNCpaaeCq97kNJEoqSfEUNMg,5051
34
+ elody/policies/authorization/mediafile_derivatives_policy.py,sha256=-i_JRgMcLjDQ85rzjBcrm3hXevAoTn5Z6itgt83K2Ik,3161
35
+ elody/policies/authorization/mediafile_download_policy.py,sha256=q5yib9EmXaWUcRMr-Kg2Fob7M7Mte6C8cmJ7K-rj_Go,2531
36
+ elody/policies/authorization/multi_tenant_policy.py,sha256=SA9H7SBjzuh8mY3gYN7pDG8TV7hdI3GEUtNeiZeNL3M,3164
37
+ elody/policies/authorization/tenant_request_policy.py,sha256=dEgblwRAqwWVcE-O7Jn8hVL3OnwDlQhDEOcPlcElBrk,1185
38
+ tests/__init_.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
+ tests/data.py,sha256=Q3oxduf-E3m-Z5G_p3fcs8jVy6g10I7zXKL1m94UVMI,2906
40
+ tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
+ tests/unit/test_csv.py,sha256=NQaOhehfQ4GuXku0Y1SA8DYjJeqqidbF50zEHAi8RZA,15923
42
+ tests/unit/test_utils.py,sha256=g63szcEZyHhCOtrW4BnNbcgVca3oYPIOLjBdIzNwwN0,8784
43
+ elody-0.0.162.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
44
+ elody-0.0.162.dist-info/METADATA,sha256=hdYI1u0QnWg9bhp7-U-daSg9iS88BdI76ZSG2WLCRyA,23336
45
+ elody-0.0.162.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
46
+ elody-0.0.162.dist-info/top_level.txt,sha256=E0mImupLj0KmtUUCXRYEoLDRaSkuiGaOIIseAa0oQ-M,21
47
+ elody-0.0.162.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,2 +1,3 @@
1
1
  __init__
2
2
  elody
3
+ tests
tests/__init_.py ADDED
File without changes
tests/data.py ADDED
@@ -0,0 +1,74 @@
1
+ mediafile1 = {
2
+ "_id": "2476c1a2-c323-499e-9e28-6d1562296f3f",
3
+ "filename": "41695fc83cdf1af3166dc77cc0d41e7a-bever.jpg",
4
+ "date_created": {"$date": "2024-11-28T08:33:47.479Z"},
5
+ "version": 3,
6
+ "thumbnail_file_location": "/iiif/3/41695fc83cdf1af3166dc77cc0d41e7a-bever.jpg/full/,150/0/default.jpg",
7
+ "original_file_location": "/download/41695fc83cdf1af3166dc77cc0d41e7a-bever.jpg",
8
+ "metadata": [
9
+ {"key": "copyright_color", "value": "green", "lang": "en"},
10
+ {"key": "copyright_color_calculation", "value": "automatic"},
11
+ ],
12
+ "identifiers": [
13
+ "2476c1a2-c323-499e-9e28-6d1562296f3f",
14
+ "41695fc83cdf1af3166dc77cc0d41e7a",
15
+ ],
16
+ "type": "mediafile",
17
+ "sort": {
18
+ "copyright_color": [{"value": "green", "lang": "en"}],
19
+ "copyright_color_calculation": [{"value": "green"}],
20
+ },
21
+ "relations": [
22
+ {
23
+ "key": "c4d1f89a-2858-4dd6-ba6b-cb333b4a5d7f",
24
+ "label": "hasMediafile",
25
+ "type": "belongsTo",
26
+ "is_primary": False,
27
+ "is_primary_thumbnail": False,
28
+ "metadata": [{"key": "order", "value": 2}],
29
+ "sort": {"order": [{"value": 2}]},
30
+ },
31
+ {"key": "0645e24b-5223-4d91-bae1-2e1226033bef", "type": "hasLicense"},
32
+ {"key": "4efa288e-ffa8-4850-bfc9-f942b63867fa", "type": "hasPhotographer"},
33
+ {
34
+ "key": "d067d0c8-f63c-435e-825d-1e4d2ede63f7",
35
+ "label": "hasChild",
36
+ "type": "hasChild",
37
+ "metadata": [{"key": "order", "value": 4}],
38
+ "sort": {"order": [{"value": 4}]},
39
+ },
40
+ ],
41
+ "file_creation_date": {"$date": "2024-11-28T08:33:47.612Z"},
42
+ "original_filename": "bever.jpg",
43
+ "mimetype": "image/jpeg",
44
+ "date_updated": {"$date": "2024-11-28T08:33:47.612Z"},
45
+ "last_editor": "developers@inuits.eu",
46
+ "img_height": 554,
47
+ "img_width": 711,
48
+ }
49
+
50
+
51
+ mediafile2 = {
52
+ "_id": "abfa72af-43ac-4c40-b969-0561eae4c122",
53
+ "filename": "0494340e99df984a6a3d8dfd15df74a7-transcode-8w3809mt4j-1.jpg",
54
+ "md5sum": "0494340e99df984a6a3d8dfd15df74a7",
55
+ "transcode_file_location": "/download/0494340e99df984a6a3d8dfd15df74a7-transcode-8w3809mt4j-1.jpg",
56
+ "thumbnail_file_location": "/iiif/3/0494340e99df984a6a3d8dfd15df74a7-transcode-8w3809mt4j-1.jpg/full/,150/0/default.jpg",
57
+ "mimetype": "image/jpeg",
58
+ "metadata": [{"key": "copyright_color", "value": "orange"}],
59
+ "identifiers": [
60
+ "abfa72af-43ac-4c40-b969-0561eae4c122",
61
+ "0494340e99df984a6a3d8dfd15df74a7",
62
+ ],
63
+ "type": "mediafile",
64
+ "sort": {"copyright_color": [{"value": "orange"}]},
65
+ "relations": [
66
+ {
67
+ "key": "c4698e82-c2c3-4dda-b7d7-6d8556d34c6e",
68
+ "label": "hasChild",
69
+ "type": "belongsToParent",
70
+ "metadata": [{"key": "order", "value": 4}],
71
+ "sort": {"order": [{"value": 4}]},
72
+ }
73
+ ],
74
+ }
tests/unit/__init__.py ADDED
File without changes
tests/unit/test_csv.py ADDED
@@ -0,0 +1,410 @@
1
+ import pytest
2
+ from elody.exceptions import (
3
+ ColumnNotFoundException,
4
+ InvalidValueException,
5
+ )
6
+ from elody.csv import CSVMultiObject
7
+
8
+
9
+ sample_basic_csv_digipolis = """external_id,external_system,type,file_source,file_identifier,asset_copyright_color,mediafile_copyright_color,photographer,license
10
+ tg:lhaq:8363:m1,arches,asset,file,meeuw.jpg,orange,red,Jos,test
11
+ """
12
+
13
+ sample_basic_csv_digipolis_wrong_values = """external_id,external_system,type,file_source,file_identifier,asset_copyright_color,mediafile_copyright_color,photographer,license
14
+ tg:lhaq:8363:m1,arches,asset,file,meeuw.jpg,orange,red,Jos,test
15
+ tg:lhaq:8364:m2,arches,asset,file,meeuw2.jpg,blue,green,Jane,test
16
+ tg:lhaq:8365:m3,arches,asset,file,meeuw3.jpg,yellow,purple,John,test
17
+ """
18
+
19
+ sample_meemoo_csv_digipolis = """external_id,external_system,type,file_source,file_identifier,asset_copyright_color,mediafile_copyright_color,photographer,license
20
+ tg:lhaq:8569:m1,arches,asset,file,tijger.jpg,green,red,fotograaf,license
21
+ tg:lhaq:8568:m1,arches,asset,meemoo,5717m4t678,green,red,fotograaf,license
22
+ tg:lhaq:8570:m1,arches,asset,meemoo,8w3809mt4j,green,red,fotograaf,license
23
+ """
24
+
25
+ sample_basic_csv_vliz = """same_entity,title,description,coordinates,media_keyword,language,asset_category,location_type,marine_region,event,project,partner,creator_person,owner_partner,type,filename,content_drager,external_link,usage_guidelines,usage_guidelines_until,embargo,qualityRating,mediafile_keyword,mediafile_creator_person,mediafile_owner_partner,confidentiality,mediafile_person
26
+ 1,This is a media entity,This is a description,,keyword1,,,,,,,,person1,partner1,media,leeuw.jpg,,,,,,,keyword,mediaperson,mediapartner,,
27
+ """
28
+
29
+ sample_basic_csv_vliz_missing_values = """title,description,coordinates,media_keyword,language,asset_category,location_type,marine_region,event,project,partner,creator_person,owner_partner,type,filename,content_drager,external_link,usage_guidelines,usage_guidelines_until,embargo,qualityRating,mediafile_keyword,mediafile_creator_person,mediafile_owner_partner,confidentiality,mediafile_person
30
+ This is a media entity,This is a description,,keyword1,,,,,,,,person1,partner1,media,leeuw.jpg,,,,,,,keyword,mediaperson,mediapartner,,
31
+ """
32
+
33
+ sample_multiple_keywords_csv_vliz = """same_entity,title,description,coordinates,media_keyword,language,asset_category,location_type,marine_region,event,project,partner,creator_person,owner_partner,type,filename,content_drager,external_link,usage_guidelines,usage_guidelines_until,embargo,qualityRating,mediafile_keyword,mediafile_creator_person,mediafile_owner_partner,confidentiality,mediafile_person
34
+ 1,This is a media entity,This is a description,,keyword1,,,,,,,,person1,partner1,media,leeuw.jpg,,,,,,,keyword,mediaperson,mediapartner,,
35
+ 1,,,,keyword2,,,,,,,,,,,leeuw.jpg,,,,,,,keyword_mediafile,,,,
36
+ """
37
+
38
+ sample_csv_without_mediafile_digi = """external_id,external_system,type,asset_copyright_color
39
+ tg:lhps:32930:m1,arches,asset,green
40
+ """
41
+
42
+ sample_csv_without_mediafile_vliz = """same_entity,title,description,coordinates,media_keyword,language,asset_category,location_type,marine_region,event,project,partner,creator_person,owner_partner,type
43
+ 1,This is a media entity without a mediafile,This is a description,,keyword1,,,,,,,,person1,partner1,media
44
+ """
45
+
46
+ expected_basic_objects_digipolis = {
47
+ "entities": [
48
+ {
49
+ "matching_id": "tg:lhaq:8363:m1",
50
+ "metadata": [
51
+ {"key": "external_id", "value": "tg:lhaq:8363:m1", "lang": "en"},
52
+ {"key": "external_system", "value": "arches", "lang": "en"},
53
+ {"key": "file_source", "value": "file", "lang": "en"},
54
+ {"key": "copyright_color", "value": "orange", "lang": "en"},
55
+ ],
56
+ "type": "asset",
57
+ }
58
+ ],
59
+ "mediafiles": [
60
+ {
61
+ "matching_id": "tg:lhaq:8363:m1",
62
+ "metadata": [
63
+ {"key": "copyright_color", "value": "red", "lang": "en"},
64
+ {"key": "photographer", "value": "Jos", "lang": "en"},
65
+ ],
66
+ "filename": "meeuw.jpg",
67
+ }
68
+ ],
69
+ }
70
+
71
+ expected_meemoo_objects_digipolis = {
72
+ "entities": [
73
+ {
74
+ "matching_id": "tg:lhaq:8569:m1",
75
+ "metadata": [
76
+ {"key": "external_id", "value": "tg:lhaq:8569:m1", "lang": "en"},
77
+ {"key": "external_system", "value": "arches", "lang": "en"},
78
+ {"key": "file_source", "value": "file", "lang": "en"},
79
+ {"key": "copyright_color", "value": "green", "lang": "en"},
80
+ ],
81
+ "type": "asset",
82
+ },
83
+ {
84
+ "matching_id": "tg:lhaq:8568:m1",
85
+ "metadata": [
86
+ {"key": "external_id", "value": "tg:lhaq:8568:m1", "lang": "en"},
87
+ {"key": "external_system", "value": "arches", "lang": "en"},
88
+ {"key": "file_source", "value": "meemoo", "lang": "en"},
89
+ {"key": "copyright_color", "value": "green", "lang": "en"},
90
+ ],
91
+ "type": "asset",
92
+ "file_identifier": "5717m4t678",
93
+ },
94
+ {
95
+ "matching_id": "tg:lhaq:8570:m1",
96
+ "metadata": [
97
+ {"key": "external_id", "value": "tg:lhaq:8570:m1", "lang": "en"},
98
+ {"key": "external_system", "value": "arches", "lang": "en"},
99
+ {"key": "file_source", "value": "meemoo", "lang": "en"},
100
+ {"key": "copyright_color", "value": "green", "lang": "en"},
101
+ ],
102
+ "type": "asset",
103
+ "file_identifier": "8w3809mt4j",
104
+ },
105
+ ],
106
+ "mediafiles": [
107
+ {
108
+ "matching_id": "tg:lhaq:8569:m1",
109
+ "metadata": [
110
+ {"key": "copyright_color", "value": "red", "lang": "en"},
111
+ {"key": "photographer", "value": "fotograaf", "lang": "en"},
112
+ ],
113
+ "filename": "tijger.jpg",
114
+ },
115
+ {
116
+ "matching_id": "tg:lhaq:8568:m1",
117
+ "metadata": [
118
+ {"key": "copyright_color", "value": "red", "lang": "en"},
119
+ {"key": "photographer", "value": "fotograaf", "lang": "en"},
120
+ ],
121
+ "is_meemoo_mediafile": True,
122
+ "filename": "5717m4t678",
123
+ },
124
+ {
125
+ "matching_id": "tg:lhaq:8570:m1",
126
+ "metadata": [
127
+ {"key": "copyright_color", "value": "red", "lang": "en"},
128
+ {"key": "photographer", "value": "fotograaf", "lang": "en"},
129
+ ],
130
+ "is_meemoo_mediafile": True,
131
+ "filename": "8w3809mt4j",
132
+ },
133
+ ],
134
+ }
135
+
136
+ expected_basic_objects_vliz = {
137
+ "entities": [
138
+ {
139
+ "matching_id": "1",
140
+ "metadata": [
141
+ {"key": "title", "value": "This is a media entity", "lang": ""},
142
+ {"key": "description", "value": "This is a description", "lang": ""},
143
+ {"key": "media_keyword", "value": "keyword1", "lang": ""},
144
+ {"key": "creator_person", "value": "person1", "lang": ""},
145
+ {"key": "owner_partner", "value": "partner1", "lang": ""},
146
+ ],
147
+ "type": "media",
148
+ }
149
+ ],
150
+ "mediafiles": [
151
+ {
152
+ "matching_id": "1",
153
+ "filename": "leeuw.jpg",
154
+ "metadata": [
155
+ {"key": "mediafile_keyword", "value": "keyword", "lang": ""},
156
+ {"key": "mediafile_creator_person", "value": "mediaperson", "lang": ""},
157
+ {"key": "mediafile_owner_partner", "value": "mediapartner", "lang": ""},
158
+ ],
159
+ }
160
+ ],
161
+ }
162
+
163
+ expected_multiple_keywords_objects_vliz = {
164
+ "entities": [
165
+ {
166
+ "matching_id": "1",
167
+ "metadata": [
168
+ {"key": "title", "value": "This is a media entity", "lang": ""},
169
+ {"key": "description", "value": "This is a description", "lang": ""},
170
+ {"key": "media_keyword", "value": "keyword1", "lang": ""},
171
+ {"key": "creator_person", "value": "person1", "lang": ""},
172
+ {"key": "owner_partner", "value": "partner1", "lang": ""},
173
+ {"key": "media_keyword", "value": "keyword2", "lang": ""},
174
+ ],
175
+ "type": "media",
176
+ }
177
+ ],
178
+ "mediafiles": [
179
+ {
180
+ "matching_id": "1",
181
+ "filename": "leeuw.jpg",
182
+ "metadata": [
183
+ {"key": "mediafile_keyword", "value": "keyword", "lang": ""},
184
+ {"key": "mediafile_creator_person", "value": "mediaperson", "lang": ""},
185
+ {"key": "mediafile_owner_partner", "value": "mediapartner", "lang": ""},
186
+ {"key": "mediafile_keyword", "value": "keyword_mediafile", "lang": ""},
187
+ ],
188
+ }
189
+ ],
190
+ }
191
+
192
+ expected_only_entities_object_digipolis = {
193
+ "entities": [
194
+ {
195
+ "matching_id": "tg:lhps:32930:m1",
196
+ "metadata": [
197
+ {"key": "external_id", "value": "tg:lhps:32930:m1", "lang": "en"},
198
+ {"key": "external_system", "value": "arches", "lang": "en"},
199
+ {"key": "copyright_color", "value": "green", "lang": "en"},
200
+ ],
201
+ "type": "asset",
202
+ }
203
+ ]
204
+ }
205
+
206
+ expected_only_entities_object_vliz = {
207
+ "entities": [
208
+ {
209
+ "matching_id": "1",
210
+ "metadata": [
211
+ {
212
+ "key": "title",
213
+ "value": "This is a media entity without a mediafile",
214
+ "lang": "",
215
+ },
216
+ {"key": "description", "value": "This is a description", "lang": ""},
217
+ {"key": "media_keyword", "value": "keyword1", "lang": ""},
218
+ {"key": "creator_person", "value": "person1", "lang": ""},
219
+ {"key": "owner_partner", "value": "partner1", "lang": ""},
220
+ ],
221
+ "type": "media",
222
+ }
223
+ ]
224
+ }
225
+
226
+
227
+ def init_digipolis_csv_object(csv):
228
+ csv_multi_object = CSVMultiObject(
229
+ csv,
230
+ index_mapping={
231
+ "entities": "external_id",
232
+ "?mediafiles": "file_identifier",
233
+ },
234
+ object_field_mapping={
235
+ "mediafiles": [
236
+ "filename",
237
+ "file_identifier",
238
+ "publication_status",
239
+ "mediafile_copyright_color",
240
+ "mediafile_description" "license",
241
+ "photographer",
242
+ "publication_status",
243
+ "back_office",
244
+ "scan",
245
+ "portrait_rights",
246
+ ],
247
+ "entities": [
248
+ "type",
249
+ "asset_copyright_color",
250
+ "asset_description",
251
+ "creator",
252
+ "tag",
253
+ "external_id",
254
+ "external_system",
255
+ "closed_deposit",
256
+ "file_source",
257
+ ],
258
+ },
259
+ required_metadata_values={"mediafiles": {"copyright_color": "red"}},
260
+ metadata_field_mapping={
261
+ "asset_copyright_color": {
262
+ "target": "entities",
263
+ "map_to": "copyright_color",
264
+ "value_options": ["", "automatic", "green", "orange", "red"],
265
+ },
266
+ "mediafile_copyright_color": {
267
+ "target": "mediafiles",
268
+ "map_to": "copyright_color",
269
+ "value_options": ["", "automatic", "green", "orange", "red"],
270
+ },
271
+ "asset_description": {
272
+ "target": "asset",
273
+ "map_to": "description",
274
+ },
275
+ "mediafile_description": {
276
+ "target": "mediafiles",
277
+ "map_to": "description",
278
+ },
279
+ },
280
+ include_indexed_field=True,
281
+ top_level_fields_mapping={"mediafiles": {"file_identifier": "filename"}},
282
+ external_file_sources=["meemoo"],
283
+ )
284
+
285
+ return csv_multi_object
286
+
287
+
288
+ def init_vliz_csv_object(csv):
289
+ csv_multi_object = CSVMultiObject(
290
+ csv,
291
+ index_mapping={"entities": "same_entity", "?mediafiles": "filename"},
292
+ object_field_mapping={
293
+ "mediafiles": [
294
+ "filename",
295
+ "content_drager",
296
+ "external_link",
297
+ "usage_guidelines",
298
+ "usage_guidelines_until",
299
+ "embargo",
300
+ "qualityRating",
301
+ "mediafile_keyword",
302
+ "confidentiality",
303
+ "subtitle",
304
+ "mediafile_person",
305
+ "mediafile_owner_person",
306
+ "mediafile_owner_partner",
307
+ "mediafile_creator_person",
308
+ "mediafile_creator_partner",
309
+ ],
310
+ "entities": [
311
+ "type",
312
+ "title",
313
+ "description",
314
+ "coordinates",
315
+ "media_keyword",
316
+ "map_keyword",
317
+ "publication_keyword",
318
+ "language",
319
+ "asset_category",
320
+ "location_type",
321
+ "marine_region",
322
+ "event",
323
+ "project",
324
+ "partner",
325
+ "content_map_type",
326
+ "formal_map_type",
327
+ "date_of_publication",
328
+ "date_of_last_revision",
329
+ "content_date",
330
+ "spatialCoverage",
331
+ "projection",
332
+ "minLocation",
333
+ "maxLocation",
334
+ "formal_document_type",
335
+ "content_document_type",
336
+ "owner_person",
337
+ "owner_partner",
338
+ "creator_person",
339
+ "creator_partner",
340
+ ],
341
+ },
342
+ required_metadata_values={},
343
+ metadata_field_mapping={
344
+ "map_owner": {
345
+ "target": "entities",
346
+ "map_to": "owner",
347
+ },
348
+ "map_creator": {
349
+ "target": "entities",
350
+ "map_to": "creator",
351
+ },
352
+ "mediafile_owner": {
353
+ "target": "mediafiles",
354
+ "map_to": "owner",
355
+ },
356
+ "mediafile_creator": {
357
+ "target": "mediafiles",
358
+ "map_to": "creator",
359
+ },
360
+ "mediafile_person": {
361
+ "target": "mediafiles",
362
+ "map_to": "person",
363
+ },
364
+ },
365
+ include_indexed_field=False,
366
+ )
367
+
368
+ return csv_multi_object
369
+
370
+
371
+ # Test CSVMultiObject DIGIPOLIS
372
+ def test_basic_csv_digipolis():
373
+ csv_multi_object = init_digipolis_csv_object(sample_basic_csv_digipolis)
374
+ assert csv_multi_object.objects == expected_basic_objects_digipolis
375
+
376
+
377
+ def test_basic_csv_digipolis_with_wrong_values():
378
+ with pytest.raises(InvalidValueException):
379
+ init_digipolis_csv_object(sample_basic_csv_digipolis_wrong_values)
380
+
381
+
382
+ def test_meemoo_csv_digipolis():
383
+ csv_multi_object = init_digipolis_csv_object(sample_meemoo_csv_digipolis)
384
+ assert csv_multi_object.objects == expected_meemoo_objects_digipolis
385
+
386
+
387
+ def test_csv_with_only_an_entity_digipolis():
388
+ csv_multi_object = init_digipolis_csv_object(sample_csv_without_mediafile_digi)
389
+ assert csv_multi_object.objects == expected_only_entities_object_digipolis
390
+
391
+
392
+ # Tests CSVMultiObject VLIZ
393
+ def test_basic_csv_vliz():
394
+ csv_multi_object = init_vliz_csv_object(sample_basic_csv_vliz)
395
+ assert csv_multi_object.objects == expected_basic_objects_vliz
396
+
397
+
398
+ def test_basic_csv_digipolis_with_wrong_values():
399
+ with pytest.raises(ColumnNotFoundException):
400
+ init_vliz_csv_object(sample_basic_csv_vliz_missing_values)
401
+
402
+
403
+ def test_multiple_keywords_csv_vliz():
404
+ csv_multi_object = init_vliz_csv_object(sample_multiple_keywords_csv_vliz)
405
+ assert csv_multi_object.objects == expected_multiple_keywords_objects_vliz
406
+
407
+
408
+ def test_csv_with_only_an_entity_vliz():
409
+ csv_multi_object = init_vliz_csv_object(sample_csv_without_mediafile_vliz)
410
+ assert csv_multi_object.objects == expected_only_entities_object_vliz