示例#1
0
 def test_notify_signal_company_updated_no_investigation(self):
     """
     Test that a notification would not be sent when a company pending investigation
     is updated.
     """
     client = self._get_dnb_investigation_notify_client()
     company = CompanyFactory(pending_dnb_investigation=True)
     client.reset_mock()
     company.name = 'foobar'
     company.save()
     client.send_email_notification.assert_not_called()
示例#2
0
def test_edit_company_syncs_large_investor_profile_in_es(es_with_signals):
    """Tests that updating company details also updated the relevant investor profiles."""
    new_company_name = 'SYNC TEST'
    investor_company = CompanyFactory()
    investor_profile = LargeCapitalInvestorProfileFactory(
        investor_company=investor_company)
    es_with_signals.indices.refresh()
    investor_company.name = new_company_name
    investor_company.save()

    result = _get_es_document(es_with_signals, investor_profile.pk)
    assert result['_source']['investor_company']['name'] == new_company_name
示例#3
0
def test_company_auto_updates_to_es(setup_es):
    """Tests if company gets updated in Elasticsearch."""
    test_name = 'very_hard_to_find_company_international'
    company = CompanyFactory(name=test_name, )
    new_test_name = 'very_hard_to_find_company_local'
    company.name = new_test_name
    company.save()
    setup_es.indices.refresh()

    result = get_basic_search_query(Company, new_test_name).execute()

    assert result.hits.total == 1
    assert result.hits[0].id == str(company.id)
示例#4
0
def test_company_auto_updates_to_opensearch(opensearch_with_signals):
    """Tests if company gets updated in OpenSearch."""
    test_name = 'very_hard_to_find_company_international'
    company = CompanyFactory(name=test_name, )
    new_test_name = 'very_hard_to_find_company_local'
    company.name = new_test_name
    company.save()
    opensearch_with_signals.indices.refresh()

    result = get_basic_search_query(Company, new_test_name).execute()

    assert result.hits.total.value == 1
    assert result.hits[0].id == str(company.id)
示例#5
0
def test_edit_promoter_syncs_large_capital_opportunity_in_opensearch(
        opensearch_with_signals):
    """
    Tests that updating promoter company details also updated the relevant
    large capital opportunity.
    """
    new_company_name = 'SYNC TEST'
    promoter = CompanyFactory()
    opportunity = LargeCapitalOpportunityFactory(promoters=[promoter])
    opensearch_with_signals.indices.refresh()
    promoter.name = new_company_name
    promoter.save()

    result = _get_documents(opensearch_with_signals, opportunity.pk)
    assert result['_source']['promoters'][0]['name'] == new_company_name
def test_edit_company_does_not_sync_growth_investor_profile(setup_es):
    """
    Tests that updating company details of a company with a growth investor profile,
    the profile is not synced to elasticsearch.
    """
    investor_company = CompanyFactory()
    setup_es.indices.refresh()

    with mock.patch('datahub.search.tasks.sync_object_task.apply_async'
                    ) as mock_sync_object:
        growth_profile = GrowthInvestorProfileFactory(
            investor_company=investor_company)
        investor_company.name = 'SYNC TEST'
        investor_company.save()
        assert mock_sync_object.call_args[1]['args'][
            0] != 'large-investor-profile'
        assert mock_sync_object.call_count == 1  # Updating the company instance

    with pytest.raises(NotFoundError):
        assert _get_es_document(setup_es, growth_profile.id) is None