Skip to content

Commit

Permalink
Linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wwakabobik committed Aug 30, 2024
1 parent 6c247c2 commit 8b50e52
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
9 changes: 4 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

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

import pytest
from faker import Faker
Expand All @@ -19,12 +18,12 @@


@pytest.fixture
def create_test_file() -> Generator:
def create_test_file():
"""
Fixture to create random test file
:return: filename
:rtype: Generator
:rtype: str (generator)
"""
test_file = f"not_existing_{fake.file_name()}"
with open(test_file, "w", encoding="utf-8") as file:
Expand Down Expand Up @@ -81,12 +80,12 @@ def case_stat_random(case_stat, random_stat): # pylint: disable=redefined-outer


@pytest.fixture
def csv_file() -> Generator:
def csv_file():
"""
Fixture to create random test file
:return: filename
:rtype: Generator
:rtype: str (generator)
"""
test_file = f"not_existing_{fake.file_name(extension='csv')}"
with open(test_file, "w", encoding="utf-8") as file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ def test_draw_automation_state_report_no_filename(random_plotly_reporter):
random_plotly_reporter.draw_automation_state_report(reports=[fake.pydict()])


def test_draw_automation_state_report_creates_file(caplog, case_stat, case_stat_random, random_plotly_reporter):
def test_draw_automation_state_report_creates_file(case_stat, case_stat_random, random_plotly_reporter):
"""
Init PlotlyReporter and call draw_automation_state_report 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 @@ -75,11 +74,12 @@ def test_draw_automation_state_report_creates_file(caplog, case_stat, case_stat_
remove(filename)


def test_draw_automation_state_report_creates_correct_image(caplog, random_expected_image, compare_image):
def test_draw_automation_state_report_creates_correct_image(
random_expected_image, compare_image # pylint: disable=W0621
):
"""
Init PlotlyReporter and call draw_automation_state_report 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 @@ -94,11 +94,12 @@ def test_draw_automation_state_report_creates_correct_image(caplog, random_expec
remove(filename)


def test_draw_automation_state_report_changes_state_markers(caplog, random_expected_image, compare_image, random_rgb):
def test_draw_automation_state_report_changes_state_markers(
random_expected_image, compare_image, random_rgb # pylint: disable=W0621
):
"""
Init PlotlyReporter and call draw_automation_state_report with valid parameters and state_markers should create correct image
Init PlotlyReporter and call draw_automation_state_report with state_markers should create different 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
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_draw_test_case_by_area_creates_file(case_stat, case_stat_random, random
remove(filename)


def test_draw_test_case_by_area_creates_correct_image(random_expected_image, compare_image):
def test_draw_test_case_by_area_creates_correct_image(random_expected_image, compare_image): # pylint: disable=W0621
"""
Init PlotlyReporter and call draw_test_case_by_area with valid parameters should create correct image
Expand All @@ -101,7 +101,9 @@ def test_draw_test_case_by_area_creates_correct_image(random_expected_image, com
remove(filename)


def test_draw_test_case_by_area_changes_ar_colors(random_expected_image, compare_image, random_rgb):
def test_draw_test_case_by_area_changes_ar_colors(
random_expected_image, compare_image, random_rgb # pylint: disable=W0621
):
"""
Init PlotlyReporter and call draw_test_case_by_area with valid parameters and ar_colors should create correct image
Expand All @@ -123,7 +125,9 @@ def test_draw_test_case_by_area_changes_ar_colors(random_expected_image, compare
remove(filename)


def test_draw_test_case_by_area_changes_lines(random_expected_image, compare_image, random_rgb):
def test_draw_test_case_by_area_changes_lines(
random_expected_image, compare_image, random_rgb # pylint: disable=W0621
):
"""
Init PlotlyReporter and call draw_test_case_by_area with valid parameters and ar_colors should create correct image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def test_load_history_data(csv_file, random_stat):
year = fake.year()
month = fake.month()
day_of_month = fake.day_of_month()
with open(csv_file, "w", encoding="utf-8") as f:
f.write(f"{year},{month},{day_of_month},{total},{automated},{not_automated},{not_applicable}\n")
with open(csv_file, "w", encoding="utf-8") as writable_file:
writable_file.write(f"{year},{month},{day_of_month},{total},{automated},{not_automated},{not_applicable}\n")

data = parser.load_history_data()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def test_save_history_data(csv_file, random_stat, case_stat):

parser.save_history_data(report=case_stat)

with open(csv_file, "r", encoding="utf-8") as f:
data = f.read()
with open(csv_file, "r", encoding="utf-8") as readable_file:
data = readable_file.read()
assert data == (
f"{datetime.today().strftime('%Y')},"
f"{datetime.today().strftime('%m')},"
Expand Down Expand Up @@ -55,6 +55,6 @@ def test_save_history_data_already_stored(csv_file, case_stat_random):
parser.save_history_data(report=case_stat_random)
parser.save_history_data(report=case_stat_random)

with open(csv_file, "r") as f:
data = f.read()
with open(csv_file, "r", encoding="utf-8") as readable_file:
data = readable_file.read()
assert data.count("\n") == 1
4 changes: 2 additions & 2 deletions tests/utils/test_reporter_utils_logger_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def test_setup_logger_default_level(caplog):

message = str(fake.random_letters(randint(1, 10))) * randint(1, 10)
logger.debug(message)
with open(log_file, "r", encoding="utf-8") as f:
assert message in f.read()
with open(log_file, "r", encoding="utf-8") as readable_file:
assert message in readable_file.read()
assert message in caplog.text
finally:
if path.exists(log_file):
Expand Down

0 comments on commit 8b50e52

Please sign in to comment.