Skip to content

Commit

Permalink
Start adding basic saving tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LagoLunatic committed Jun 20, 2024
1 parent 901102e commit 0f02b41
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
artifact: linux
reqs_file: requirements_full.txt

container: ghcr.io/LagoLunatic/wwrando-test-files:main

runs-on: ${{ matrix.os }}

env:
Expand Down Expand Up @@ -63,6 +65,14 @@ jobs:
if: runner.os == 'Linux'
run: |
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX
- name: Extract test files
uses: edgarrc/action-7z@v1
with:
args: 7z x /wwrando-files/GZLE01-stripped.7z -o/wwrando-files/
- name: Prepare test env vars
run: |
echo "WW_GZLE01_STRIPPED_PATH=/wwrando-files/WW Stripped ISO.iso" > .env
echo "WW_RANDO_OUTPUT_DIR=/wwrando-output" > .env
- name: Test with pytest
run: |
pip install pytest pytest-cov
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ profileresults*.prof
/.venv
/site
.coverage
.env
1 change: 1 addition & 0 deletions requirements_full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ PyInstaller~=6.8.0
pytest~=7.4.0
pytest-cov~=4.1.0
pytest-qt~=4.2.0
python-dotenv~=1.0.1
1 change: 1 addition & 0 deletions requirements_qt5_full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ PyInstaller~=6.8.0
pytest~=7.4.0
pytest-cov~=4.1.0
pytest-qt~=4.2.0
python-dotenv~=1.0.1
5 changes: 3 additions & 2 deletions test/test_dry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from wwrando import make_argparser
from randomizer import WWRandomizer
from options.wwrando_options import Options, SwordMode, EntranceMixMode, TrickDifficulty
from options.wwrando_options import Options, TrickDifficulty
from enum import StrEnum
from test_helpers import *

Expand All @@ -9,7 +10,7 @@ def dry_rando_with_options(options) -> WWRandomizer:
rando_kwargs = {
"seed": "pytestseed",
"clean_iso_path": None,
"randomized_output_folder": "./rando_output",
"randomized_output_folder": os.environ["WW_RANDO_OUTPUT_DIR"],
"options": options,
"cmd_line_args": args,
}
Expand Down
22 changes: 22 additions & 0 deletions test/test_save.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
from wwrando import make_argparser
from randomizer import WWRandomizer
from options.wwrando_options import Options
from test_helpers import *

def rando_with_options(options) -> WWRandomizer:
args = make_argparser().parse_args(args=["--nologs"])
rando_kwargs = {
"seed": "pytestseed",
"clean_iso_path": os.environ["WW_GZLE01_STRIPPED_PATH"],
"randomized_output_folder": os.environ["WW_RANDO_OUTPUT_DIR"],
"options": options,
"cmd_line_args": args,
}
os.makedirs(rando_kwargs["randomized_output_folder"], exist_ok=True)
return WWRandomizer(**rando_kwargs)

def test_default_options():
options = Options()
rando = rando_with_options(options)
rando.randomize_all()

0 comments on commit 0f02b41

Please sign in to comment.