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

Task/cdd 2220 update alt text for tend line none #1764

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion metrics/domain/models/plots_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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. "

Expand Down
21 changes: 21 additions & 0 deletions tests/unit/metrics/domain/models/test_plots_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down
Loading