Skip to content

Commit

Permalink
refactor: maintainability
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvanr committed Feb 6, 2024
1 parent 2318919 commit 9d5f4c6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/direct_indexing/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
subtask_publisher_metadata
)

CLEAR_INDICES = 'direct_indexing.direct_indexing.clear_indices'


def test_clear_all_cores(mocker):
# mock direct_indexing.clear_indices
mock_clear = mocker.patch('direct_indexing.direct_indexing.clear_indices')
mock_clear = mocker.patch(CLEAR_INDICES)
clear_all_cores()
mock_clear.assert_called_once()

Expand All @@ -35,7 +37,7 @@ def test_start(mocker):

# mock clear_indices
# mock_datadump.return_value = True
mocker.patch('direct_indexing.direct_indexing.clear_indices', side_effect=pysolr.SolrError)
mocker.patch(CLEAR_INDICES, side_effect=pysolr.SolrError)
assert start(False) == "Error clearing the direct indexing cores, check your Solr instance."
mock_subtask_dataset_metadata.assert_not_called()
mock_drop.assert_not_called()
Expand All @@ -46,7 +48,7 @@ def test_start(mocker):
assert res == "Both the publisher and dataset metadata indexing have begun."

# Test if drop is true, direct_indexing.drop_removed_data() is called once
mocker.patch('direct_indexing.direct_indexing.clear_indices', side_effect=None)
mocker.patch(CLEAR_INDICES, side_effect=None)
start(False, drop=True)
mock_drop.assert_called_once()

Expand Down

0 comments on commit 9d5f4c6

Please sign in to comment.