|
1 | 1 | import pytest
|
| 2 | +import pytz |
2 | 3 |
|
3 | 4 | from datahub.company_activity.tests.factories import GreatExportEnquiryFactory
|
4 | 5 | from datahub.company_referral.test.factories import CompanyReferralFactory
|
@@ -59,6 +60,46 @@ def test_activity_investment_dict():
|
59 | 60 | assert result['investment_type']['id'] == str(
|
60 | 61 | investment.investment_type_id)
|
61 | 62 | assert result['estimated_land_date'] == investment.estimated_land_date
|
| 63 | + assert result['eyb_leads'] == [] |
| 64 | + |
| 65 | + |
| 66 | +def assert_eyb_lead_in_result_list(eyb_lead, result_list): |
| 67 | + assert { |
| 68 | + 'id': str(eyb_lead.id), |
| 69 | + 'company_name': eyb_lead.company_name, |
| 70 | + 'created_on': eyb_lead.created_on, |
| 71 | + 'triage_created': eyb_lead.triage_created.replace(tzinfo=pytz.UTC), |
| 72 | + 'is_high_value': eyb_lead.is_high_value, |
| 73 | + } in result_list |
| 74 | + |
| 75 | + |
| 76 | +def test_activity_investment_with_eyb_leads_dict(): |
| 77 | + obj = None |
| 78 | + result = dict_utils.activity_investment_dict(obj) |
| 79 | + assert result is None |
| 80 | + |
| 81 | + investment = InvestmentProjectFactory() |
| 82 | + eyb_leads_is_high_value = EYBLeadFactory( |
| 83 | + investment_projects=[investment.id], |
| 84 | + is_high_value=True, |
| 85 | + ) |
| 86 | + eyb_leads_is_not_high_value = EYBLeadFactory( |
| 87 | + investment_projects=[investment.id], |
| 88 | + is_high_value=False, |
| 89 | + ) |
| 90 | + eyb_leads_is_not_high_value = EYBLeadFactory( |
| 91 | + investment_projects=[investment.id], |
| 92 | + is_high_value=None, |
| 93 | + ) |
| 94 | + result = dict_utils.activity_investment_dict(investment) |
| 95 | + |
| 96 | + assert result['id'] == str(investment.id) |
| 97 | + assert result['created_by']['id'] == str(investment.created_by_id) |
| 98 | + assert result['investment_type']['id'] == str( |
| 99 | + investment.investment_type_id) |
| 100 | + assert result['estimated_land_date'] == investment.estimated_land_date |
| 101 | + assert_eyb_lead_in_result_list(eyb_leads_is_high_value, result['eyb_leads']) |
| 102 | + assert_eyb_lead_in_result_list(eyb_leads_is_not_high_value, result['eyb_leads']) |
62 | 103 |
|
63 | 104 |
|
64 | 105 | def test_activity_order_dict():
|
|
0 commit comments