Skip to content

Fix leaking mock and hardcoded UUIDs in workflow tests

Erwan Rouchet requested to merge fix-workflow-tests into master

Two KeyError were occuring in local unit tests, but not in CI:

======================================================================
ERROR: test_create_element_source (arkindex.documents.tests.test_elements_api.TestElementsAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lucidiot/dev/ark/backend/arkindex/documents/tests/test_elements_api.py", line 450, in test_create_element_source
    response = self.client.post(**request)
[snip]
  File "/home/lucidiot/dev/ark/backend/arkindex/dataimport/tests/test_workflows_api.py", line 87, in <lambda>
    self.ml_get_mock.side_effect = lambda directory, type, slug: tools[slug]
KeyError: 'fairy_tale_detector'

======================================================================
ERROR: test_bulk_transcriptions_v2_wrong_fields_validation (arkindex.documents.tests.test_transcriptions.TestTranscriptionCreate)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/lucidiot/dev/ark/backend/arkindex/documents/tests/test_transcriptions.py", line 1054, in test_bulk_transcriptions_v2_wrong_fields_validation
    'text': 'There is a snake in my computer'
[snip]
  File "/home/lucidiot/dev/ark/backend/arkindex/dataimport/tests/test_workflows_api.py", line 87, in <lambda>
    self.ml_get_mock.side_effect = lambda directory, type, slug: tools[slug]
KeyError: 'gloubiboulga'

Those errors were caused by a MLTool.get mock in test_workflows_api, which was not actually removed at the end of the tests. This did not occur in CI because the test execution order is different.

While working on #356 (closed), I also noticed two tests had hardcoded corpus UUIDs that broke immediately when regenerating the test fixtures.

Edited by Erwan Rouchet

Merge request reports

Loading