-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a 3.10.4 vanilla save to test cases #129
Conversation
test/parser_test.py
Outdated
output_db_dir = Path(f"{config.CONFIG.base_output_path}/db") | ||
for db in list(output_db_dir.glob('*.db')): | ||
db.unlink(missing_ok=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this risks deleting db files from real games when running tests which I think we should avoid.
Instead, we can use the tmp_path fixture provided by pytest and let the OS handle the cleanup. Then, I would also parametrize the test to a test case per game ID so we can easier figure out what broke
It should work like this:
@pytest.mark.parametrize(
"save_dir",
[path for path in pathlib.Path(__file__).parent.glob(r"saves/*")],
ids=lambda path: path.stem,
)
def test_real_save(save_dir, tmp_path):
from stellarisdashboard import cli, config
debug = config.CONFIG.debug_mode
base_path = config.CONFIG.base_output_path
config.CONFIG.debug_mode = True
config.CONFIG.base_output_path = tmp_path
try:
cli.f_parse_saves(save_path=save_dir)
finally:
config.CONFIG.debug_mode = debug
config.CONFIG.base_output_path = base_path
Looks like this (before merging #128):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(maybe it also makes sense to organize the save files by game version, e.g. test/saves/3.10.4/kaanvisamfriendship3_-449354374/2508.07.01.sav
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thank you. Updated
I like the idea of testing the code with a real save file, but I think we'll need a different way to store the files since they will quickly increase the size of the repo if we add new ones on every release. Maybe we can just move them to a separate repo and clone it during the github action workflow. Or something like this? https://docs.github.com/en/repositories/working-with-files/managing-large-files @chennin @MichaelMakesGames Do you have any ideas for this? |
84349eb
to
1fc1ab8
Compare
This specifically tests both accented characters and names literally `=`. Modifies the test case to remove all *.db files output by the test. Uses temporary directories for save tests and organizes test saves a bit more.
1fc1ab8
to
111478b
Compare
@eliasdoehne I tried Git LFS and it seems it won't work for the usual model of collaborators using forks to code and open PRs.
|
Closing this in favor of an upcoming different solution |
Add an updated vanilla save from 3.10.4. It was generated on a huge galaxy by letting observer mode run for 300 years (then saved in non-observer mode). This save specifically tests both accented characters and names literally
=
, ie, #126. It also has newer features like council positions.Also modifies the test case to remove all *.db files output by the test.