Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

chennin
Copy link
Contributor

@chennin chennin commented Dec 22, 2023

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.

⚠️ Please merge after #124 and #128

Comment on lines 34 to 36
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)
Copy link
Owner

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):
image

Copy link
Owner

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)

Copy link
Contributor Author

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

@eliasdoehne
Copy link
Owner

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
(I never tried it)

@chennin @MichaelMakesGames Do you have any ideas for this?

@chennin chennin force-pushed the add_updated_test_save branch from 84349eb to 1fc1ab8 Compare December 23, 2023 17:53
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.
@chennin chennin force-pushed the add_updated_test_save branch from 1fc1ab8 to 111478b Compare December 23, 2023 18:02
@chennin
Copy link
Contributor Author

chennin commented Dec 23, 2023

@chennin @MichaelMakesGames Do you have any ideas for this?

@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.

batch response: @chennin can not upload new objects to public fork chennin/stellaris-dashboard
error: failed to push some refs to 'github.com:chennin/stellaris-dashboard.git'

@chennin
Copy link
Contributor Author

chennin commented May 10, 2024

Closing this in favor of an upcoming different solution

@chennin chennin closed this May 10, 2024
@chennin chennin deleted the add_updated_test_save branch May 10, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants