diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 86cf7b3..778fe44 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,4 +24,10 @@ jobs: run: pip install -r requirements.txt - name: Test with pytest - run: env $(cat .env.example | grep -v '^#' | xargs) python -m pytest --cov --disable-warnings -q \ No newline at end of file + run: env $(cat .env.example | grep -v '^#' | xargs) python -m pytest --cov --disable-warnings -q --cov-report xml:coverage.xml + + - name: Get coverage + uses: orgoro/coverage@v3.1 + with: + coverageFile: coverage.xml + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/tests/bot/cogs/ext/tcg/test_utils.py b/tests/bot/cogs/ext/tcg/test_utils.py new file mode 100644 index 0000000..26f9e75 --- /dev/null +++ b/tests/bot/cogs/ext/tcg/test_utils.py @@ -0,0 +1,17 @@ +import unittest + +from bot.cogs.ext.tcg.utils import calculate_elo + + +class TestCalculateElo(unittest.TestCase): + def test_zero_rating(self): + rating_winner = 0.0 + rating_loser = 0.0 + + self.assertEqual(20.0, calculate_elo(rating_winner, rating_loser)) + + def test_non_zero_rating(self): + rating_winner = 10.0 + rating_loser = 20.0 + + self.assertEqual(20.6, calculate_elo(rating_winner, rating_loser)) \ No newline at end of file