Skip to content

Commit

Permalink
Add Unit Testing Workflow using PyTest (#400)
Browse files Browse the repository at this point in the history
* Add PyTest CI workflow

* Add initial Unit Test

* Testing-CI: Cache Python Pip dependencies

* Testing-CI: Add Qt dependencies
  • Loading branch information
DavidoTek authored Jul 27, 2024
1 parent e8197bc commit cd3e843
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/testing-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test using Pytest

on:
push:
branches:
- main
pull_request:

jobs:
tests:
name: "Run PyTest"
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
cache: "pip"

- name: Install dependencies
run: |
sudo apt install -y libegl1 libxkbcommon0
pip install pytest pytest-md pytest-emoji
- name: Install ProtonUp-Qt
run: pip install -e .

- name: Run pytest
uses: pavelzw/pytest-action@v2
env:
QT_QPA_PLATFORM: "offscreen"
with:
verbose: true
emoji: true
job-summary: true
custom-arguments: '-q'
click-to-expand: true
report-title: 'ProtonUp-Qt Test Report'
22 changes: 22 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from pupgui2.util import *

from pupgui2.datastructures import SteamApp, LutrisGame, HeroicGame


def test_get_random_game_name():
""" test whether get_random_game_name returns a valid game name """
names = ["game", "A super cool game", "A game with a very long name that is very long", "0123456789"]

steam_app = [SteamApp() for _ in range(len(names))]
lutris_game = [LutrisGame() for _ in range(len(names))]
heroic_game = [HeroicGame() for _ in range(len(names))]

for i, name in enumerate(names):
steam_app[i].game_name = name
lutris_game[i].name = name
heroic_game[i].title = name

for i in range(10):
assert get_random_game_name(steam_app) in names
assert get_random_game_name(lutris_game) in names
assert get_random_game_name(heroic_game) in names

0 comments on commit cd3e843

Please sign in to comment.