diff --git a/tests/direct_indexing/test_tasks.py b/tests/direct_indexing/test_tasks.py index f6145cbe1..92844dddf 100644 --- a/tests/direct_indexing/test_tasks.py +++ b/tests/direct_indexing/test_tasks.py @@ -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() @@ -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() @@ -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()