1
- # 2788738 -> user with orcid
1
+ # 2788738 -> user with orcid # TODO
2
2
# 2684743 -> many fields
3
3
# 2889522 -> multiple file versions
4
4
# 2051872 -> multiple version with custom fields
5
5
# 2207587 -> multiple custom fields
6
- # 2783103 -> file missing # TODO
7
- # 2783104 -> file restricted # TODO
8
- # 2046076 -> irregular experiment field value # TODO
9
- # 1597985 -> contains ALEPH identifier # TODO
10
- # 2041388 -> custom affiliation # TODO
11
- # 2779426 -> clump of keywords # TODO
12
- # 2294138 -> author with inspire id # TODO
6
+ # 2783103 -> file missing
7
+ # 2783104 -> file restricted
8
+ # 2046076 -> irregular experiment field value
9
+ # 1597985 -> contains ALEPH identifier
10
+ # 2041388 -> custom affiliation
11
+ # 2779426 -> clump of keywords
12
+ # 2294138 -> author with inspire id
13
13
import json
14
14
from pathlib import Path
15
15
24
24
25
25
26
26
def suite_multi_field (record ):
27
+ """2684743."""
27
28
dict_rec = record .to_dict ()
28
29
assert dict_rec ["created" ] == "2019-07-29T00:00:00+00:00"
29
30
assert dict_rec ["versions" ]["index" ] == 1
@@ -122,8 +123,9 @@ def suite_multi_field(record):
122
123
123
124
124
125
def orcid_id (record ):
125
- dict_rec = record . to_dict ()
126
+ """2788738."""
126
127
# TODO pre-create user with orcid
128
+ dict_rec = record .to_dict ()
127
129
assert dict_rec ["metadata" ]["creators" ] == [
128
130
{
129
131
"person_or_org" : {
@@ -138,11 +140,13 @@ def orcid_id(record):
138
140
139
141
140
142
def multiple_versions (record , record_state ):
143
+ """2889522."""
141
144
dict_rec = record .to_dict ()
142
145
assert dict_rec ["versions" ]["index" ] == 2
143
146
144
147
145
148
def multiple_versions_with_cs (record ):
149
+ """2051872."""
146
150
dict_rec = record .to_dict ()
147
151
assert dict_rec ["versions" ]["index" ] == 2
148
152
assert dict_rec ["custom_fields" ] == {
@@ -151,6 +155,126 @@ def multiple_versions_with_cs(record):
151
155
}
152
156
153
157
158
+ def multiple_custom_fields (record ):
159
+ """2207587."""
160
+ dict_rec = record .to_dict ()
161
+ assert "custom_fields" in dict_rec
162
+ assert dict_rec ["custom_fields" ] == {
163
+ "cern:accelerators" : [
164
+ {"id" : "CERN AD" , "title" : {"en" : "CERN AD" }},
165
+ {"id" : "CERN AD" , "title" : {"en" : "CERN AD" }},
166
+ ],
167
+ }
168
+
169
+
170
+ def file_missing (record ):
171
+ """2783103."""
172
+ dict_rec = record .to_dict ()
173
+ assert "files" in dict_rec
174
+ assert dict_rec ["files" ]["enabled" ] == False
175
+ assert dict_rec ["files" ]["count" ] == 0
176
+ assert "media_files" in dict_rec
177
+ assert dict_rec ["media_files" ]["enabled" ] == False
178
+ assert dict_rec ["media_files" ]["count" ] == 0
179
+
180
+
181
+ def file_restricted (record ):
182
+ """2783104."""
183
+ dict_rec = record .to_dict ()
184
+ assert "access" in dict_rec
185
+ assert dict_rec ["access" ]["record" ] == "public"
186
+ assert dict_rec ["access" ]["files" ] == "restricted"
187
+ assert "files" in dict_rec
188
+ assert dict_rec ["files" ]["enabled" ] == True
189
+ assert dict_rec ["files" ]["count" ] == 1
190
+
191
+
192
+ def irregular_exp_field (record ):
193
+ """2046076."""
194
+ dict_rec = record .to_dict ()
195
+ assert "custom_fields" in dict_rec
196
+ assert dict_rec ["custom_fields" ] == {
197
+ "cern:accelerators" : [
198
+ {"id" : "CERN AD" , "title" : {"en" : "CERN AD" }},
199
+ ],
200
+ }
201
+ assert "subjects" in dict_rec ["metadata" ]
202
+ assert dict_rec ["metadata" ]["subjects" ] == [
203
+ {
204
+ "id" : "Computing and Computers" ,
205
+ "subject" : "Computing and Computers" ,
206
+ "scheme" : "CERN" ,
207
+ },
208
+ {"subject" : "COMPASS" },
209
+ {"subject" : "DAQ" },
210
+ {"subject" : "FPGA" },
211
+ {"subject" : "GUI" },
212
+ {"subject" : "COMPASS NA58" },
213
+ ]
214
+
215
+
216
+ def custom_affiliation (record ):
217
+ """2041388."""
218
+ dict_rec = record .to_dict ()
219
+ for creator in dict_rec ["metadata" ]["creators" ]:
220
+ assert "affiliations" in creator
221
+ for affiliation in creator ["affiliations" ]:
222
+ assert "ror" != affiliation .get ("scheme" , None )
223
+
224
+
225
+ def contains_aleph (record ):
226
+ """1597985."""
227
+ dict_rec = record .to_dict ()
228
+ assert "identifiers" in dict_rec ["metadata" ]
229
+ assert dict_rec ["metadata" ]["identifiers" ] == [
230
+ {"identifier" : "CERN-STUDENTS-Note-2013-181" , "scheme" : "cds_ref" },
231
+ {"identifier" : "000733613CER" , "scheme" : "aleph" },
232
+ ]
233
+
234
+
235
+ def contains_keywords (record ):
236
+ """2779426."""
237
+ dict_rec = record .to_dict ()
238
+ assert "subjects" in dict_rec ["metadata" ]
239
+ assert dict_rec ["metadata" ]["subjects" ] == [
240
+ {
241
+ "id" : "Detectors and Experimental Techniques" ,
242
+ "subject" : "Detectors and Experimental Techniques" ,
243
+ "scheme" : "CERN" ,
244
+ },
245
+ {
246
+ "subject" : "Gaseous detectors, Drift tubes, CSC, MSGC, Microdot chambers, Micromegas, Micropattern, GEM, TPC, RPC, TGC, RICH, electron avalanche, Garfield++, Magboltz"
247
+ },
248
+ ]
249
+
250
+
251
+ def author_with_inspire (record ):
252
+ """2294138."""
253
+ dict_rec = record .to_dict ()
254
+ assert "contributors" in dict_rec ["metadata" ]
255
+ assert dict_rec ["metadata" ]["contributors" ] == [
256
+ {
257
+ "person_or_org" : {
258
+ "type" : "personal" ,
259
+ "name" : "Glatzer, Julian" ,
260
+ "given_name" : "Julian" ,
261
+ "family_name" : "Glatzer" ,
262
+ "identifiers" : [
263
+ {"identifier" : "INSPIRE-00013837" , "scheme" : "inspire" },
264
+ {"identifier" : "2073275" , "scheme" : "lcds" },
265
+ ],
266
+ },
267
+ "role" : {
268
+ "id" : "other" ,
269
+ "title" : {"en" : "Other" },
270
+ },
271
+ "affiliations" : [
272
+ {"name" : "Universitat Autonoma de Barcelona ES" },
273
+ ],
274
+ },
275
+ ]
276
+
277
+
154
278
def test_full_migration_stream (
155
279
test_app ,
156
280
minimal_restricted_record ,
@@ -211,3 +335,19 @@ def test_full_migration_stream(
211
335
multiple_versions (loaded_rec , record )
212
336
if record ["legacy_recid" ] == "2051872" :
213
337
multiple_versions_with_cs (loaded_rec )
338
+ if record ["legacy_recid" ] == "2207587" :
339
+ multiple_custom_fields (loaded_rec )
340
+ if record ["legacy_recid" ] == "2783103" :
341
+ file_missing (loaded_rec )
342
+ if record ["legacy_recid" ] == "2783104" :
343
+ file_restricted (loaded_rec )
344
+ if record ["legacy_recid" ] == "2046076" :
345
+ irregular_exp_field (loaded_rec )
346
+ if record ["legacy_recid" ] == "2041388" :
347
+ custom_affiliation (loaded_rec )
348
+ if record ["legacy_recid" ] == "1597985" :
349
+ contains_aleph (loaded_rec )
350
+ if record ["legacy_recid" ] == "2779426" :
351
+ contains_keywords (loaded_rec )
352
+ if record ["legacy_recid" ] == "2294138" :
353
+ author_with_inspire (loaded_rec )
0 commit comments