Skip to content

Commit

Permalink
Add test_engines_plotly_reporter_draw_history_state_chart.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wwakabobik committed Aug 30, 2024
1 parent 2f88ebb commit bfa4b8b
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 2 deletions.
4 changes: 2 additions & 2 deletions testrail_api_reporter/engines/plotly_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = (
Expand Down
121 changes: 121 additions & 0 deletions tests/engines/test_engines_plotly_reporter_draw_history_state_chart.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bfa4b8b

Please sign in to comment.