diff --git a/testrail_api_reporter/engines/plotly_reporter.py b/testrail_api_reporter/engines/plotly_reporter.py index ae89d70..c1bdd30 100644 --- a/testrail_api_reporter/engines/plotly_reporter.py +++ b/testrail_api_reporter/engines/plotly_reporter.py @@ -231,7 +231,7 @@ def draw_test_case_by_area(self, filename=None, cases=None, ar_colors=None, line def draw_history_state_chart( self, - chart_name: str, + chart_name: str | None = None, history_data=None, filename=None, trace1_decor=None, @@ -257,7 +257,7 @@ def draw_history_state_chart( :param reverse_traces: reverse traces order :return: none """ - if not chart_name: + if chart_name is None: raise ValueError("No chart name is provided, report aborted!") filename = filename if filename else f"{filename_pattern}_{chart_name.replace(' ', '_')}.csv" trace1_decor = ( diff --git a/tests/engines/test_engines_plotly_reporter_draw_history_state_chart.py b/tests/engines/test_engines_plotly_reporter_draw_history_state_chart.py new file mode 100644 index 0000000..11d99b4 --- /dev/null +++ b/tests/engines/test_engines_plotly_reporter_draw_history_state_chart.py @@ -0,0 +1,121 @@ +# -*- coding: utf-8 -*- +"""Tests for plotly_reporter module, the PlotlyReporter clas, draw_history_state_chart method""" + +from os import path, remove, getcwd +from random import choice, randint + +import pytest +from faker import Faker + + +fake = Faker() + + +def test_draw_history_state_chart_no_chart_name(caplog, random_plotly_reporter): + """ + Init PlotlyReporter and call draw_history_state_chart without chart_name should raise ValueError + + :param caplog: caplog fixture + :param random_plotly_reporter: fixture returns PlotlyReporter + """ + with pytest.raises(ValueError, match="No chart name is provided, report aborted!"): + random_plotly_reporter.draw_history_state_chart() # type: ignore + + +def test_draw_history_state_chart_no_filename(caplog, random_plotly_reporter): + """ + Init PlotlyReporter and call draw_test_case_by_priority without filename should raise ValueError + + :param caplog: caplog fixture + :param random_plotly_reporter: fixture returns PlotlyReporter + """ + with pytest.raises(ValueError, match="No output filename is provided, report aborted!"): + random_plotly_reporter.draw_test_case_by_area(cases=[fake.pydict()]) + random_plotly_reporter.draw_history_state_chart() + + +def test_draw_history_state_chart_creates_file(caplog, random_plotly_reporter): + """ + Init PlotlyReporter and call draw_history_state_chart with valid parameters should create file + + :param caplog: caplog fixture + :param random_plotly_reporter: fixture returns PlotlyReporter + """ + raise NotImplementedError + + +def test_draw_history_state_chart_creates_correct_image(caplog, random_plotly_reporter, compare_image): + """ + Init PlotlyReporter and call draw_history_state_chart with valid parameters should create valid image + + :param caplog: caplog fixture + :param random_plotly_reporter: fixture returns PlotlyReporter + :param compare_image: fixture, returns function to compare images + """ + raise NotImplementedError + + +def test_draw_history_state_chart_default_history_data(caplog, random_plotly_reporter, compare_image): + """ + Init PlotlyReporter and call draw_history_state_chart with default history data + + :param caplog: caplog fixture + :param random_plotly_reporter: fixture returns PlotlyReporter + :param compare_image: fixture, returns function to compare images + """ + raise NotImplementedError + + +def test_draw_history_state_chart_custom_history_data(caplog, random_plotly_reporter, compare_image): + """ + Init PlotlyReporter and call draw_history_state_chart with custom history data + + :param caplog: caplog fixture + :param random_plotly_reporter: fixture returns PlotlyReporter + :param compare_image: fixture, returns function to compare images + """ + raise NotImplementedError + + +def test_draw_history_state_chart_trace1_decor(caplog, random_plotly_reporter, compare_image): + """ + Init PlotlyReporter and call draw_history_state_chart with custom trace1 decor + + :param caplog: caplog fixture + :param random_plotly_reporter: fixture returns PlotlyReporter + :param compare_image: fixture, returns function to compare images + """ + raise NotImplementedError + + +def test_draw_history_state_chart_trace2_decor(caplog, random_plotly_reporter, compare_image): + """ + Init PlotlyReporter and call draw_history_state_chart with custom trace2 decor + + :param caplog: caplog fixture + :param random_plotly_reporter: fixture returns PlotlyReporter + :param compare_image: fixture, returns function to compare images + """ + raise NotImplementedError + + +def test_draw_history_state_chart_reverse_traces(caplog, random_plotly_reporter, compare_image): + """ + Init PlotlyReporter and call draw_history_state_chart with reverced traces + + :param caplog: caplog fixture + :param random_plotly_reporter: fixture returns PlotlyReporter + :param compare_image: fixture, returns function to compare images + """ + raise NotImplementedError + + +def test_draw_history_state_chart_filename_pattern(caplog, random_plotly_reporter, compare_image): + """ + Init PlotlyReporter and call draw_history_state_chart with reverced traces + + :param caplog: caplog fixture + :param random_plotly_reporter: fixture returns PlotlyReporter + :param compare_image: fixture, returns function to compare images + """ + raise NotImplementedError