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

Tests: test that collect and remove have expected behaviour. #2062

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
26 changes: 24 additions & 2 deletions test/general/TestItems.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,36 @@


class TestBase(unittest.TestCase):
def testCreateItem(self):
def testItem(self):
for game_name, world_type in AutoWorldRegister.world_types.items():
proxy_world = world_type(None, 0) # this is identical to MultiServer.py creating worlds
multiworld = setup_solo_multiworld(world_type, steps=("generate_early", "create_regions", "create_items"))
proxy_world = multiworld.worlds[1]
empty_prog_items = multiworld.state.prog_items.copy()
for item_name in world_type.item_name_to_id:
with self.subTest("Create Item", item_name=item_name, game_name=game_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)
Berserker66 marked this conversation as resolved.
Show resolved Hide resolved

if item.advancement:
with self.subTest("Item State Collect", item_name=item_name, game_name=game_name):
multiworld.state.collect(item, True)
Berserker66 marked this conversation as resolved.
Show resolved Hide resolved

Berserker66 marked this conversation as resolved.
Show resolved Hide resolved
with self.subTest("Item State Remove", item_name=item_name, game_name=game_name):
multiworld.state.remove(item)

self.assertEqual(multiworld.state.prog_items, empty_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.
base_state = multiworld.state.prog_items.copy()
multiworld.state.collect(item)
self.assertEqual(base_state, multiworld.state.prog_items)
Copy link
Collaborator

@el-u el-u Sep 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the variable base_state could be removed and empty_prog_items be used instead (once the bug on the line below has been fixed.)

Out of scope feature request removed.

Berserker66 marked this conversation as resolved.
Show resolved Hide resolved

multiworld.state.prog_items = empty_prog_items
Berserker66 marked this conversation as resolved.
Show resolved Hide resolved

def testItemNameGroupHasValidItem(self):
"""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.
Expand Down