def test_updated_interaction_synced(opensearch_with_signals): """Test that when an interaction is updated it is synced to OpenSearch.""" interaction = CompanyInteractionFactory() new_subject = 'pluto' interaction.subject = new_subject interaction.save() opensearch_with_signals.indices.refresh() result = opensearch_with_signals.get( index=InteractionSearchApp.search_model.get_write_index(), id=interaction.pk, ) assert result['_source']['subject'] == new_subject
def test_updated_interaction_synced(es_with_signals): """Test that when an interaction is updated it is synced to ES.""" interaction = CompanyInteractionFactory() new_subject = 'pluto' interaction.subject = new_subject interaction.save() es_with_signals.indices.refresh() result = es_with_signals.get( index=InteractionSearchApp.es_model.get_write_index(), doc_type=DEFAULT_MAPPING_TYPE, id=interaction.pk, ) assert result['_source']['subject'] == new_subject
def test_updated_interaction_synced(setup_es): """Test that when an interaction is updated it is synced to ES.""" interaction = CompanyInteractionFactory() new_subject = 'pluto' interaction.subject = new_subject interaction.save() setup_es.indices.refresh() result = setup_es.get( index=InteractionSearchApp.es_model.get_write_index(), doc_type=InteractionSearchApp.name, id=interaction.pk, ) assert result['_source']['subject'] == new_subject
def test_investment_project_synched_only_if_interaction_linked( mocked_sync_object, opensearch_with_signals, ): """ Test sync_object_async not called if no investment project related to an interaction. When an interaction without an investment project attached to it is saved, the investment_project_sync_search_interaction_change signal should return without attempting to sync an investment project to OpenSearch. """ interaction = CompanyInteractionFactory() interaction.investment_project = None interaction.save() assert mocked_sync_object.call_count == 0 investment = InvestmentProjectFactory() interaction.investment_project = investment interaction.save() assert mocked_sync_object.call_count == 5