mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Tests: test that collect and remove have expected behaviour. (#2062)
--------- Co-authored-by: qwint <qwint.42@gmail.com> Co-authored-by: Exempt-Medic <60412657+Exempt-Medic@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from BaseClasses import CollectionState
|
||||||
from worlds.AutoWorld import AutoWorldRegister, call_all
|
from worlds.AutoWorld import AutoWorldRegister, call_all
|
||||||
from . import setup_solo_multiworld
|
from . import setup_solo_multiworld
|
||||||
|
|
||||||
@@ -8,12 +9,31 @@ class TestBase(unittest.TestCase):
|
|||||||
def test_create_item(self):
|
def test_create_item(self):
|
||||||
"""Test that a world can successfully create all items in its datapackage"""
|
"""Test that a world can successfully create all items in its datapackage"""
|
||||||
for game_name, world_type in AutoWorldRegister.world_types.items():
|
for game_name, world_type in AutoWorldRegister.world_types.items():
|
||||||
proxy_world = setup_solo_multiworld(world_type, ()).worlds[1]
|
multiworld = setup_solo_multiworld(world_type, steps=("generate_early", "create_regions", "create_items"))
|
||||||
|
proxy_world = multiworld.worlds[1]
|
||||||
for item_name in world_type.item_name_to_id:
|
for item_name in world_type.item_name_to_id:
|
||||||
|
test_state = CollectionState(multiworld)
|
||||||
with self.subTest("Create Item", item_name=item_name, game_name=game_name):
|
with self.subTest("Create Item", item_name=item_name, game_name=game_name):
|
||||||
item = proxy_world.create_item(item_name)
|
item = proxy_world.create_item(item_name)
|
||||||
|
|
||||||
|
with self.subTest("Item Name", item_name=item_name, game_name=game_name):
|
||||||
self.assertEqual(item.name, item_name)
|
self.assertEqual(item.name, item_name)
|
||||||
|
|
||||||
|
if item.advancement:
|
||||||
|
with self.subTest("Item State Collect", item_name=item_name, game_name=game_name):
|
||||||
|
test_state.collect(item, True)
|
||||||
|
|
||||||
|
with self.subTest("Item State Remove", item_name=item_name, game_name=game_name):
|
||||||
|
test_state.remove(item)
|
||||||
|
|
||||||
|
self.assertEqual(test_state.prog_items, multiworld.state.prog_items,
|
||||||
|
"Item Collect -> Remove should restore empty state.")
|
||||||
|
else:
|
||||||
|
with self.subTest("Item State Collect No Change", item_name=item_name, game_name=game_name):
|
||||||
|
# Non-Advancement should not modify state.
|
||||||
|
test_state.collect(item)
|
||||||
|
self.assertEqual(test_state.prog_items, multiworld.state.prog_items)
|
||||||
|
|
||||||
def test_item_name_group_has_valid_item(self):
|
def test_item_name_group_has_valid_item(self):
|
||||||
"""Test that all item name groups contain valid items. """
|
"""Test that all item name groups contain valid items. """
|
||||||
# This cannot test for Event names that you may have declared for logic, only sendable Items.
|
# This cannot test for Event names that you may have declared for logic, only sendable Items.
|
||||||
|
Reference in New Issue
Block a user