diff --git a/metrics/domain/models/plots_text.py b/metrics/domain/models/plots_text.py index c14adea8a..cab80f4f1 100644 --- a/metrics/domain/models/plots_text.py +++ b/metrics/domain/models/plots_text.py @@ -347,6 +347,8 @@ def _get_trend_direction(cls, *, plot_parameters: PlotParameters) -> str: return "positive" case RGBAChartLineColours.TREND_LINE_NEUTRAL.name: return "neutral" + case _: + return "none" def _describe_plot_type(self, *, plot_parameters: PlotParameters) -> str: line_type: str = self._get_line_type_or_default(plot_parameters=plot_parameters) @@ -357,7 +359,12 @@ def _describe_plot_type(self, *, plot_parameters: PlotParameters) -> str: if self._plot_is_simplified_chart(plot_parameters=plot_parameters): trend_type: str = self._get_trend_direction(plot_parameters=plot_parameters) - return f"This is a {line_type} {plot_type} chart, showing a {trend_type} trend in the data. " + plot_description = f"This is a {line_type} {plot_type} chart, " + + if trend_type != "none": + plot_description += f"showing a {trend_type} trend in the data. " + + return plot_description return f"This is a {line_colour} {line_type} {plot_type} plot. " diff --git a/tests/unit/metrics/domain/models/test_plots_text.py b/tests/unit/metrics/domain/models/test_plots_text.py index a73bf7991..f0b4bf355 100644 --- a/tests/unit/metrics/domain/models/test_plots_text.py +++ b/tests/unit/metrics/domain/models/test_plots_text.py @@ -150,6 +150,27 @@ def test_returns_correct_trend_type_when_line_colour_provided_is_for_trend_line( ) assert expected_text_about_parameters in text + def test_returns_no_trend_type_when_line_colour_is_trend_line_none( + self, + fake_plot_data: PlotData, + ): + """ + Given a valid plot where the `line_colour` that is not a `TREND_LINE` colour + When the `construct_text()` method is called + Then no trend type is returned in the response. + """ + fake_plot_data.parameters.line_colour = "COLOUR_1_DARK_BLUE" + fake_plot_data.parameters.line_type = "SOLID" + fake_plot_data.parameters.chart_type = ChartTypes.line_single_simplified.value + plots_text = PlotsText(plots_data=[fake_plot_data]) + + # When + text: str = plots_text.construct_text() + + # Then + expected_text_about_parameters = f"This is a solid line chart," + assert expected_text_about_parameters in text + def test_returns_correct_text_about_parameters_for_multiple_plots( self, fake_plot_data: PlotData ):