Skip to content

Commit

Permalink
fix: black
Browse files Browse the repository at this point in the history
  • Loading branch information
mastrolube committed Feb 17, 2024
1 parent eb68768 commit c32a66d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions test/test_telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def test_load_sessions(mocker):
""" Test if the function returns a list of dictionaries """
"""Test if the function returns a list of dictionaries"""
mock_file_content = sessions_txt
mocker.patch("builtins.open", mock_open(read_data=mock_file_content))
result = TelegramReports.load_sessions("test_user")
Expand All @@ -18,19 +18,19 @@ def test_load_sessions(mocker):


def test_calculate_duration():
""" Test if the function returns a number """
"""Test if the function returns a number"""
result = TelegramReports._calculate_session_duration(sessions_json[0])
assert isinstance(result, int), "Expected an integer"


def test_calculate_duration_not_finisched():
""" Test if the function returns 0 if the session is not finished """
"""Test if the function returns 0 if the session is not finished"""
result = TelegramReports._calculate_session_duration(sessions_json[1])
assert result == 0


def test_daily_summary():
""" Test if the function returns a dictionary and the values are correct """
"""Test if the function returns a dictionary and the values are correct"""
results = TelegramReports.daily_summary(sessions_json)
assert isinstance(results, dict), "Expected a dictionary"
assert results.get("2024-01-01", {}).get("total_likes") == 16, "Expected 16"
Expand All @@ -43,15 +43,18 @@ def test_daily_summary():


def test_daily_summary_no_sessions():
""" Test if the function returns an empty dictionary if no sessions are provided """
"""Test if the function returns an empty dictionary if no sessions are provided"""
results = TelegramReports.daily_summary([])
assert results == {}, "Expected an empty dictionary"


def test_generate_report():
""" Test if the function returns a string """
"""Test if the function returns a string"""
daily_aggregated_data = TelegramReports.daily_summary(sessions_json)
today_data = daily_aggregated_data.get("2024-01-02", {})
last_session = sessions_json[-1]
last_session["duration"] = TelegramReports._calculate_session_duration(last_session)
results = TelegramReports.generate_report("test_user", last_session, today_data, 400, 400)
assert isinstance(results, str), "Expected a string"
results = TelegramReports.generate_report(
"test_user", last_session, today_data, 400, 400
)
assert isinstance(results, str), "Expected a string"

0 comments on commit c32a66d

Please sign in to comment.