def test_indexed_doc(es):
    """Test the ES data of an Large investor profile."""
    investor_company = CompanyFactory()

    large_investor_profile = LargeCapitalInvestorProfileFactory(
        investor_company=investor_company,
    )

    doc = ESLargeInvestorProfile.es_document(large_investor_profile)
    elasticsearch.bulk(actions=(doc, ), chunk_size=1)

    es.indices.refresh()

    indexed_large_investor_profile = es.get(
        index=ESLargeInvestorProfile.get_write_index(),
        doc_type=LargeInvestorProfileSearchApp.name,
        id=large_investor_profile.pk,
    )

    assert indexed_large_investor_profile['_id'] == str(large_investor_profile.pk)
    assert indexed_large_investor_profile['_source'] == {
        '_document_type': LargeInvestorProfileSearchApp.name,
        'id': str(large_investor_profile.pk),
        'asset_classes_of_interest': [],
        'country_of_origin': {
            'id': str(large_investor_profile.country_of_origin.pk),
            'name': str(large_investor_profile.country_of_origin.name),
        },
        'investor_company': {
            'id': str(investor_company.pk),
            'name': str(investor_company.name),
            'trading_names': investor_company.trading_names,
        },
        'created_by': None,
        'investor_type': None,
        'required_checks_conducted': None,
        'deal_ticket_sizes': [],
        'investment_types': [],
        'minimum_return_rate': None,
        'time_horizons': [],
        'restrictions': [],
        'construction_risks': [],
        'minimum_equity_percentage': None,
        'desired_deal_roles': [],
        'uk_region_locations': [],
        'other_countries_being_considered': [],
        'investable_capital': None,
        'investor_description': '',
        'created_on': '2019-01-01T00:00:00+00:00',
        'notes_on_locations': '',
        'global_assets_under_management': None,
        'modified_on': '2019-01-01T00:00:00+00:00',
    }
Esempio n. 2
0
    def test_large_investor_profile_dbmodel_to_dict(self, es):
        """Tests conversion of db model to dict."""
        large_investor_profile = LargeCapitalInvestorProfileFactory()

        result = ESLargeInvestorProfile.db_object_to_dict(
            large_investor_profile)
        keys = {
            'asset_classes_of_interest',
            'construction_risks',
            'country_of_origin',
            'created_by',
            'created_on',
            'deal_ticket_sizes',
            'desired_deal_roles',
            'global_assets_under_management',
            'id',
            'investable_capital',
            'investment_types',
            'investor_company',
            'investor_description',
            'investor_type',
            'minimum_equity_percentage',
            'minimum_return_rate',
            'modified_on',
            'notes_on_locations',
            'other_countries_being_considered',
            'required_checks_conducted',
            'restrictions',
            'time_horizons',
            'uk_region_locations',
        }
        assert set(result.keys()) == keys
Esempio n. 3
0
    def test_investment_project_dbmodels_to_es_documents(self, es):
        """Tests conversion of db models to Elasticsearch documents."""
        large_profiles = LargeCapitalInvestorProfileFactory.create_batch(2)

        result = ESLargeInvestorProfile.db_objects_to_es_documents(
            large_profiles)

        assert len(list(result)) == len(large_profiles)