Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes average_salary serialization. #260

Merged
merged 1 commit into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions datahub/search/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ class InvestmentProject(DocType, MapDBModelToDict):
'id': String(index='not_analyzed'),
'name': String()
}) # Sector
average_salary = Nested(properties={
'id': String(index='not_analyzed'),
'name': String()
}) # AverageSalary

MAPPINGS = {
'id': str,
Expand All @@ -374,6 +378,7 @@ class InvestmentProject(DocType, MapDBModelToDict):
'referral_source_adviser': _contact_dict,
'sector': _id_name_dict,
'project_code': str,
'average_salary': _id_name_dict,
}

IGNORED_FIELDS = (
Expand Down
7 changes: 6 additions & 1 deletion datahub/search/test/test_signals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest

from datahub.company.test.factories import CompanyFactory, ContactFactory
from datahub.core import constants
from datahub.investment.test.factories import InvestmentProjectFactory
from datahub.search import elasticsearch

Expand Down Expand Up @@ -96,9 +97,13 @@ def test_investment_project_auto_updates_to_es(setup_data, post_save_handlers):
"""Tests if investment project gets synced to Elasticsearch."""
test_name = 'very_hard_to_find_project'
project = InvestmentProjectFactory(
name=test_name
name=test_name,
total_investment=999,
number_new_jobs=100,
average_salary_id=constants.SalaryRange.below_25000.value.id
)
project.save()
project = InvestmentProjectFactory()

new_test_name = 'even_harder_to_find_investment_project'
project.name = new_test_name
Expand Down