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

Replace print with logger #75

Merged
merged 59 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b1ea793
Replace print with logger
wwakabobik Oct 10, 2023
07ed7b2
Merge branch 'master' of github.com:wwakabobik/testrail_api_reporter …
wwakabobik Nov 1, 2023
012e259
Merge branch 'master' of github.com:wwakabobik/testrail_api_reporter …
wwakabobik Jan 16, 2024
61f4625
Merge branch 'master' of github.com:wwakabobik/testrail_api_reporter …
wwakabobik Jan 16, 2024
35fd93c
Merge branch 'master' of github.com:wwakabobik/testrail_api_reporter …
wwakabobik Jan 30, 2024
5aba820
Update to 1.4.10
wwakabobik Mar 12, 2024
cd26d29
Update to 1.4.11
wwakabobik Mar 12, 2024
85783db
Update to 1.4.11
wwakabobik Mar 12, 2024
a53f87b
Update to 1.4.11
wwakabobik Mar 12, 2024
cb9c5ea
Update to 1.4.11
wwakabobik Mar 12, 2024
6014d5d
Update to 1.4.11
wwakabobik Mar 12, 2024
3e40db3
Update to 1.4.11
wwakabobik Mar 12, 2024
a9d4f2e
Update to 1.4.11
wwakabobik Mar 12, 2024
9225b41
Update to 1.4.11
wwakabobik Mar 27, 2024
905fb75
Update to 1.4.11
wwakabobik Mar 27, 2024
5efcc7b
Re-sort requirements.txt
wwakabobik Aug 19, 2024
cfa0860
Update GA and README.md
wwakabobik Aug 19, 2024
55b9741
Update GA and README.md
wwakabobik Aug 19, 2024
e6306dd
Update GA and README.md
wwakabobik Aug 19, 2024
2bd3be4
Update GA and README.md
wwakabobik Aug 19, 2024
cee07b6
Rearrange project structure, add tests for upload_image
wwakabobik Aug 19, 2024
a223c00
Rearrange project structure, add tests for upload_image
wwakabobik Aug 19, 2024
e4b2809
Rearrange project structure, add tests for upload_image
wwakabobik Aug 19, 2024
ff2c5aa
Fix linters
wwakabobik Aug 19, 2024
39f838a
Fix linters
wwakabobik Aug 19, 2024
abdfbc0
Fix linters
wwakabobik Aug 19, 2024
9c34087
Fix linters
wwakabobik Aug 19, 2024
862ab68
Fix linters
wwakabobik Aug 19, 2024
62a5b6d
Fix linters
wwakabobik Aug 19, 2024
94e94be
Fix linters
wwakabobik Aug 19, 2024
7915a6a
Add test_reporter_utils_delete_file.py
wwakabobik Aug 20, 2024
6e87fe5
Add test_reporter_utils_delete_file.py
wwakabobik Aug 20, 2024
fd0a0f2
100% cover "reporter_utils"
wwakabobik Aug 20, 2024
a3c5d2e
100% cover "reporter_utils"
wwakabobik Aug 20, 2024
5e98c3e
100% cover "reporter_utils"
wwakabobik Aug 20, 2024
65b4190
100% cover "reporter_utils"
wwakabobik Aug 20, 2024
ae97ade
Add explicit coding (utf-8)
wwakabobik Aug 20, 2024
c66bbe5
Added test_reporter_utils_case_stat.py
wwakabobik Aug 29, 2024
3674308
Added test_reporter_utils_csv_parser_*.py
wwakabobik Aug 29, 2024
86becd9
Added test_reporter_utils_logger_config.py
wwakabobik Aug 29, 2024
f5e64ae
Added test_engines_plotly_reporter_draw_automation_state_report.py
wwakabobik Aug 30, 2024
9e64152
Added test_engines_plotly_reporter_draw_test_case_by_area.py
wwakabobik Aug 30, 2024
ea283cb
Added test_engines_plotly_reporter_draw_test_case_by_priority.py.py
wwakabobik Aug 30, 2024
2f88ebb
Variate more params for draw functions
wwakabobik Aug 30, 2024
bfa4b8b
Add test_engines_plotly_reporter_draw_history_state_chart.py
wwakabobik Aug 30, 2024
965c8b9
Fix test against missed filename
wwakabobik Aug 30, 2024
6c247c2
Linter fixes
wwakabobik Aug 30, 2024
8b50e52
Linter fixes
wwakabobik Aug 30, 2024
44a1c63
Linter fixes
wwakabobik Aug 30, 2024
7d3510b
Linter fixes
wwakabobik Aug 30, 2024
331153c
Add explicit coding (utf-8)
wwakabobik Aug 30, 2024
736c445
Linter fixes
wwakabobik Aug 30, 2024
3a1d559
Linter fixes
wwakabobik Aug 30, 2024
d299bee
Linter fixes
wwakabobik Aug 30, 2024
e218cdd
Linter fixes
wwakabobik Aug 30, 2024
6921143
Linter fixes
wwakabobik Aug 30, 2024
a80d528
Linter fixes
wwakabobik Aug 30, 2024
4105b4b
Merge branch 'master' of github.com:wwakabobik/testrail_api_reporter …
wwakabobik Aug 30, 2024
acda84c
Fix readme file
wwakabobik Aug 30, 2024
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
Prev Previous commit
Next Next commit
Linter fixes
  • Loading branch information
wwakabobik committed Aug 30, 2024
commit 6c247c2e7e57d14b6cc0f498de5286e90f4a26cd
1 change: 1 addition & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
pip install types-requests
pip install pytest
pip install faker
pip install pillow
- name: Add 'testrail_api_reporter' to PYTHONPATH
run: echo "PYTHONPATH=$PYTHONPATH:$(pwd)/testrail_api_reporter:." >> $GITHUB_ENV
- name: Analysing the code with pylint
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/master_linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
pip install types-requests
pip install pytest
pip install faker
pip install pillow
- name: Add 'testrail_api_reporter' to PYTHONPATH
run: echo "PYTHONPATH=$PYTHONPATH:$(pwd)/testrail_api_reporter:." >> $GITHUB_ENV
- name: Analysing the code with pylint
Expand Down
4 changes: 3 additions & 1 deletion testrail_api_reporter/engines/plotly_reporter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
""" Confluence sender module """

from typing import Optional

import plotly

from ..utils.csv_parser import CSVParser
Expand Down Expand Up @@ -231,7 +233,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 | None = None,
chart_name: Optional[str] = None,
history_data=None,
filename=None,
trace1_decor=None,
Expand Down
12 changes: 6 additions & 6 deletions testrail_api_reporter/utils/reporter_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
""" This module contains service functions for reporter """
from logging import Logger
from os import popen
from typing import Optional, Any
from typing import Optional, Any, Union

import requests


def format_error(error: list | str | Exception) -> str:
def format_error(error: Union[list, str, Exception]) -> str:
"""
Service function for parse errors to human-readable format

Expand Down Expand Up @@ -58,7 +58,7 @@ def delete_file(filename: str, debug: bool = True, logger: Optional[Logger] = No
logger.debug(f"Removed {filename}")


def zip_file(filename: str, suffix: str | None = None, debug: bool = True, logger: Optional[Logger] = None) -> str:
def zip_file(filename: str, suffix: Optional[str] = None, debug: bool = True, logger: Optional[Logger] = None) -> str:
"""
Service function to ZIP file

Expand All @@ -79,8 +79,8 @@ def zip_file(filename: str, suffix: str | None = None, debug: bool = True, logge


def check_captions_and_files(
captions: list | None | Any, files: list, debug: bool = True, logger: Optional[Logger] = None
) -> list | None:
captions: Union[list, None, Any], files: list, debug: bool = True, logger: Optional[Logger] = None
) -> Optional[list]:
"""
Service function to check captions and file lists

Expand Down Expand Up @@ -114,7 +114,7 @@ def init_get_cases_process() -> tuple[list, bool, None, None, int]:

:return: cases_list, first_run, criteria, response, retry
"""
cases_list = []
cases_list: list = []
first_run = True
criteria = None
response = None
Expand Down
17 changes: 9 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from os import path, remove
from random import randint
from typing import Generator

import pytest
from faker import Faker
Expand All @@ -14,17 +15,16 @@
from testrail_api_reporter.utils.case_stat import CaseStat # pylint: disable=import-error,no-name-in-module



fake = Faker()


@pytest.fixture
def create_test_file() -> str:
def create_test_file() -> Generator:
"""
Fixture to create random test file

:return: filename
:rtype: str
:rtype: Generator
"""
test_file = f"not_existing_{fake.file_name()}"
with open(test_file, "w", encoding="utf-8") as file:
Expand Down Expand Up @@ -65,7 +65,7 @@ def case_stat() -> CaseStat:


@pytest.fixture
def case_stat_random(case_stat, random_stat):
def case_stat_random(case_stat, random_stat): # pylint: disable=redefined-outer-name
"""
Fixture to return object of CaseStat

Expand All @@ -81,12 +81,12 @@ def case_stat_random(case_stat, random_stat):


@pytest.fixture
def csv_file() -> str:
def csv_file() -> Generator:
"""
Fixture to create random test file

:return: filename
:rtype: str
:rtype: Generator
"""
test_file = f"not_existing_{fake.file_name(extension='csv')}"
with open(test_file, "w", encoding="utf-8") as file:
Expand Down Expand Up @@ -155,7 +155,7 @@ def random_type_platforms() -> list[dict]:


@pytest.fixture
def random_plotly_reporter(random_type_platforms) -> PlotlyReporter:
def random_plotly_reporter(random_type_platforms) -> PlotlyReporter: # pylint: disable=redefined-outer-name
"""
Returns PlotlyReporter object with random type platforms

Expand All @@ -167,7 +167,8 @@ def random_plotly_reporter(random_type_platforms) -> PlotlyReporter:

@pytest.fixture()
def random_rgb():
"""Returns fixture to get rgb in string format """
"""Returns fixture to get rgb in string format"""

def get_rgb() -> str:
"""
Returns rgb in string format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@ def random_expected_image(case_stat):
case_stat.not_automated = 27205
case_stat.not_applicable = 10092
return {"filename": f"{getcwd()}/tests/assets/expected_automation_state.png", "data": [case_stat]}
else:
case_stat.set_name("Automation State")
return {"filename": f"{getcwd()}/tests/assets/expected_automation_state_empty.png", "data": [case_stat]}
case_stat.set_name("Automation State")
return {"filename": f"{getcwd()}/tests/assets/expected_automation_state_empty.png", "data": [case_stat]}


def test_draw_automation_state_report_no_reports(caplog, random_plotly_reporter):
def test_draw_automation_state_report_no_reports(random_plotly_reporter):
"""
Init PlotlyReporter and call draw_automation_state_report without reports should raise ValueError

:param caplog: caplog fixture
:param random_plotly_reporter: fixture returns PlotlyReporter
"""
with pytest.raises(ValueError, match="No TestRail reports are provided, report aborted!"):
Expand All @@ -47,11 +45,10 @@ def test_draw_automation_state_report_no_reports(caplog, random_plotly_reporter)
)


def test_draw_automation_state_report_no_filename(caplog, random_plotly_reporter):
def test_draw_automation_state_report_no_filename(random_plotly_reporter):
"""
Init PlotlyReporter and call draw_automation_state_report 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!"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@
fake = Faker()


def test_draw_history_state_chart_no_chart_name(caplog, random_plotly_reporter):
def test_draw_history_state_chart_no_chart_name(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):
def test_draw_history_state_chart_no_filename(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
"""
fake_name = fake.name()
Expand All @@ -32,87 +30,79 @@ def test_draw_history_state_chart_no_filename(caplog, random_plotly_reporter):
random_plotly_reporter.draw_history_state_chart(chart_name=fake_name)


def test_draw_history_state_chart_creates_file(caplog, random_plotly_reporter):
def test_draw_history_state_chart_creates_file(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):
def test_draw_history_state_chart_creates_correct_image(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):
def test_draw_history_state_chart_default_history_data(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):
def test_draw_history_state_chart_custom_history_data(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):
def test_draw_history_state_chart_trace1_decor(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):
def test_draw_history_state_chart_trace2_decor(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):
def test_draw_history_state_chart_reverse_traces(random_plotly_reporter, compare_image):
"""
Init PlotlyReporter and call draw_history_state_chart with reverced traces
Init PlotlyReporter and call draw_history_state_chart with reversed 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):
def test_draw_history_state_chart_filename_pattern(random_plotly_reporter, compare_image):
"""
Init PlotlyReporter and call draw_history_state_chart with reverced traces
Init PlotlyReporter and call draw_history_state_chart with filename pattern

:param caplog: caplog fixture
:param random_plotly_reporter: fixture returns PlotlyReporter
:param compare_image: fixture, returns function to compare images
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ def random_expected_image(case_stat):
}


def test_draw_test_case_by_area_no_cases(caplog, random_plotly_reporter):
def test_draw_test_case_by_area_no_cases(random_plotly_reporter):
"""
Init PlotlyReporter and call draw_test_case_by_area without cases should raise ValueError

:param caplog: caplog fixture
:param random_plotly_reporter: fixture returns PlotlyReporter
"""
with pytest.raises(ValueError, match="No TestRail cases are provided, report aborted!"):
Expand All @@ -54,22 +53,20 @@ def test_draw_test_case_by_area_no_cases(caplog, random_plotly_reporter):
)


def test_draw_test_case_by_area_no_filename(caplog, random_plotly_reporter):
def test_draw_test_case_by_area_no_filename(random_plotly_reporter):
"""
Init PlotlyReporter and call draw_test_case_by_area 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()])


def test_draw_test_case_by_area_creates_file(caplog, case_stat, case_stat_random, random_plotly_reporter):
def test_draw_test_case_by_area_creates_file(case_stat, case_stat_random, random_plotly_reporter):
"""
Init PlotlyReporter and call draw_test_case_by_area with valid parameters should create file

:param caplog: caplog fixture
:param case_stat: fixture returns empty CaseStat object
:param case_stat_random: fixture returns filled with random data CaseStat object
:param random_plotly_reporter: fixture returns PlotlyReporter
Expand All @@ -86,11 +83,10 @@ def test_draw_test_case_by_area_creates_file(caplog, case_stat, case_stat_random
remove(filename)


def test_draw_test_case_by_area_creates_correct_image(caplog, random_expected_image, compare_image):
def test_draw_test_case_by_area_creates_correct_image(random_expected_image, compare_image):
"""
Init PlotlyReporter and call draw_test_case_by_area with valid parameters should create correct image

:param caplog: caplog fixture
:param random_expected_image: fixture, returns any of possible expected cases
:param compare_image: fixture, returns function to compare images
"""
Expand All @@ -105,11 +101,10 @@ def test_draw_test_case_by_area_creates_correct_image(caplog, random_expected_im
remove(filename)


def test_draw_test_case_by_area_changes_ar_colors(caplog, random_expected_image, compare_image, random_rgb):
def test_draw_test_case_by_area_changes_ar_colors(random_expected_image, compare_image, random_rgb):
"""
Init PlotlyReporter and call draw_test_case_by_area with valid parameters and ar_colors should create correct image

:param caplog: caplog fixture
:param random_expected_image: fixture, returns any of possible expected cases
:param compare_image: fixture, returns function to compare images
:param random_rgb: fixture, returns random rgb in string format
Expand All @@ -128,11 +123,10 @@ def test_draw_test_case_by_area_changes_ar_colors(caplog, random_expected_image,
remove(filename)


def test_draw_test_case_by_area_changes_lines(caplog, random_expected_image, compare_image, random_rgb):
def test_draw_test_case_by_area_changes_lines(random_expected_image, compare_image, random_rgb):
"""
Init PlotlyReporter and call draw_test_case_by_area with valid parameters and ar_colors should create correct image

:param caplog: caplog fixture
:param random_expected_image: fixture, returns any of possible expected cases
:param compare_image: fixture, returns function to compare images
:param random_rgb: fixture, returns random rgb in string format
Expand Down
Loading
Loading