2121import pytest
2222
2323from core import factories , models
24- from core .services .search_indexers import FindDocumentIndexer
24+ from core .services .search_indexers import SearchIndexer
2525
2626pytestmark = pytest .mark .django_db
2727
@@ -1450,7 +1450,7 @@ def test_models_documents_compute_ancestors_links_paths_mapping_structure(
14501450 }
14511451
14521452
1453- @mock .patch .object (FindDocumentIndexer , "push" )
1453+ @mock .patch .object (SearchIndexer , "push" )
14541454@pytest .mark .django_db (transaction = True )
14551455def test_models_documents_post_save_indexer (mock_push , indexer_settings ):
14561456 """Test indexation task on document creation"""
@@ -1462,7 +1462,7 @@ def test_models_documents_post_save_indexer(mock_push, indexer_settings):
14621462 accesses = {}
14631463 data = [call .args [0 ] for call in mock_push .call_args_list ]
14641464
1465- indexer = FindDocumentIndexer ()
1465+ indexer = SearchIndexer ()
14661466
14671467 assert sorted (data , key = itemgetter ("id" )) == sorted (
14681468 [
@@ -1479,7 +1479,7 @@ def test_models_documents_post_save_indexer(mock_push, indexer_settings):
14791479 assert cache .get (f"doc-indexer-debounce-{ doc3 .pk } " ) == 0
14801480
14811481
1482- @mock .patch .object (FindDocumentIndexer , "push" )
1482+ @mock .patch .object (SearchIndexer , "push" )
14831483@pytest .mark .django_db (transaction = True )
14841484def test_models_documents_post_save_indexer_not_configured (mock_push , indexer_settings ):
14851485 """Task should not start an indexation when disabled"""
@@ -1492,7 +1492,7 @@ def test_models_documents_post_save_indexer_not_configured(mock_push, indexer_se
14921492 assert mock_push .call_args_list == []
14931493
14941494
1495- @mock .patch .object (FindDocumentIndexer , "push" )
1495+ @mock .patch .object (SearchIndexer , "push" )
14961496@pytest .mark .django_db (transaction = True )
14971497def test_models_documents_post_save_indexer_with_accesses (mock_push , indexer_settings ):
14981498 """Test indexation task on document creation"""
@@ -1515,7 +1515,7 @@ def test_models_documents_post_save_indexer_with_accesses(mock_push, indexer_set
15151515
15161516 data = [call .args [0 ] for call in mock_push .call_args_list ]
15171517
1518- indexer = FindDocumentIndexer ()
1518+ indexer = SearchIndexer ()
15191519
15201520 assert sorted (data , key = itemgetter ("id" )) == sorted (
15211521 [
@@ -1532,7 +1532,7 @@ def test_models_documents_post_save_indexer_with_accesses(mock_push, indexer_set
15321532 assert cache .get (f"doc-indexer-debounce-{ doc3 .pk } " ) == 0
15331533
15341534
1535- @mock .patch .object (FindDocumentIndexer , "push" )
1535+ @mock .patch .object (SearchIndexer , "push" )
15361536@pytest .mark .django_db (transaction = True )
15371537def test_models_documents_post_save_indexer_deleted (mock_push , indexer_settings ):
15381538 """Indexation task on deleted or ancestor_deleted documents"""
@@ -1575,7 +1575,7 @@ def test_models_documents_post_save_indexer_deleted(mock_push, indexer_settings)
15751575
15761576 data = [call .args [0 ] for call in mock_push .call_args_list ]
15771577
1578- indexer = FindDocumentIndexer ()
1578+ indexer = SearchIndexer ()
15791579
15801580 # Even deleted document are re-indexed : only update their status in the future ?
15811581 assert sorted (data , key = itemgetter ("id" )) == sorted (
@@ -1594,7 +1594,7 @@ def test_models_documents_post_save_indexer_deleted(mock_push, indexer_settings)
15941594 assert cache .get (f"doc-indexer-debounce-{ doc_ancestor_deleted .pk } " ) == 0
15951595
15961596
1597- @mock .patch .object (FindDocumentIndexer , "push" )
1597+ @mock .patch .object (SearchIndexer , "push" )
15981598@pytest .mark .django_db (transaction = True )
15991599def test_models_documents_post_save_indexer_restored (mock_push , indexer_settings ):
16001600 """Restart indexation task on restored documents"""
@@ -1648,7 +1648,7 @@ def test_models_documents_post_save_indexer_restored(mock_push, indexer_settings
16481648
16491649 data = [call .args [0 ] for call in mock_push .call_args_list ]
16501650
1651- indexer = FindDocumentIndexer ()
1651+ indexer = SearchIndexer ()
16521652
16531653 # All docs are re-indexed
16541654 assert sorted (data , key = itemgetter ("id" )) == sorted (
@@ -1668,10 +1668,10 @@ def test_models_documents_post_save_indexer_debounce(indexer_settings):
16681668 """Test indexation task skipping on document update"""
16691669 indexer_settings .SEARCH_INDEXER_COUNTDOWN = 0
16701670
1671- indexer = FindDocumentIndexer ()
1671+ indexer = SearchIndexer ()
16721672 user = factories .UserFactory ()
16731673
1674- with mock .patch .object (FindDocumentIndexer , "push" ):
1674+ with mock .patch .object (SearchIndexer , "push" ):
16751675 with transaction .atomic ():
16761676 doc = factories .DocumentFactory ()
16771677 factories .UserDocumentAccessFactory (document = doc , user = user )
@@ -1680,7 +1680,7 @@ def test_models_documents_post_save_indexer_debounce(indexer_settings):
16801680 str (doc .path ): {"users" : [user .sub ]},
16811681 }
16821682
1683- with mock .patch .object (FindDocumentIndexer , "push" ) as mock_push :
1683+ with mock .patch .object (SearchIndexer , "push" ) as mock_push :
16841684 # Simulate 1 waiting task
16851685 cache .set (f"doc-indexer-debounce-{ doc .pk } " , 1 )
16861686
@@ -1691,7 +1691,7 @@ def test_models_documents_post_save_indexer_debounce(indexer_settings):
16911691
16921692 assert [call .args [0 ] for call in mock_push .call_args_list ] == []
16931693
1694- with mock .patch .object (FindDocumentIndexer , "push" ) as mock_push :
1694+ with mock .patch .object (SearchIndexer , "push" ) as mock_push :
16951695 # No waiting task
16961696 cache .set (f"doc-indexer-debounce-{ doc .pk } " , 0 )
16971697
@@ -1709,10 +1709,10 @@ def test_models_documents_access_post_save_indexer(indexer_settings):
17091709 """Test indexation task on DocumentAccess update"""
17101710 indexer_settings .SEARCH_INDEXER_COUNTDOWN = 0
17111711
1712- indexer = FindDocumentIndexer ()
1712+ indexer = SearchIndexer ()
17131713 user = factories .UserFactory ()
17141714
1715- with mock .patch .object (FindDocumentIndexer , "push" ):
1715+ with mock .patch .object (SearchIndexer , "push" ):
17161716 with transaction .atomic ():
17171717 doc = factories .DocumentFactory ()
17181718 doc_access = factories .UserDocumentAccessFactory (document = doc , user = user )
@@ -1721,9 +1721,9 @@ def test_models_documents_access_post_save_indexer(indexer_settings):
17211721 str (doc .path ): {"users" : [user .sub ]},
17221722 }
17231723
1724- indexer = FindDocumentIndexer ()
1724+ indexer = SearchIndexer ()
17251725
1726- with mock .patch .object (FindDocumentIndexer , "push" ) as mock_push :
1726+ with mock .patch .object (SearchIndexer , "push" ) as mock_push :
17271727 with transaction .atomic ():
17281728 doc_access .save ()
17291729
0 commit comments