Example #1
0
def test_investment_project_interaction_deleted_sync_to_opensearch(
        opensearch_with_signals):
    """Test investment project gets synced to OpenSearch when an interaction is deleted."""
    investment_project = InvestmentProjectFactory()
    interaction = InvestmentProjectInteractionFactory(
        investment_project=investment_project, )
    opensearch_with_signals.indices.refresh()

    assert_project_search_latest_interaction(has_interaction=True)

    interaction.delete()
    opensearch_with_signals.indices.refresh()

    assert_project_search_latest_interaction(has_interaction=False)
Example #2
0
def test_deleted_interaction_deleted_from_opensearch(opensearch_with_signals):
    """
    Test that when an interaction is deleted from db it is also
    deleted from OpenSearch.
    """
    interaction = InvestmentProjectInteractionFactory()
    opensearch_with_signals.indices.refresh()

    assert opensearch_with_signals.get(
        index=InteractionSearchApp.search_model.get_write_index(),
        id=interaction.pk,
    )

    interaction_id = interaction.pk
    interaction.delete()
    opensearch_with_signals.indices.refresh()

    with pytest.raises(NotFoundError):
        assert opensearch_with_signals.get(
            index=InteractionSearchApp.search_model.get_write_index(),
            id=interaction_id,
        ) is None
Example #3
0
def test_deleted_interaction_deleted_from_es(es_with_signals):
    """
    Test that when an interaction is deleted from db it is also
    deleted from ES.
    """
    interaction = InvestmentProjectInteractionFactory()
    es_with_signals.indices.refresh()

    assert es_with_signals.get(
        index=InteractionSearchApp.es_model.get_write_index(),
        doc_type=InteractionSearchApp.name,
        id=interaction.pk,
    )

    interaction_id = interaction.pk
    interaction.delete()
    es_with_signals.indices.refresh()

    with pytest.raises(NotFoundError):
        assert es_with_signals.get(
            index=InteractionSearchApp.es_model.get_write_index(),
            doc_type=InteractionSearchApp.name,
            id=interaction_id,
        ) is None