@@ -140,6 +140,9 @@ def _stub_plotters(self):
140
140
self .reach_frequency .plot_optimal_frequency ().to_json .return_value = '{}'
141
141
142
142
def _stub_media_summary_plotters (self , media_summary ):
143
+ media_summary .plot_channel_contribution_area_chart ().to_json .return_value = (
144
+ '{}'
145
+ )
143
146
media_summary .plot_contribution_waterfall_chart ().to_json .return_value = (
144
147
'{}'
145
148
)
@@ -152,7 +155,9 @@ def _stub_media_summary_plotters(self, media_summary):
152
155
153
156
def _stub_for_insights (self ):
154
157
self .media_metrics = test_utils .generate_paid_summary_metrics ()
155
- self .media_summary .paid_summary_metrics = self .media_metrics
158
+ self .media_summary .get_paid_summary_metrics = mock .MagicMock (
159
+ return_value = self .media_metrics
160
+ )
156
161
157
162
frequency_data = test_utils .generate_optimal_frequency_data (
158
163
channel_prefix = 'rf_ch' , num_channels = 2
@@ -365,6 +370,12 @@ def test_output_card_static_chart_spec(self, card_spec):
365
370
(
366
371
summary_text .CHANNEL_CONTRIB_CARD_ID ,
367
372
[
373
+ (
374
+ summary_text .CHANNEL_CONTRIB_BY_TIME_CHART_ID ,
375
+ summary_text .CHANNEL_CONTRIB_BY_TIME_CHART_DESCRIPTION .format (
376
+ outcome = c .REVENUE
377
+ ),
378
+ ),
368
379
(
369
380
summary_text .CHANNEL_DRIVERS_CHART_ID ,
370
381
summary_text .CHANNEL_DRIVERS_CHART_DESCRIPTION .format (
@@ -781,6 +792,10 @@ def test_channel_contrib_card_plotters_called(self):
781
792
media_summary .plot_contribution_pie_chart ().to_json .return_value = (
782
793
f'["{ mock_spec_3 } "]'
783
794
)
795
+ mock_spec_4 = 'revenue_area_chart'
796
+ media_summary .plot_channel_contribution_area_chart ().to_json .return_value = (
797
+ f'["{ mock_spec_4 } "]'
798
+ )
784
799
785
800
summary_html_dom = self ._get_output_model_results_summary_html_dom (
786
801
self .summarizer_revenue ,
@@ -789,6 +804,7 @@ def test_channel_contrib_card_plotters_called(self):
789
804
media_summary .plot_contribution_waterfall_chart (),
790
805
media_summary .plot_spend_vs_contribution (),
791
806
media_summary .plot_contribution_pie_chart (),
807
+ media_summary .plot_channel_contribution_area_chart (),
792
808
]:
793
809
mock_plot .to_json .assert_called_once ()
794
810
@@ -812,8 +828,16 @@ def test_channel_contrib_card_plotters_called(self):
812
828
mock_spec_3_exists = any (
813
829
[mock_spec_3 in script_text for script_text in script_texts ]
814
830
)
831
+ mock_spec_4_exists = any (
832
+ [mock_spec_4 in script_text for script_text in script_texts ]
833
+ )
815
834
self .assertTrue (
816
- all ([mock_spec_1_exists , mock_spec_2_exists , mock_spec_3_exists ])
835
+ all ([
836
+ mock_spec_1_exists ,
837
+ mock_spec_2_exists ,
838
+ mock_spec_3_exists ,
839
+ mock_spec_4_exists ,
840
+ ])
817
841
)
818
842
819
843
def test_channel_contrib_card_insights (self ):
@@ -998,7 +1022,7 @@ def test_response_curves_card_insights_multiple_channels(self):
998
1022
media_summary = self .media_summary
999
1023
reach_frequency = self .reach_frequency
1000
1024
1001
- media_summary .paid_summary_metrics .spend .data = [
1025
+ media_summary .get_paid_summary_metrics () .spend .data = [
1002
1026
100 , # 'ch_0'
1003
1027
200 , # 'ch_1'
1004
1028
300 , # 'ch_2'
0 commit comments