Skip to content

Commit

Permalink
test: Improve codecov for main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicconike committed Jul 14, 2024
1 parent 26c391a commit 83e02e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 16 additions & 4 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 83e02e4

Please sign in to comment.