arkindex-base-worker 0.3.6rc1__py3-none-any.whl → 0.3.6rc2__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.
- arkindex_base_worker-0.3.6rc2.dist-info/METADATA +39 -0
- arkindex_base_worker-0.3.6rc2.dist-info/RECORD +40 -0
- arkindex_worker/__init__.py +0 -1
- arkindex_worker/cache.py +19 -25
- arkindex_worker/image.py +16 -17
- arkindex_worker/models.py +17 -21
- arkindex_worker/utils.py +16 -17
- arkindex_worker/worker/__init__.py +14 -23
- arkindex_worker/worker/base.py +12 -7
- arkindex_worker/worker/classification.py +13 -15
- arkindex_worker/worker/dataset.py +3 -4
- arkindex_worker/worker/element.py +80 -75
- arkindex_worker/worker/entity.py +27 -29
- arkindex_worker/worker/metadata.py +19 -25
- arkindex_worker/worker/task.py +2 -3
- arkindex_worker/worker/training.py +21 -22
- arkindex_worker/worker/transcription.py +37 -34
- arkindex_worker/worker/version.py +1 -2
- tests/conftest.py +55 -75
- tests/test_base_worker.py +37 -31
- tests/test_cache.py +14 -7
- tests/test_dataset_worker.py +4 -4
- tests/test_element.py +0 -1
- tests/test_elements_worker/__init__.py +0 -1
- tests/test_elements_worker/test_classifications.py +0 -1
- tests/test_elements_worker/test_cli.py +22 -17
- tests/test_elements_worker/test_dataset.py +9 -10
- tests/test_elements_worker/test_elements.py +58 -63
- tests/test_elements_worker/test_entities.py +10 -20
- tests/test_elements_worker/test_metadata.py +72 -96
- tests/test_elements_worker/test_task.py +9 -10
- tests/test_elements_worker/test_training.py +20 -13
- tests/test_elements_worker/test_transcriptions.py +6 -10
- tests/test_elements_worker/test_worker.py +16 -14
- tests/test_image.py +21 -20
- tests/test_merge.py +5 -6
- tests/test_utils.py +0 -1
- arkindex_base_worker-0.3.6rc1.dist-info/METADATA +0 -27
- arkindex_base_worker-0.3.6rc1.dist-info/RECORD +0 -42
- arkindex_worker/git.py +0 -392
- tests/test_git.py +0 -480
- {arkindex_base_worker-0.3.6rc1.dist-info → arkindex_base_worker-0.3.6rc2.dist-info}/WHEEL +0 -0
- {arkindex_base_worker-0.3.6rc1.dist-info → arkindex_base_worker-0.3.6rc2.dist-info}/top_level.txt +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
import json
|
|
3
|
-
import os
|
|
4
2
|
import sys
|
|
5
3
|
import tempfile
|
|
4
|
+
from pathlib import Path
|
|
6
5
|
from uuid import UUID
|
|
7
6
|
|
|
8
7
|
import pytest
|
|
@@ -10,49 +9,53 @@ import pytest
|
|
|
10
9
|
from arkindex_worker.worker import ElementsWorker
|
|
11
10
|
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
@pytest.mark.usefixtures("_mock_worker_run_api")
|
|
13
|
+
def test_cli_default(monkeypatch):
|
|
14
14
|
_, path = tempfile.mkstemp()
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
path = Path(path)
|
|
16
|
+
path.write_text(
|
|
17
|
+
json.dumps(
|
|
17
18
|
[
|
|
18
19
|
{"id": "volumeid", "type": "volume"},
|
|
19
20
|
{"id": "pageid", "type": "page"},
|
|
20
21
|
{"id": "actid", "type": "act"},
|
|
21
22
|
{"id": "surfaceid", "type": "surface"},
|
|
22
23
|
],
|
|
23
|
-
f,
|
|
24
24
|
)
|
|
25
|
+
)
|
|
25
26
|
|
|
26
27
|
monkeypatch.setenv("TASK_ELEMENTS", path)
|
|
27
28
|
monkeypatch.setattr(sys, "argv", ["worker"])
|
|
28
29
|
worker = ElementsWorker()
|
|
29
30
|
worker.configure()
|
|
30
31
|
|
|
31
|
-
assert worker.args.elements_list.name == path
|
|
32
|
+
assert worker.args.elements_list.name == str(path)
|
|
32
33
|
assert not worker.args.element
|
|
33
|
-
|
|
34
|
+
path.unlink()
|
|
34
35
|
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
@pytest.mark.usefixtures("_mock_worker_run_api")
|
|
38
|
+
def test_cli_arg_elements_list_given(mocker):
|
|
37
39
|
_, path = tempfile.mkstemp()
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
path = Path(path)
|
|
41
|
+
path.write_text(
|
|
42
|
+
json.dumps(
|
|
40
43
|
[
|
|
41
44
|
{"id": "volumeid", "type": "volume"},
|
|
42
45
|
{"id": "pageid", "type": "page"},
|
|
43
46
|
{"id": "actid", "type": "act"},
|
|
44
47
|
{"id": "surfaceid", "type": "surface"},
|
|
45
48
|
],
|
|
46
|
-
f,
|
|
47
49
|
)
|
|
50
|
+
)
|
|
48
51
|
|
|
49
|
-
mocker.patch.object(sys, "argv", ["worker", "--elements-list", path])
|
|
52
|
+
mocker.patch.object(sys, "argv", ["worker", "--elements-list", str(path)])
|
|
50
53
|
worker = ElementsWorker()
|
|
51
54
|
worker.configure()
|
|
52
55
|
|
|
53
|
-
assert worker.args.elements_list.name == path
|
|
56
|
+
assert worker.args.elements_list.name == str(path)
|
|
54
57
|
assert not worker.args.element
|
|
55
|
-
|
|
58
|
+
path.unlink()
|
|
56
59
|
|
|
57
60
|
|
|
58
61
|
def test_cli_arg_element_one_given_not_uuid(mocker):
|
|
@@ -62,7 +65,8 @@ def test_cli_arg_element_one_given_not_uuid(mocker):
|
|
|
62
65
|
worker.configure()
|
|
63
66
|
|
|
64
67
|
|
|
65
|
-
|
|
68
|
+
@pytest.mark.usefixtures("_mock_worker_run_api")
|
|
69
|
+
def test_cli_arg_element_one_given(mocker):
|
|
66
70
|
mocker.patch.object(
|
|
67
71
|
sys, "argv", ["worker", "--element", "12341234-1234-1234-1234-123412341234"]
|
|
68
72
|
)
|
|
@@ -74,7 +78,8 @@ def test_cli_arg_element_one_given(mocker, mock_worker_run_api):
|
|
|
74
78
|
assert not worker.args.elements_list
|
|
75
79
|
|
|
76
80
|
|
|
77
|
-
|
|
81
|
+
@pytest.mark.usefixtures("_mock_worker_run_api")
|
|
82
|
+
def test_cli_arg_element_many_given(mocker):
|
|
78
83
|
mocker.patch.object(
|
|
79
84
|
sys,
|
|
80
85
|
"argv",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
import json
|
|
3
2
|
import logging
|
|
4
3
|
|
|
@@ -107,8 +106,8 @@ def test_list_process_datasets(
|
|
|
107
106
|
|
|
108
107
|
|
|
109
108
|
@pytest.mark.parametrize(
|
|
110
|
-
"payload, error",
|
|
111
|
-
|
|
109
|
+
("payload", "error"),
|
|
110
|
+
[
|
|
112
111
|
# Dataset
|
|
113
112
|
(
|
|
114
113
|
{"dataset": None},
|
|
@@ -118,7 +117,7 @@ def test_list_process_datasets(
|
|
|
118
117
|
{"dataset": "not Dataset type"},
|
|
119
118
|
"dataset shouldn't be null and should be a Dataset",
|
|
120
119
|
),
|
|
121
|
-
|
|
120
|
+
],
|
|
122
121
|
)
|
|
123
122
|
def test_list_dataset_elements_wrong_param_dataset(mock_dataset_worker, payload, error):
|
|
124
123
|
with pytest.raises(AssertionError, match=error):
|
|
@@ -265,8 +264,8 @@ def test_list_dataset_elements(
|
|
|
265
264
|
|
|
266
265
|
|
|
267
266
|
@pytest.mark.parametrize(
|
|
268
|
-
"payload, error",
|
|
269
|
-
|
|
267
|
+
("payload", "error"),
|
|
268
|
+
[
|
|
270
269
|
# Dataset
|
|
271
270
|
(
|
|
272
271
|
{"dataset": None},
|
|
@@ -276,7 +275,7 @@ def test_list_dataset_elements(
|
|
|
276
275
|
{"dataset": "not dataset type"},
|
|
277
276
|
"dataset shouldn't be null and should be a Dataset",
|
|
278
277
|
),
|
|
279
|
-
|
|
278
|
+
],
|
|
280
279
|
)
|
|
281
280
|
def test_update_dataset_state_wrong_param_dataset(
|
|
282
281
|
mock_dataset_worker, default_dataset, payload, error
|
|
@@ -292,8 +291,8 @@ def test_update_dataset_state_wrong_param_dataset(
|
|
|
292
291
|
|
|
293
292
|
|
|
294
293
|
@pytest.mark.parametrize(
|
|
295
|
-
"payload, error",
|
|
296
|
-
|
|
294
|
+
("payload", "error"),
|
|
295
|
+
[
|
|
297
296
|
# DatasetState
|
|
298
297
|
(
|
|
299
298
|
{"state": None},
|
|
@@ -303,7 +302,7 @@ def test_update_dataset_state_wrong_param_dataset(
|
|
|
303
302
|
{"state": "not dataset type"},
|
|
304
303
|
"state shouldn't be null and should be a str from DatasetState",
|
|
305
304
|
),
|
|
306
|
-
|
|
305
|
+
],
|
|
307
306
|
)
|
|
308
307
|
def test_update_dataset_state_wrong_param_state(
|
|
309
308
|
mock_dataset_worker, default_dataset, payload, error
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
import json
|
|
3
2
|
import re
|
|
4
3
|
from argparse import Namespace
|
|
@@ -1219,8 +1218,8 @@ def test_create_elements_integrity_error(
|
|
|
1219
1218
|
|
|
1220
1219
|
|
|
1221
1220
|
@pytest.mark.parametrize(
|
|
1222
|
-
"payload, error",
|
|
1223
|
-
|
|
1221
|
+
("payload", "error"),
|
|
1222
|
+
[
|
|
1224
1223
|
# Element
|
|
1225
1224
|
(
|
|
1226
1225
|
{"element": None},
|
|
@@ -1230,7 +1229,7 @@ def test_create_elements_integrity_error(
|
|
|
1230
1229
|
{"element": "not element type"},
|
|
1231
1230
|
"element shouldn't be null and should be an Element or CachedElement",
|
|
1232
1231
|
),
|
|
1233
|
-
|
|
1232
|
+
],
|
|
1234
1233
|
)
|
|
1235
1234
|
def test_partial_update_element_wrong_param_element(
|
|
1236
1235
|
mock_elements_worker, payload, error
|
|
@@ -1247,12 +1246,12 @@ def test_partial_update_element_wrong_param_element(
|
|
|
1247
1246
|
|
|
1248
1247
|
|
|
1249
1248
|
@pytest.mark.parametrize(
|
|
1250
|
-
"payload, error",
|
|
1251
|
-
|
|
1249
|
+
("payload", "error"),
|
|
1250
|
+
[
|
|
1252
1251
|
# Type
|
|
1253
1252
|
({"type": 1234}, "type should be a str"),
|
|
1254
1253
|
({"type": None}, "type should be a str"),
|
|
1255
|
-
|
|
1254
|
+
],
|
|
1256
1255
|
)
|
|
1257
1256
|
def test_partial_update_element_wrong_param_type(mock_elements_worker, payload, error):
|
|
1258
1257
|
api_payload = {
|
|
@@ -1267,12 +1266,12 @@ def test_partial_update_element_wrong_param_type(mock_elements_worker, payload,
|
|
|
1267
1266
|
|
|
1268
1267
|
|
|
1269
1268
|
@pytest.mark.parametrize(
|
|
1270
|
-
"payload, error",
|
|
1271
|
-
|
|
1269
|
+
("payload", "error"),
|
|
1270
|
+
[
|
|
1272
1271
|
# Name
|
|
1273
1272
|
({"name": 1234}, "name should be a str"),
|
|
1274
1273
|
({"name": None}, "name should be a str"),
|
|
1275
|
-
|
|
1274
|
+
],
|
|
1276
1275
|
)
|
|
1277
1276
|
def test_partial_update_element_wrong_param_name(mock_elements_worker, payload, error):
|
|
1278
1277
|
api_payload = {
|
|
@@ -1287,8 +1286,8 @@ def test_partial_update_element_wrong_param_name(mock_elements_worker, payload,
|
|
|
1287
1286
|
|
|
1288
1287
|
|
|
1289
1288
|
@pytest.mark.parametrize(
|
|
1290
|
-
"payload, error",
|
|
1291
|
-
|
|
1289
|
+
("payload", "error"),
|
|
1290
|
+
[
|
|
1292
1291
|
# Polygon
|
|
1293
1292
|
({"polygon": "not a polygon"}, "polygon should be a list"),
|
|
1294
1293
|
({"polygon": None}, "polygon should be a list"),
|
|
@@ -1305,7 +1304,7 @@ def test_partial_update_element_wrong_param_name(mock_elements_worker, payload,
|
|
|
1305
1304
|
{"polygon": [["not a coord", 1], [2, 2], [2, 1], [1, 2]]},
|
|
1306
1305
|
"polygon points should be lists of two numbers",
|
|
1307
1306
|
),
|
|
1308
|
-
|
|
1307
|
+
],
|
|
1309
1308
|
)
|
|
1310
1309
|
def test_partial_update_element_wrong_param_polygon(
|
|
1311
1310
|
mock_elements_worker, payload, error
|
|
@@ -1322,8 +1321,8 @@ def test_partial_update_element_wrong_param_polygon(
|
|
|
1322
1321
|
|
|
1323
1322
|
|
|
1324
1323
|
@pytest.mark.parametrize(
|
|
1325
|
-
"payload, error",
|
|
1326
|
-
|
|
1324
|
+
("payload", "error"),
|
|
1325
|
+
[
|
|
1327
1326
|
# Confidence
|
|
1328
1327
|
({"confidence": "lol"}, "confidence should be None or a float in [0..1] range"),
|
|
1329
1328
|
({"confidence": "0.2"}, "confidence should be None or a float in [0..1] range"),
|
|
@@ -1333,7 +1332,7 @@ def test_partial_update_element_wrong_param_polygon(
|
|
|
1333
1332
|
{"confidence": float("inf")},
|
|
1334
1333
|
"confidence should be None or a float in [0..1] range",
|
|
1335
1334
|
),
|
|
1336
|
-
|
|
1335
|
+
],
|
|
1337
1336
|
)
|
|
1338
1337
|
def test_partial_update_element_wrong_param_conf(mock_elements_worker, payload, error):
|
|
1339
1338
|
api_payload = {
|
|
@@ -1348,14 +1347,14 @@ def test_partial_update_element_wrong_param_conf(mock_elements_worker, payload,
|
|
|
1348
1347
|
|
|
1349
1348
|
|
|
1350
1349
|
@pytest.mark.parametrize(
|
|
1351
|
-
"payload, error",
|
|
1352
|
-
|
|
1350
|
+
("payload", "error"),
|
|
1351
|
+
[
|
|
1353
1352
|
# Rotation angle
|
|
1354
1353
|
({"rotation_angle": "lol"}, "rotation_angle should be a positive integer"),
|
|
1355
1354
|
({"rotation_angle": -1}, "rotation_angle should be a positive integer"),
|
|
1356
1355
|
({"rotation_angle": 0.5}, "rotation_angle should be a positive integer"),
|
|
1357
1356
|
({"rotation_angle": None}, "rotation_angle should be a positive integer"),
|
|
1358
|
-
|
|
1357
|
+
],
|
|
1359
1358
|
)
|
|
1360
1359
|
def test_partial_update_element_wrong_param_rota(mock_elements_worker, payload, error):
|
|
1361
1360
|
api_payload = {
|
|
@@ -1370,13 +1369,13 @@ def test_partial_update_element_wrong_param_rota(mock_elements_worker, payload,
|
|
|
1370
1369
|
|
|
1371
1370
|
|
|
1372
1371
|
@pytest.mark.parametrize(
|
|
1373
|
-
"payload, error",
|
|
1374
|
-
|
|
1372
|
+
("payload", "error"),
|
|
1373
|
+
[
|
|
1375
1374
|
# Mirrored
|
|
1376
1375
|
({"mirrored": "lol"}, "mirrored should be a boolean"),
|
|
1377
1376
|
({"mirrored": 1234}, "mirrored should be a boolean"),
|
|
1378
1377
|
({"mirrored": None}, "mirrored should be a boolean"),
|
|
1379
|
-
|
|
1378
|
+
],
|
|
1380
1379
|
)
|
|
1381
1380
|
def test_partial_update_element_wrong_param_mir(mock_elements_worker, payload, error):
|
|
1382
1381
|
api_payload = {
|
|
@@ -1391,13 +1390,13 @@ def test_partial_update_element_wrong_param_mir(mock_elements_worker, payload, e
|
|
|
1391
1390
|
|
|
1392
1391
|
|
|
1393
1392
|
@pytest.mark.parametrize(
|
|
1394
|
-
"payload, error",
|
|
1395
|
-
|
|
1393
|
+
("payload", "error"),
|
|
1394
|
+
[
|
|
1396
1395
|
# Image
|
|
1397
1396
|
({"image": "lol"}, "image should be a UUID"),
|
|
1398
1397
|
({"image": 1234}, "image should be a UUID"),
|
|
1399
1398
|
({"image": None}, "image should be a UUID"),
|
|
1400
|
-
|
|
1399
|
+
],
|
|
1401
1400
|
)
|
|
1402
1401
|
def test_partial_update_element_wrong_param_image(mock_elements_worker, payload, error):
|
|
1403
1402
|
api_payload = {
|
|
@@ -1440,9 +1439,10 @@ def test_partial_update_element_api_error(responses, mock_elements_worker):
|
|
|
1440
1439
|
]
|
|
1441
1440
|
|
|
1442
1441
|
|
|
1442
|
+
@pytest.mark.usefixtures("_mock_cached_elements", "_mock_cached_images")
|
|
1443
1443
|
@pytest.mark.parametrize(
|
|
1444
1444
|
"payload",
|
|
1445
|
-
|
|
1445
|
+
[
|
|
1446
1446
|
(
|
|
1447
1447
|
{
|
|
1448
1448
|
"polygon": [[10, 10], [20, 20], [20, 10], [10, 20]],
|
|
@@ -1463,15 +1463,9 @@ def test_partial_update_element_api_error(responses, mock_elements_worker):
|
|
|
1463
1463
|
"mirrored": False,
|
|
1464
1464
|
}
|
|
1465
1465
|
),
|
|
1466
|
-
|
|
1466
|
+
],
|
|
1467
1467
|
)
|
|
1468
|
-
def test_partial_update_element(
|
|
1469
|
-
responses,
|
|
1470
|
-
mock_elements_worker_with_cache,
|
|
1471
|
-
mock_cached_elements,
|
|
1472
|
-
mock_cached_images,
|
|
1473
|
-
payload,
|
|
1474
|
-
):
|
|
1468
|
+
def test_partial_update_element(responses, mock_elements_worker_with_cache, payload):
|
|
1475
1469
|
elt = CachedElement.select().first()
|
|
1476
1470
|
new_image = CachedImage.select().first()
|
|
1477
1471
|
|
|
@@ -1516,9 +1510,10 @@ def test_partial_update_element(
|
|
|
1516
1510
|
assert getattr(cached_element, param) == elt_response[param]
|
|
1517
1511
|
|
|
1518
1512
|
|
|
1519
|
-
@pytest.mark.
|
|
1513
|
+
@pytest.mark.usefixtures("_mock_cached_elements")
|
|
1514
|
+
@pytest.mark.parametrize("confidence", [None, 0.42])
|
|
1520
1515
|
def test_partial_update_element_confidence(
|
|
1521
|
-
responses, mock_elements_worker_with_cache,
|
|
1516
|
+
responses, mock_elements_worker_with_cache, confidence
|
|
1522
1517
|
):
|
|
1523
1518
|
elt = CachedElement.select().first()
|
|
1524
1519
|
elt_response = {
|
|
@@ -1661,13 +1656,13 @@ def test_list_element_children_wrong_with_metadata(mock_elements_worker):
|
|
|
1661
1656
|
|
|
1662
1657
|
|
|
1663
1658
|
@pytest.mark.parametrize(
|
|
1664
|
-
"param, value",
|
|
1665
|
-
|
|
1659
|
+
("param", "value"),
|
|
1660
|
+
[
|
|
1666
1661
|
("worker_version", 1234),
|
|
1667
1662
|
("worker_run", 1234),
|
|
1668
1663
|
("transcription_worker_version", 1234),
|
|
1669
1664
|
("transcription_worker_run", 1234),
|
|
1670
|
-
|
|
1665
|
+
],
|
|
1671
1666
|
)
|
|
1672
1667
|
def test_list_element_children_wrong_worker_version(mock_elements_worker, param, value):
|
|
1673
1668
|
elt = Element({"id": "12341234-1234-1234-1234-123412341234"})
|
|
@@ -1681,12 +1676,12 @@ def test_list_element_children_wrong_worker_version(mock_elements_worker, param,
|
|
|
1681
1676
|
|
|
1682
1677
|
@pytest.mark.parametrize(
|
|
1683
1678
|
"param",
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1679
|
+
[
|
|
1680
|
+
"worker_version",
|
|
1681
|
+
"worker_run",
|
|
1682
|
+
"transcription_worker_version",
|
|
1683
|
+
"transcription_worker_run",
|
|
1684
|
+
],
|
|
1690
1685
|
)
|
|
1691
1686
|
def test_list_element_children_wrong_bool_worker_version(mock_elements_worker, param):
|
|
1692
1687
|
elt = Element({"id": "12341234-1234-1234-1234-123412341234"})
|
|
@@ -1908,9 +1903,10 @@ def test_list_element_children_with_cache_unhandled_param(
|
|
|
1908
1903
|
)
|
|
1909
1904
|
|
|
1910
1905
|
|
|
1906
|
+
@pytest.mark.usefixtures("_mock_cached_elements")
|
|
1911
1907
|
@pytest.mark.parametrize(
|
|
1912
|
-
"filters, expected_ids",
|
|
1913
|
-
|
|
1908
|
+
("filters", "expected_ids"),
|
|
1909
|
+
[
|
|
1914
1910
|
# Filter on element should give all elements inserted
|
|
1915
1911
|
(
|
|
1916
1912
|
{
|
|
@@ -1977,12 +1973,11 @@ def test_list_element_children_with_cache_unhandled_param(
|
|
|
1977
1973
|
"33333333-3333-3333-3333-333333333333",
|
|
1978
1974
|
),
|
|
1979
1975
|
),
|
|
1980
|
-
|
|
1976
|
+
],
|
|
1981
1977
|
)
|
|
1982
1978
|
def test_list_element_children_with_cache(
|
|
1983
1979
|
responses,
|
|
1984
1980
|
mock_elements_worker_with_cache,
|
|
1985
|
-
mock_cached_elements,
|
|
1986
1981
|
filters,
|
|
1987
1982
|
expected_ids,
|
|
1988
1983
|
):
|
|
@@ -1992,7 +1987,7 @@ def test_list_element_children_with_cache(
|
|
|
1992
1987
|
# Query database through cache
|
|
1993
1988
|
elements = mock_elements_worker_with_cache.list_element_children(**filters)
|
|
1994
1989
|
assert elements.count() == len(expected_ids)
|
|
1995
|
-
for child, expected_id in zip(elements.order_by("id"), expected_ids):
|
|
1990
|
+
for child, expected_id in zip(elements.order_by("id"), expected_ids, strict=True):
|
|
1996
1991
|
assert child.id == UUID(expected_id)
|
|
1997
1992
|
|
|
1998
1993
|
# Check the worker never hits the API for elements
|
|
@@ -2109,13 +2104,13 @@ def test_list_element_parents_wrong_with_metadata(mock_elements_worker):
|
|
|
2109
2104
|
|
|
2110
2105
|
|
|
2111
2106
|
@pytest.mark.parametrize(
|
|
2112
|
-
"param, value",
|
|
2113
|
-
|
|
2107
|
+
("param", "value"),
|
|
2108
|
+
[
|
|
2114
2109
|
("worker_version", 1234),
|
|
2115
2110
|
("worker_run", 1234),
|
|
2116
2111
|
("transcription_worker_version", 1234),
|
|
2117
2112
|
("transcription_worker_run", 1234),
|
|
2118
|
-
|
|
2113
|
+
],
|
|
2119
2114
|
)
|
|
2120
2115
|
def test_list_element_parents_wrong_worker_version(mock_elements_worker, param, value):
|
|
2121
2116
|
elt = Element({"id": "12341234-1234-1234-1234-123412341234"})
|
|
@@ -2129,12 +2124,12 @@ def test_list_element_parents_wrong_worker_version(mock_elements_worker, param,
|
|
|
2129
2124
|
|
|
2130
2125
|
@pytest.mark.parametrize(
|
|
2131
2126
|
"param",
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2127
|
+
[
|
|
2128
|
+
"worker_version",
|
|
2129
|
+
"worker_run",
|
|
2130
|
+
"transcription_worker_version",
|
|
2131
|
+
"transcription_worker_run",
|
|
2132
|
+
],
|
|
2138
2133
|
)
|
|
2139
2134
|
def test_list_element_parents_wrong_bool_worker_version(mock_elements_worker, param):
|
|
2140
2135
|
elt = Element({"id": "12341234-1234-1234-1234-123412341234"})
|
|
@@ -2356,9 +2351,10 @@ def test_list_element_parents_with_cache_unhandled_param(
|
|
|
2356
2351
|
)
|
|
2357
2352
|
|
|
2358
2353
|
|
|
2354
|
+
@pytest.mark.usefixtures("_mock_cached_elements")
|
|
2359
2355
|
@pytest.mark.parametrize(
|
|
2360
|
-
"filters, expected_id",
|
|
2361
|
-
|
|
2356
|
+
("filters", "expected_id"),
|
|
2357
|
+
[
|
|
2362
2358
|
# Filter on element
|
|
2363
2359
|
(
|
|
2364
2360
|
{
|
|
@@ -2415,12 +2411,11 @@ def test_list_element_parents_with_cache_unhandled_param(
|
|
|
2415
2411
|
},
|
|
2416
2412
|
"99999999-9999-9999-9999-999999999999",
|
|
2417
2413
|
),
|
|
2418
|
-
|
|
2414
|
+
],
|
|
2419
2415
|
)
|
|
2420
2416
|
def test_list_element_parents_with_cache(
|
|
2421
2417
|
responses,
|
|
2422
2418
|
mock_elements_worker_with_cache,
|
|
2423
|
-
mock_cached_elements,
|
|
2424
2419
|
filters,
|
|
2425
2420
|
expected_id,
|
|
2426
2421
|
):
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
1
|
import json
|
|
3
2
|
import re
|
|
4
3
|
from uuid import UUID
|
|
@@ -56,7 +55,7 @@ def test_create_entity_wrong_type(mock_elements_worker):
|
|
|
56
55
|
)
|
|
57
56
|
|
|
58
57
|
|
|
59
|
-
def test_create_entity_wrong_corpus(
|
|
58
|
+
def test_create_entity_wrong_corpus(mock_elements_worker):
|
|
60
59
|
# Triggering an error on metas param, not giving corpus should work since
|
|
61
60
|
# ARKINDEX_CORPUS_ID environment variable is set on mock_elements_worker
|
|
62
61
|
with pytest.raises(AssertionError, match="metas should be of type dict"):
|
|
@@ -760,22 +759,13 @@ def test_list_corpus_entities(responses, mock_elements_worker):
|
|
|
760
759
|
]
|
|
761
760
|
|
|
762
761
|
|
|
763
|
-
@pytest.mark.parametrize(
|
|
764
|
-
"wrong_name",
|
|
765
|
-
[
|
|
766
|
-
1234,
|
|
767
|
-
12.5,
|
|
768
|
-
],
|
|
769
|
-
)
|
|
762
|
+
@pytest.mark.parametrize("wrong_name", [1234, 12.5])
|
|
770
763
|
def test_list_corpus_entities_wrong_name(mock_elements_worker, wrong_name):
|
|
771
764
|
with pytest.raises(AssertionError, match="name should be of type str"):
|
|
772
765
|
mock_elements_worker.list_corpus_entities(name=wrong_name)
|
|
773
766
|
|
|
774
767
|
|
|
775
|
-
@pytest.mark.parametrize(
|
|
776
|
-
"wrong_parent",
|
|
777
|
-
[{"id": "element_id"}, 12.5, "blabla"],
|
|
778
|
-
)
|
|
768
|
+
@pytest.mark.parametrize("wrong_parent", [{"id": "element_id"}, 12.5, "blabla"])
|
|
779
769
|
def test_list_corpus_entities_wrong_parent(mock_elements_worker, wrong_parent):
|
|
780
770
|
with pytest.raises(AssertionError, match="parent should be of type Element"):
|
|
781
771
|
mock_elements_worker.list_corpus_entities(parent=wrong_parent)
|
|
@@ -850,7 +840,7 @@ def test_check_required_entity_types_no_creation_allowed(
|
|
|
850
840
|
] == BASE_API_CALLS
|
|
851
841
|
|
|
852
842
|
|
|
853
|
-
@pytest.mark.parametrize("transcription",
|
|
843
|
+
@pytest.mark.parametrize("transcription", [None, "not a transcription", 1])
|
|
854
844
|
def test_create_transcription_entities_wrong_transcription(
|
|
855
845
|
mock_elements_worker, transcription
|
|
856
846
|
):
|
|
@@ -865,8 +855,8 @@ def test_create_transcription_entities_wrong_transcription(
|
|
|
865
855
|
|
|
866
856
|
|
|
867
857
|
@pytest.mark.parametrize(
|
|
868
|
-
"entities, error",
|
|
869
|
-
|
|
858
|
+
("entities", "error"),
|
|
859
|
+
[
|
|
870
860
|
(None, "entities shouldn't be null and should be of type list"),
|
|
871
861
|
(
|
|
872
862
|
"not a list of entities",
|
|
@@ -886,7 +876,7 @@ def test_create_transcription_entities_wrong_transcription(
|
|
|
886
876
|
* 2,
|
|
887
877
|
"entities should be unique",
|
|
888
878
|
),
|
|
889
|
-
|
|
879
|
+
],
|
|
890
880
|
)
|
|
891
881
|
def test_create_transcription_entities_wrong_entities(
|
|
892
882
|
mock_elements_worker, entities, error
|
|
@@ -909,8 +899,8 @@ def test_create_transcription_entities_wrong_entities_subtype(mock_elements_work
|
|
|
909
899
|
|
|
910
900
|
|
|
911
901
|
@pytest.mark.parametrize(
|
|
912
|
-
"entity, error",
|
|
913
|
-
|
|
902
|
+
("entity", "error"),
|
|
903
|
+
[
|
|
914
904
|
(
|
|
915
905
|
{
|
|
916
906
|
"name": None,
|
|
@@ -989,7 +979,7 @@ def test_create_transcription_entities_wrong_entities_subtype(mock_elements_work
|
|
|
989
979
|
},
|
|
990
980
|
"Entity at index 0 in entities: confidence should be None or a float in [0..1] range",
|
|
991
981
|
),
|
|
992
|
-
|
|
982
|
+
],
|
|
993
983
|
)
|
|
994
984
|
def test_create_transcription_entities_wrong_entity(
|
|
995
985
|
mock_elements_worker, entity, error
|