-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Test: check fields in world source manifest #5558
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
Merged
black-sliver
merged 10 commits into
ArchipelagoMW:main
from
black-sliver:feat/test-world-manifest-game
Oct 21, 2025
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
95743cb
Test: check game in world manifest
black-sliver 2d140df
Update test/general/test_world_manifest.py
black-sliver a79cefb
Test: rework finding expected manifest location
black-sliver 89dee5d
Test: fix doc comment
black-sliver 5ec0e5c
Test: fix wrong custom_worlds path in test_world_manifest
black-sliver 401026b
Test: make test_world_manifest easier to extend
black-sliver d01f507
Test: check world_version in world manifest
black-sliver 2de6feb
Test: check no container version in source world manifest
black-sliver a6016fc
Test: better assertion messages in test_world_manifest.py
black-sliver c20b37d
Test: fix wording in world source manifest
black-sliver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| """Check world sources' manifest files""" | ||
|
|
||
| import json | ||
| import unittest | ||
| from pathlib import Path | ||
| from typing import ClassVar | ||
|
|
||
| from worlds.AutoWorld import AutoWorldRegister | ||
| from ..param import classvar_matrix | ||
|
|
||
|
|
||
| # Only check source folders for now. Zip validation should probably be in the loader and/or installer. | ||
| source_world_names = [k for k, v in AutoWorldRegister.world_types.items() if not v.zip_path] | ||
|
|
||
|
|
||
| def get_source_world_manifest_path(game: str) -> Path | None: | ||
| world_type = AutoWorldRegister.world_types[game] | ||
| manifest_path = Path(world_type.__file__).parent / "archipelago.json" | ||
| if manifest_path.exists(): | ||
| return manifest_path | ||
| return None | ||
|
|
||
|
|
||
| # TODO: remove the filter once manifests are mandatory. | ||
| @classvar_matrix(game=filter(get_source_world_manifest_path, source_world_names)) | ||
| class TestWorldManifest(unittest.TestCase): | ||
| game: ClassVar[str] | ||
|
|
||
| def test_game(self) -> None: | ||
| """Test that 'game' will be correctly defined when generating APWorld manifest from source.""" | ||
| world_type = AutoWorldRegister.world_types[self.game] | ||
| manifest_path = get_source_world_manifest_path(self.game) | ||
| assert manifest_path # make mypy happy | ||
| with manifest_path.open("r", encoding="utf-8") as f: | ||
| manifest = json.load(f) | ||
| self.assertIn( | ||
| "game", | ||
| manifest, | ||
| f"archipelago.json manifest exists for {self.game} but does not contain 'game'", | ||
| ) | ||
| self.assertIn( | ||
black-sliver marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| manifest["game"], | ||
| world_type.game, | ||
| f"archipelago.json manifest for {self.game} specifies wrong game '{manifest['game']}'", | ||
| ) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are worlds meant to always define the world class in a file that's directly inside the root directory instead of a subfolder? Otherwise this will fail to find an
archipelago.jsonin the root directory, although it doesn't seem to be the first place to use this.Uh oh!
There was an error while loading. Please reload this page.
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.
Technically it only has to be imported from the
__init__.py. (But maybe even that can be relaxed in the future once the manifest is mandatory - the manifest could say what exactly to import.)I added some code to find the worlds' root folder now. I do think this should be solved in AutoWorldRegister, so it can be shared between setup, LauncherComponents and tests, but I am honestly not sure what the best approach is gonna be, so I'd rather leave it just in the test for now (and we'll fix other places in the future).