arkindex-base-worker 0.3.5rc6__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.
Files changed (43) hide show
  1. arkindex_base_worker-0.3.6rc2.dist-info/METADATA +39 -0
  2. arkindex_base_worker-0.3.6rc2.dist-info/RECORD +40 -0
  3. arkindex_worker/__init__.py +0 -1
  4. arkindex_worker/cache.py +19 -25
  5. arkindex_worker/image.py +16 -17
  6. arkindex_worker/models.py +24 -21
  7. arkindex_worker/utils.py +18 -19
  8. arkindex_worker/worker/__init__.py +17 -27
  9. arkindex_worker/worker/base.py +12 -7
  10. arkindex_worker/worker/classification.py +13 -15
  11. arkindex_worker/worker/dataset.py +3 -4
  12. arkindex_worker/worker/element.py +80 -76
  13. arkindex_worker/worker/entity.py +28 -30
  14. arkindex_worker/worker/metadata.py +21 -27
  15. arkindex_worker/worker/task.py +2 -3
  16. arkindex_worker/worker/training.py +25 -26
  17. arkindex_worker/worker/transcription.py +37 -34
  18. arkindex_worker/worker/version.py +1 -2
  19. tests/conftest.py +56 -76
  20. tests/test_base_worker.py +38 -32
  21. tests/test_cache.py +14 -7
  22. tests/test_dataset_worker.py +25 -22
  23. tests/test_element.py +0 -1
  24. tests/test_elements_worker/__init__.py +0 -1
  25. tests/test_elements_worker/test_classifications.py +0 -1
  26. tests/test_elements_worker/test_cli.py +22 -17
  27. tests/test_elements_worker/test_dataset.py +9 -10
  28. tests/test_elements_worker/test_elements.py +58 -63
  29. tests/test_elements_worker/test_entities.py +10 -20
  30. tests/test_elements_worker/test_metadata.py +72 -96
  31. tests/test_elements_worker/test_task.py +22 -20
  32. tests/test_elements_worker/test_training.py +20 -13
  33. tests/test_elements_worker/test_transcriptions.py +6 -10
  34. tests/test_elements_worker/test_worker.py +16 -14
  35. tests/test_image.py +21 -20
  36. tests/test_merge.py +5 -6
  37. tests/test_utils.py +0 -1
  38. arkindex_base_worker-0.3.5rc6.dist-info/METADATA +0 -27
  39. arkindex_base_worker-0.3.5rc6.dist-info/RECORD +0 -42
  40. arkindex_worker/git.py +0 -392
  41. tests/test_git.py +0 -480
  42. {arkindex_base_worker-0.3.5rc6.dist-info → arkindex_base_worker-0.3.6rc2.dist-info}/WHEEL +0 -0
  43. {arkindex_base_worker-0.3.5rc6.dist-info → arkindex_base_worker-0.3.6rc2.dist-info}/top_level.txt +0 -0
tests/conftest.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  import hashlib
3
2
  import json
4
3
  import os
@@ -19,10 +18,10 @@ from arkindex_worker.cache import (
19
18
  CachedImage,
20
19
  CachedTranscription,
21
20
  Version,
21
+ create_tables,
22
22
  create_version_table,
23
23
  init_cache_db,
24
24
  )
25
- from arkindex_worker.git import GitHelper, GitlabHelper
26
25
  from arkindex_worker.models import Artifact, Dataset
27
26
  from arkindex_worker.worker import BaseWorker, DatasetWorker, ElementsWorker
28
27
  from arkindex_worker.worker.dataset import DatasetState
@@ -37,7 +36,7 @@ __yaml_cache = {}
37
36
 
38
37
 
39
38
  @pytest.fixture(autouse=True)
40
- def disable_sleep(monkeypatch):
39
+ def _disable_sleep(monkeypatch):
41
40
  """
42
41
  Do not sleep at all in between API executions
43
42
  when errors occur in unit tests.
@@ -46,8 +45,8 @@ def disable_sleep(monkeypatch):
46
45
  monkeypatch.setattr(time, "sleep", lambda x: None)
47
46
 
48
47
 
49
- @pytest.fixture
50
- def cache_yaml(monkeypatch):
48
+ @pytest.fixture()
49
+ def _cache_yaml(monkeypatch):
51
50
  """
52
51
  Cache all calls to yaml.safe_load in order to speedup
53
52
  every test cases that load the OpenAPI schema
@@ -75,7 +74,7 @@ def cache_yaml(monkeypatch):
75
74
 
76
75
 
77
76
  @pytest.fixture(autouse=True)
78
- def setup_api(responses, monkeypatch, cache_yaml):
77
+ def _setup_api(responses, monkeypatch, _cache_yaml):
79
78
  # Always use the environment variable first
80
79
  schema_url = os.environ.get("ARKINDEX_API_SCHEMA_URL")
81
80
  if schema_url is None:
@@ -106,13 +105,13 @@ def setup_api(responses, monkeypatch, cache_yaml):
106
105
 
107
106
 
108
107
  @pytest.fixture(autouse=True)
109
- def give_env_variable(request, monkeypatch):
108
+ def _give_env_variable(monkeypatch):
110
109
  """Defines required environment variables"""
111
110
  monkeypatch.setenv("ARKINDEX_WORKER_RUN_ID", "56785678-5678-5678-5678-567856785678")
112
111
 
113
112
 
114
- @pytest.fixture
115
- def mock_worker_run_api(responses):
113
+ @pytest.fixture()
114
+ def _mock_worker_run_api(responses):
116
115
  """Provide a mock API response to get worker run information"""
117
116
  payload = {
118
117
  "id": "56785678-5678-5678-5678-567856785678",
@@ -180,8 +179,8 @@ def mock_worker_run_api(responses):
180
179
  )
181
180
 
182
181
 
183
- @pytest.fixture
184
- def mock_worker_run_no_revision_api(responses):
182
+ @pytest.fixture()
183
+ def _mock_worker_run_no_revision_api(responses):
185
184
  """Provide a mock API response to get worker run not linked to a revision information"""
186
185
  payload = {
187
186
  "id": "56785678-5678-5678-5678-567856785678",
@@ -247,8 +246,8 @@ def mock_worker_run_no_revision_api(responses):
247
246
  )
248
247
 
249
248
 
250
- @pytest.fixture
251
- def mock_activity_calls(responses):
249
+ @pytest.fixture()
250
+ def _mock_activity_calls(responses):
252
251
  """
253
252
  Mock responses when updating the activity state for multiple element of the same version
254
253
  """
@@ -259,8 +258,8 @@ def mock_activity_calls(responses):
259
258
  )
260
259
 
261
260
 
262
- @pytest.fixture
263
- def mock_elements_worker(monkeypatch, mock_worker_run_api):
261
+ @pytest.fixture()
262
+ def mock_elements_worker(monkeypatch, _mock_worker_run_api):
264
263
  """Build and configure an ElementsWorker with fixed CLI parameters to avoid issues with pytest"""
265
264
  monkeypatch.setattr(sys, "argv", ["worker"])
266
265
  worker = ElementsWorker()
@@ -268,7 +267,7 @@ def mock_elements_worker(monkeypatch, mock_worker_run_api):
268
267
  return worker
269
268
 
270
269
 
271
- @pytest.fixture
270
+ @pytest.fixture()
272
271
  def mock_elements_worker_read_only(monkeypatch):
273
272
  """Build and configure an ElementsWorker with fixed CLI parameters to avoid issues with pytest"""
274
273
  monkeypatch.setattr(sys, "argv", ["worker", "--dev"])
@@ -277,7 +276,7 @@ def mock_elements_worker_read_only(monkeypatch):
277
276
  return worker
278
277
 
279
278
 
280
- @pytest.fixture
279
+ @pytest.fixture()
281
280
  def mock_elements_worker_with_list(monkeypatch, responses, mock_elements_worker):
282
281
  """
283
282
  Mock a worker instance to list and retrieve a single element
@@ -298,8 +297,19 @@ def mock_elements_worker_with_list(monkeypatch, responses, mock_elements_worker)
298
297
  return mock_elements_worker
299
298
 
300
299
 
301
- @pytest.fixture
302
- def mock_base_worker_with_cache(mocker, monkeypatch, mock_worker_run_api):
300
+ @pytest.fixture()
301
+ def mock_cache_db(tmp_path):
302
+ cache_path = tmp_path / "db.sqlite"
303
+
304
+ init_cache_db(cache_path)
305
+ create_version_table()
306
+ create_tables()
307
+
308
+ return cache_path
309
+
310
+
311
+ @pytest.fixture()
312
+ def mock_base_worker_with_cache(monkeypatch, _mock_worker_run_api):
303
313
  """Build a BaseWorker using SQLite cache, also mocking a PONOS_TASK"""
304
314
  monkeypatch.setattr(sys, "argv", ["worker"])
305
315
 
@@ -309,13 +319,10 @@ def mock_base_worker_with_cache(mocker, monkeypatch, mock_worker_run_api):
309
319
  return worker
310
320
 
311
321
 
312
- @pytest.fixture
313
- def mock_elements_worker_with_cache(monkeypatch, mock_worker_run_api, tmp_path):
322
+ @pytest.fixture()
323
+ def mock_elements_worker_with_cache(monkeypatch, mock_cache_db, _mock_worker_run_api):
314
324
  """Build and configure an ElementsWorker using SQLite cache with fixed CLI parameters to avoid issues with pytest"""
315
- cache_path = tmp_path / "db.sqlite"
316
- init_cache_db(cache_path)
317
- create_version_table()
318
- monkeypatch.setattr(sys, "argv", ["worker", "-d", str(cache_path)])
325
+ monkeypatch.setattr(sys, "argv", ["worker", "-d", str(mock_cache_db)])
319
326
 
320
327
  worker = ElementsWorker(support_cache=True)
321
328
  worker.configure()
@@ -323,35 +330,34 @@ def mock_elements_worker_with_cache(monkeypatch, mock_worker_run_api, tmp_path):
323
330
  return worker
324
331
 
325
332
 
326
- @pytest.fixture
333
+ @pytest.fixture()
327
334
  def fake_page_element():
328
- with open(FIXTURES_DIR / "page_element.json", "r") as f:
329
- return json.load(f)
335
+ return json.loads((FIXTURES_DIR / "page_element.json").read_text())
330
336
 
331
337
 
332
- @pytest.fixture
338
+ @pytest.fixture()
333
339
  def fake_ufcn_worker_version():
334
- with open(FIXTURES_DIR / "ufcn_line_historical_worker_version.json", "r") as f:
335
- return json.load(f)
340
+ return json.loads(
341
+ (FIXTURES_DIR / "ufcn_line_historical_worker_version.json").read_text()
342
+ )
336
343
 
337
344
 
338
- @pytest.fixture
345
+ @pytest.fixture()
339
346
  def fake_transcriptions_small():
340
- with open(FIXTURES_DIR / "line_transcriptions_small.json", "r") as f:
341
- return json.load(f)
347
+ return json.loads((FIXTURES_DIR / "line_transcriptions_small.json").read_text())
342
348
 
343
349
 
344
- @pytest.fixture
350
+ @pytest.fixture()
345
351
  def model_file_dir():
346
352
  return SAMPLES_DIR / "model_files"
347
353
 
348
354
 
349
- @pytest.fixture
355
+ @pytest.fixture()
350
356
  def model_file_dir_with_subfolder():
351
357
  return SAMPLES_DIR / "root_folder"
352
358
 
353
359
 
354
- @pytest.fixture
360
+ @pytest.fixture()
355
361
  def fake_dummy_worker():
356
362
  api_client = MockApiClient()
357
363
  worker = ElementsWorker()
@@ -359,34 +365,8 @@ def fake_dummy_worker():
359
365
  return worker
360
366
 
361
367
 
362
- @pytest.fixture
363
- def fake_git_helper(mocker):
364
- gitlab_helper = mocker.MagicMock()
365
- return GitHelper(
366
- "repo_url",
367
- "/tmp/git_test/foo/",
368
- "/tmp/test/path/",
369
- "tmp_workflow_id",
370
- gitlab_helper,
371
- )
372
-
373
-
374
- @pytest.fixture
375
- def fake_gitlab_helper_factory():
376
- # have to set up the responses, before creating the client
377
- def run():
378
- return GitlabHelper(
379
- "balsac_exporter/balsac-exported-xmls-testing",
380
- "https://gitlab.com",
381
- "<GITLAB_TOKEN>",
382
- "gitlab_branch",
383
- )
384
-
385
- return run
386
-
387
-
388
- @pytest.fixture
389
- def mock_cached_elements():
368
+ @pytest.fixture()
369
+ def _mock_cached_elements(mock_cache_db):
390
370
  """Insert few elements in local cache"""
391
371
  CachedElement.create(
392
372
  id=UUID("99999999-9999-9999-9999-999999999999"),
@@ -430,8 +410,8 @@ def mock_cached_elements():
430
410
  assert CachedElement.select().count() == 5
431
411
 
432
412
 
433
- @pytest.fixture
434
- def mock_cached_images():
413
+ @pytest.fixture()
414
+ def _mock_cached_images(mock_cache_db):
435
415
  """Insert few elements in local cache"""
436
416
  CachedImage.create(
437
417
  id=UUID("99999999-9999-9999-9999-999999999999"),
@@ -442,8 +422,8 @@ def mock_cached_images():
442
422
  assert CachedImage.select().count() == 1
443
423
 
444
424
 
445
- @pytest.fixture
446
- def mock_cached_transcriptions():
425
+ @pytest.fixture()
426
+ def _mock_cached_transcriptions(mock_cache_db):
447
427
  """Insert few transcriptions in local cache, on a shared element"""
448
428
  CachedElement.create(
449
429
  id=UUID("11111111-1111-1111-1111-111111111111"),
@@ -529,7 +509,7 @@ def mock_cached_transcriptions():
529
509
  )
530
510
 
531
511
 
532
- @pytest.fixture(scope="function")
512
+ @pytest.fixture()
533
513
  def mock_databases(tmp_path):
534
514
  """
535
515
  Initialize several temporary databases
@@ -612,7 +592,7 @@ def mock_databases(tmp_path):
612
592
  return out
613
593
 
614
594
 
615
- @pytest.fixture
595
+ @pytest.fixture()
616
596
  def default_dataset():
617
597
  return Dataset(
618
598
  **{
@@ -630,8 +610,8 @@ def default_dataset():
630
610
  )
631
611
 
632
612
 
633
- @pytest.fixture
634
- def mock_dataset_worker(monkeypatch, mocker, mock_worker_run_api):
613
+ @pytest.fixture()
614
+ def mock_dataset_worker(monkeypatch, mocker, _mock_worker_run_api):
635
615
  monkeypatch.setenv("PONOS_TASK", "my_task")
636
616
  mocker.patch.object(sys, "argv", ["worker"])
637
617
 
@@ -644,7 +624,7 @@ def mock_dataset_worker(monkeypatch, mocker, mock_worker_run_api):
644
624
  return dataset_worker
645
625
 
646
626
 
647
- @pytest.fixture
627
+ @pytest.fixture()
648
628
  def mock_dev_dataset_worker(mocker):
649
629
  mocker.patch.object(
650
630
  sys,
@@ -668,12 +648,12 @@ def mock_dev_dataset_worker(mocker):
668
648
  return dataset_worker
669
649
 
670
650
 
671
- @pytest.fixture
651
+ @pytest.fixture()
672
652
  def default_artifact():
673
653
  return Artifact(
674
654
  **{
675
655
  "id": "artifact_id",
676
- "path": "dataset_id.zstd",
656
+ "path": "dataset_id.tar.zst",
677
657
  "size": 42,
678
658
  "content_type": "application/zstd",
679
659
  "s3_put_url": None,
tests/test_base_worker.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  import json
3
2
  import logging
4
3
  import sys
@@ -15,7 +14,7 @@ from arkindex_worker.worker.base import ExtrasDirNotFoundError
15
14
  from tests.conftest import FIXTURES_DIR
16
15
 
17
16
 
18
- def test_init_default_local_share(monkeypatch):
17
+ def test_init_default_local_share():
19
18
  worker = BaseWorker()
20
19
 
21
20
  assert worker.work_dir == Path("~/.local/share/arkindex").expanduser()
@@ -29,7 +28,7 @@ def test_init_default_xdg_data_home(monkeypatch):
29
28
  assert str(worker.work_dir) == f"{path}/arkindex"
30
29
 
31
30
 
32
- def test_init_with_local_cache(monkeypatch):
31
+ def test_init_with_local_cache():
33
32
  worker = BaseWorker(support_cache=True)
34
33
 
35
34
  assert worker.work_dir == Path("~/.local/share/arkindex").expanduser()
@@ -72,7 +71,8 @@ def test_init_var_worker_local_file(monkeypatch, tmp_path):
72
71
  config.unlink()
73
72
 
74
73
 
75
- def test_cli_default(mocker, mock_worker_run_api):
74
+ @pytest.mark.usefixtures("_mock_worker_run_api")
75
+ def test_cli_default(mocker):
76
76
  worker = BaseWorker()
77
77
  assert logger.level == logging.NOTSET
78
78
 
@@ -91,7 +91,8 @@ def test_cli_default(mocker, mock_worker_run_api):
91
91
  logger.setLevel(logging.NOTSET)
92
92
 
93
93
 
94
- def test_cli_arg_verbose_given(mocker, mock_worker_run_api):
94
+ @pytest.mark.usefixtures("_mock_worker_run_api")
95
+ def test_cli_arg_verbose_given(mocker):
95
96
  worker = BaseWorker()
96
97
  assert logger.level == logging.NOTSET
97
98
 
@@ -110,7 +111,8 @@ def test_cli_arg_verbose_given(mocker, mock_worker_run_api):
110
111
  logger.setLevel(logging.NOTSET)
111
112
 
112
113
 
113
- def test_cli_envvar_debug_given(mocker, monkeypatch, mock_worker_run_api):
114
+ @pytest.mark.usefixtures("_mock_worker_run_api")
115
+ def test_cli_envvar_debug_given(mocker, monkeypatch):
114
116
  worker = BaseWorker()
115
117
 
116
118
  assert logger.level == logging.NOTSET
@@ -129,7 +131,7 @@ def test_cli_envvar_debug_given(mocker, monkeypatch, mock_worker_run_api):
129
131
  logger.setLevel(logging.NOTSET)
130
132
 
131
133
 
132
- def test_configure_dev_mode(mocker, monkeypatch):
134
+ def test_configure_dev_mode(mocker):
133
135
  """
134
136
  Configuring a worker in developer mode avoid retrieving process information
135
137
  """
@@ -145,7 +147,7 @@ def test_configure_dev_mode(mocker, monkeypatch):
145
147
  assert worker.user_configuration == {}
146
148
 
147
149
 
148
- def test_configure_worker_run(mocker, monkeypatch, responses, caplog):
150
+ def test_configure_worker_run(mocker, responses, caplog):
149
151
  # Capture log messages
150
152
  caplog.set_level(logging.INFO)
151
153
 
@@ -214,9 +216,8 @@ def test_configure_worker_run(mocker, monkeypatch, responses, caplog):
214
216
  assert worker.user_configuration == {"a": "b"}
215
217
 
216
218
 
217
- def test_configure_worker_run_no_revision(
218
- mocker, monkeypatch, mock_worker_run_no_revision_api, caplog
219
- ):
219
+ @pytest.mark.usefixtures("_mock_worker_run_no_revision_api")
220
+ def test_configure_worker_run_no_revision(mocker, caplog):
220
221
  worker = BaseWorker()
221
222
 
222
223
  mocker.patch.object(sys, "argv", ["worker"])
@@ -234,11 +235,7 @@ def test_configure_worker_run_no_revision(
234
235
  ]
235
236
 
236
237
 
237
- def test_configure_user_configuration_defaults(
238
- mocker,
239
- monkeypatch,
240
- responses,
241
- ):
238
+ def test_configure_user_configuration_defaults(mocker, responses):
242
239
  worker = BaseWorker()
243
240
  mocker.patch.object(sys, "argv")
244
241
  worker.args = worker.parser.parse_args()
@@ -300,8 +297,8 @@ def test_configure_user_configuration_defaults(
300
297
  }
301
298
 
302
299
 
303
- @pytest.mark.parametrize("debug", (True, False))
304
- def test_configure_user_config_debug(mocker, monkeypatch, responses, debug):
300
+ @pytest.mark.parametrize("debug", [True, False])
301
+ def test_configure_user_config_debug(mocker, responses, debug):
305
302
  worker = BaseWorker()
306
303
  mocker.patch.object(sys, "argv", ["worker"])
307
304
  assert logger.level == logging.NOTSET
@@ -347,7 +344,7 @@ def test_configure_user_config_debug(mocker, monkeypatch, responses, debug):
347
344
  logger.setLevel(logging.NOTSET)
348
345
 
349
346
 
350
- def test_configure_worker_run_missing_conf(mocker, monkeypatch, responses):
347
+ def test_configure_worker_run_missing_conf(mocker, responses):
351
348
  worker = BaseWorker()
352
349
  mocker.patch.object(sys, "argv", ["worker"])
353
350
 
@@ -392,7 +389,7 @@ def test_configure_worker_run_missing_conf(mocker, monkeypatch, responses):
392
389
  assert worker.user_configuration == {}
393
390
 
394
391
 
395
- def test_configure_worker_run_no_worker_run_conf(mocker, monkeypatch, responses):
392
+ def test_configure_worker_run_no_worker_run_conf(mocker, responses):
396
393
  """
397
394
  No configuration is provided but should not crash
398
395
  """
@@ -434,7 +431,7 @@ def test_configure_worker_run_no_worker_run_conf(mocker, monkeypatch, responses)
434
431
  assert worker.user_configuration == {}
435
432
 
436
433
 
437
- def test_configure_load_model_configuration(mocker, monkeypatch, responses):
434
+ def test_configure_load_model_configuration(mocker, responses):
438
435
  worker = BaseWorker()
439
436
  mocker.patch.object(sys, "argv", ["worker"])
440
437
  payload = {
@@ -454,7 +451,10 @@ def test_configure_load_model_configuration(mocker, monkeypatch, responses):
454
451
  "configuration": None,
455
452
  "model_version": {
456
453
  "id": "12341234-1234-1234-1234-123412341234",
457
- "name": "Model version 1337",
454
+ "model": {
455
+ "id": "43214321-4321-4321-4321-432143214321",
456
+ "name": "Model 1337",
457
+ },
458
458
  "configuration": {
459
459
  "param1": "value1",
460
460
  "param2": 2,
@@ -489,6 +489,10 @@ def test_configure_load_model_configuration(mocker, monkeypatch, responses):
489
489
  "param3": None,
490
490
  }
491
491
  assert worker.model_version_id == "12341234-1234-1234-1234-123412341234"
492
+ assert worker.model_details == {
493
+ "id": "43214321-4321-4321-4321-432143214321",
494
+ "name": "Model 1337",
495
+ }
492
496
 
493
497
 
494
498
  def test_load_missing_secret():
@@ -578,7 +582,7 @@ def test_load_local_secret(monkeypatch, tmp_path):
578
582
  secret.write_text("this is a local secret value", encoding="utf-8")
579
583
 
580
584
  # Mock GPG decryption
581
- class GpgDecrypt(object):
585
+ class GpgDecrypt:
582
586
  def __init__(self, fd):
583
587
  self.ok = True
584
588
  self.data = fd.read()
@@ -631,15 +635,15 @@ def test_find_extras_directory_from_config(monkeypatch):
631
635
 
632
636
 
633
637
  @pytest.mark.parametrize(
634
- "extras_path, exists, error",
635
- (
636
- [
638
+ ("extras_path", "exists", "error"),
639
+ [
640
+ (
637
641
  None,
638
642
  True,
639
643
  "No path to the directory for extra files was provided. Please provide extras_dir either through configuration or as CLI argument.",
640
- ],
641
- ["extra_files", False, "The path extra_files does not link to any directory"],
642
- ),
644
+ ),
645
+ ("extra_files", False, "The path extra_files does not link to any directory"),
646
+ ],
643
647
  )
644
648
  def test_find_extras_directory_not_found(monkeypatch, extras_path, exists, error):
645
649
  if extras_path:
@@ -666,7 +670,9 @@ def test_find_parents_file_paths(responses, mock_base_worker_with_cache, tmp_pat
666
670
  )
667
671
 
668
672
  filename = Path("my_file.txt")
669
- for parent_id, content in zip(["first", "third"], ["Some text", "Other text"]):
673
+ for parent_id, content in zip(
674
+ ["first", "third"], ["Some text", "Other text"], strict=True
675
+ ):
670
676
  (tmp_path / parent_id).mkdir()
671
677
  file_path = tmp_path / parent_id / filename
672
678
  with file_path.open("w", encoding="utf-8") as f:
@@ -697,7 +703,7 @@ def test_extract_parent_archives(tmp_path):
697
703
  ]
698
704
  worker.task_data_dir = FIXTURES_DIR / "extract_parent_archives"
699
705
 
700
- worker.extract_parent_archives("arkindex_data.zstd", tmp_path)
706
+ worker.extract_parent_archives("arkindex_data.tar.zst", tmp_path)
701
707
 
702
708
  extracted_files = [
703
709
  # Test
@@ -742,7 +748,7 @@ def test_corpus_id_not_set_read_only_mode(
742
748
  with pytest.raises(
743
749
  Exception, match="Missing ARKINDEX_CORPUS_ID environment variable"
744
750
  ):
745
- mock_elements_worker_read_only.corpus_id
751
+ _ = mock_elements_worker_read_only.corpus_id
746
752
 
747
753
 
748
754
  def test_corpus_id_set_read_only_mode(
tests/test_cache.py CHANGED
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  from pathlib import Path
3
2
  from uuid import UUID
4
3
 
@@ -31,22 +30,20 @@ def test_init(tmp_path):
31
30
 
32
31
 
33
32
  def test_create_tables_existing_table(tmp_path):
34
- db_path = f"{tmp_path}/db.sqlite"
33
+ db_path = tmp_path / "db.sqlite"
35
34
 
36
35
  # Create the tables once…
37
36
  init_cache_db(db_path)
38
37
  create_tables()
39
38
  db.close()
40
39
 
41
- with open(db_path, "rb") as before_file:
42
- before = before_file.read()
40
+ before = db_path.read_bytes()
43
41
 
44
42
  # Create them again
45
43
  init_cache_db(db_path)
46
44
  create_tables()
47
45
 
48
- with open(db_path, "rb") as after_file:
49
- after = after_file.read()
46
+ after = db_path.read_bytes()
50
47
 
51
48
  assert before == after, "Existing table structure was modified"
52
49
 
@@ -144,7 +141,17 @@ def test_check_version_same_version(tmp_path):
144
141
 
145
142
 
146
143
  @pytest.mark.parametrize(
147
- "image_width,image_height,polygon_x,polygon_y,polygon_width,polygon_height,max_width,max_height,expected_url",
144
+ (
145
+ "image_width",
146
+ "image_height",
147
+ "polygon_x",
148
+ "polygon_y",
149
+ "polygon_width",
150
+ "polygon_height",
151
+ "max_width",
152
+ "max_height",
153
+ "expected_url",
154
+ ),
148
155
  [
149
156
  # No max_size: no resize
150
157
  (