From 83e02e447b3772734743c3f3d4b8dbf11c2abb48 Mon Sep 17 00:00:00 2001 From: Nicconike <38905025+Nicconike@users.noreply.github.com> Date: Mon, 15 Jul 2024 00:37:55 +0530 Subject: [PATCH] test: Improve codecov for main.py --- README.md | 2 +- tests/test_main.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 346b713..886aafd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Steam Stats](https://github.com/Nicconike/Steam-Stats/actions/workflows/steam-stats.yml/badge.svg)](https://github.com/Nicconike/Steam-Stats/actions/workflows/steam-stats.yml) [![Release](https://github.com/Nicconike/Steam-Stats/actions/workflows/release.yml/badge.svg)](https://github.com/Nicconike/Steam-Stats/actions/workflows/release.yml) [![CodeQL & Pylint](https://github.com/Nicconike/Steam-Stats/actions/workflows/codeql.yml/badge.svg)](https://github.com/Nicconike/Steam-Stats/actions/workflows/codeql.yml) -[![Bandit](https://github.com/Nicconike/Steam-Stats/actions/workflows/sast.yml/badge.svg)](https://github.com/Nicconike/Steam-Stats/actions/workflows/sast.yml) +[![Bandit](https://github.com/Nicconike/Steam-Stats/actions/workflows/bandit.yml/badge.svg)](https://github.com/Nicconike/Steam-Stats/actions/workflows/bandit.yml) ![Pylint](https://img.shields.io/badge/Pylint-9.19-yellow?logo=python) [![codecov](https://codecov.io/gh/Nicconike/Steam-Stats/graph/badge.svg?token=SC5P7CS1BW)](https://codecov.io/gh/Nicconike/Steam-Stats) ![Docker Image Size](https://img.shields.io/docker/image-size/nicconike/steam-stats?logo=docker&label=Docker%20Image&link=https%3A%2F%2Fhub.docker.com%2Fr%2Fnicconike%2Fsteam-stats) diff --git a/tests/test_main.py b/tests/test_main.py index 3954c26..87359fa 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -81,26 +81,38 @@ def test_generate_steam_stats(mock_logger, mock_generate_card_played, mock_get_r "Generated Card for Recently Played Games") mock_get_player_summaries.return_value = None + mock_get_recently_played.return_value = {'games': 'data'} + mock_generate_card_played.return_value = 'Played Games Card' result = generate_steam_stats() - TestCase().assertEqual(result, '') + TestCase().assertIn('Played Games Card', result) + TestCase().assertEqual(result, 'Played Games Card') mock_logger.info.assert_any_call("No Steam User Summary data found") + mock_get_player_summaries.return_value = {'player': 'summary'} + mock_generate_card_summary.return_value = 'Player Summary Card' mock_get_recently_played.return_value = None result = generate_steam_stats() - TestCase().assertEqual(result, '') + TestCase().assertIn('Player Summary Card', result) + TestCase().assertEqual(result, 'Player Summary Card') mock_logger.info.assert_any_call("No Recently Played Games data found") mock_get_player_summaries.return_value = {'player': 'summary'} mock_generate_card_summary.return_value = None + mock_get_recently_played.return_value = {'games': 'data'} + mock_generate_card_played.return_value = 'Played Games Card' result = generate_steam_stats() - TestCase().assertEqual(result, '') + TestCase().assertIn('Played Games Card', result) + TestCase().assertEqual(result, 'Played Games Card') mock_logger.error.assert_any_call( "Failed to generate card for Steam Summary") + mock_get_player_summaries.return_value = {'player': 'summary'} + mock_generate_card_summary.return_value = 'Player Summary Card' mock_get_recently_played.return_value = {'games': 'data'} mock_generate_card_played.return_value = None result = generate_steam_stats() - TestCase().assertEqual(result, '') + TestCase().assertIn('Player Summary Card', result) + TestCase().assertEqual(result, 'Player Summary Card') mock_logger.info.assert_any_call( "No Games data found, skipping card generation")