From 6f9484f3750ce05113044baab8fe0f53fc28cc59 Mon Sep 17 00:00:00 2001 From: Aaron Wagener Date: Sun, 8 Oct 2023 07:33:39 -0500 Subject: [PATCH] The Messenger: Make modules and tests PEP8 (#2276) * The Messenger: PEP8 module and test names * fix dumb * whitespace --- worlds/messenger/__init__.py | 30 ++++++++----------- .../messenger/{Constants.py => constants.py} | 2 +- worlds/messenger/{Options.py => options.py} | 0 worlds/messenger/{Regions.py => regions.py} | 0 worlds/messenger/{Rules.py => rules.py} | 8 ++--- worlds/messenger/{Shop.py => shop.py} | 0 .../{SubClasses.py => subclasses.py} | 8 ++--- .../test/{TestAccess.py => test_access.py} | 24 +++++++-------- .../{TestLocations.py => test_locations.py} | 6 ++-- .../test/{TestLogic.py => test_logic.py} | 12 ++++---- .../test/{TestNotes.py => test_notes.py} | 10 +++---- .../test/{TestShop.py => test_shop.py} | 24 +++++++-------- .../{TestShopChest.py => test_shop_chest.py} | 12 ++++---- 13 files changed, 65 insertions(+), 71 deletions(-) rename worlds/messenger/{Constants.py => constants.py} (98%) rename worlds/messenger/{Options.py => options.py} (100%) rename worlds/messenger/{Regions.py => regions.py} (100%) rename worlds/messenger/{Rules.py => rules.py} (99%) rename worlds/messenger/{Shop.py => shop.py} (100%) rename worlds/messenger/{SubClasses.py => subclasses.py} (95%) rename worlds/messenger/test/{TestAccess.py => test_access.py} (95%) rename worlds/messenger/test/{TestLocations.py => test_locations.py} (81%) rename worlds/messenger/test/{TestLogic.py => test_logic.py} (96%) rename worlds/messenger/test/{TestNotes.py => test_notes.py} (80%) rename worlds/messenger/test/{TestShop.py => test_shop.py} (89%) rename worlds/messenger/test/{TestShopChest.py => test_shop_chest.py} (94%) diff --git a/worlds/messenger/__init__.py b/worlds/messenger/__init__.py index b37f23749df5..c7fd25363293 100644 --- a/worlds/messenger/__init__.py +++ b/worlds/messenger/__init__.py @@ -1,14 +1,14 @@ import logging -from typing import Dict, Any, List, Optional +from typing import Any, Dict, List, Optional -from BaseClasses import Tutorial, ItemClassification, CollectionState, Item, MultiWorld -from worlds.AutoWorld import World, WebWorld -from .Constants import NOTES, PHOBEKINS, ALL_ITEMS, ALWAYS_LOCATIONS, BOSS_LOCATIONS, FILLER -from .Options import messenger_options, NotesNeeded, Goal, PowerSeals, Logic -from .Regions import REGIONS, REGION_CONNECTIONS, SEALS, MEGA_SHARDS -from .Shop import SHOP_ITEMS, shuffle_shop_prices, FIGURINES -from .SubClasses import MessengerRegion, MessengerItem -from . import Rules +from BaseClasses import CollectionState, Item, ItemClassification, Tutorial +from worlds.AutoWorld import WebWorld, World +from .constants import ALL_ITEMS, ALWAYS_LOCATIONS, BOSS_LOCATIONS, FILLER, NOTES, PHOBEKINS +from .options import Goal, Logic, NotesNeeded, PowerSeals, messenger_options +from .regions import MEGA_SHARDS, REGIONS, REGION_CONNECTIONS, SEALS +from .rules import MessengerHardRules, MessengerOOBRules, MessengerRules +from .shop import FIGURINES, SHOP_ITEMS, shuffle_shop_prices +from .subclasses import MessengerItem, MessengerRegion class MessengerWeb(WebWorld): @@ -68,15 +68,11 @@ class MessengerWorld(World): total_seals: int = 0 required_seals: int = 0 - total_shards: int + total_shards: int = 0 shop_prices: Dict[str, int] figurine_prices: Dict[str, int] _filler_items: List[str] - def __init__(self, multiworld: MultiWorld, player: int): - super().__init__(multiworld, player) - self.total_shards = 0 - def generate_early(self) -> None: if self.multiworld.goal[self.player] == Goal.option_power_seal_hunt: self.multiworld.shuffle_seals[self.player].value = PowerSeals.option_true @@ -144,11 +140,11 @@ def create_items(self) -> None: def set_rules(self) -> None: logic = self.multiworld.logic_level[self.player] if logic == Logic.option_normal: - Rules.MessengerRules(self).set_messenger_rules() + MessengerRules(self).set_messenger_rules() elif logic == Logic.option_hard: - Rules.MessengerHardRules(self).set_messenger_rules() + MessengerHardRules(self).set_messenger_rules() else: - Rules.MessengerOOBRules(self).set_messenger_rules() + MessengerOOBRules(self).set_messenger_rules() def fill_slot_data(self) -> Dict[str, Any]: shop_prices = {SHOP_ITEMS[item].internal_name: price for item, price in self.shop_prices.items()} diff --git a/worlds/messenger/Constants.py b/worlds/messenger/constants.py similarity index 98% rename from worlds/messenger/Constants.py rename to worlds/messenger/constants.py index 121584da0555..e6608be043b3 100644 --- a/worlds/messenger/Constants.py +++ b/worlds/messenger/constants.py @@ -1,6 +1,6 @@ # items # listing individual groups first for easy lookup -from .Shop import SHOP_ITEMS, FIGURINES +from .shop import SHOP_ITEMS, FIGURINES NOTES = [ "Key of Hope", diff --git a/worlds/messenger/Options.py b/worlds/messenger/options.py similarity index 100% rename from worlds/messenger/Options.py rename to worlds/messenger/options.py diff --git a/worlds/messenger/Regions.py b/worlds/messenger/regions.py similarity index 100% rename from worlds/messenger/Regions.py rename to worlds/messenger/regions.py diff --git a/worlds/messenger/Rules.py b/worlds/messenger/rules.py similarity index 99% rename from worlds/messenger/Rules.py rename to worlds/messenger/rules.py index 664bf5f6d7cf..65a99627f22e 100644 --- a/worlds/messenger/Rules.py +++ b/worlds/messenger/rules.py @@ -2,9 +2,9 @@ from BaseClasses import CollectionState, MultiWorld from worlds.generic.Rules import set_rule, allow_self_locking_items, add_rule -from .Options import MessengerAccessibility, Goal -from .Constants import NOTES, PHOBEKINS -from .SubClasses import MessengerShopLocation +from .options import MessengerAccessibility, Goal +from .constants import NOTES, PHOBEKINS +from .subclasses import MessengerShopLocation if TYPE_CHECKING: from . import MessengerWorld @@ -119,7 +119,7 @@ def can_destroy_projectiles(self, state: CollectionState) -> bool: def can_dboost(self, state: CollectionState) -> bool: return state.has_any({"Path of Resilience", "Meditation"}, self.player) and \ state.has("Second Wind", self.player) - + def is_aerobatic(self, state: CollectionState) -> bool: return self.has_wingsuit(state) and state.has("Aerobatics Warrior", self.player) diff --git a/worlds/messenger/Shop.py b/worlds/messenger/shop.py similarity index 100% rename from worlds/messenger/Shop.py rename to worlds/messenger/shop.py diff --git a/worlds/messenger/SubClasses.py b/worlds/messenger/subclasses.py similarity index 95% rename from worlds/messenger/SubClasses.py rename to worlds/messenger/subclasses.py index 717b38987870..e6a18b2e4e7d 100644 --- a/worlds/messenger/SubClasses.py +++ b/worlds/messenger/subclasses.py @@ -2,10 +2,10 @@ from typing import Optional, TYPE_CHECKING, cast from BaseClasses import CollectionState, Item, ItemClassification, Location, Region -from .Constants import NOTES, PHOBEKINS, PROG_ITEMS, USEFUL_ITEMS -from .Options import Goal -from .Regions import MEGA_SHARDS, REGIONS, SEALS -from .Shop import FIGURINES, PROG_SHOP_ITEMS, SHOP_ITEMS, USEFUL_SHOP_ITEMS +from .constants import NOTES, PHOBEKINS, PROG_ITEMS, USEFUL_ITEMS +from .options import Goal +from .regions import MEGA_SHARDS, REGIONS, SEALS +from .shop import FIGURINES, PROG_SHOP_ITEMS, SHOP_ITEMS, USEFUL_SHOP_ITEMS if TYPE_CHECKING: from . import MessengerWorld diff --git a/worlds/messenger/test/TestAccess.py b/worlds/messenger/test/test_access.py similarity index 95% rename from worlds/messenger/test/TestAccess.py rename to worlds/messenger/test/test_access.py index e95a81c5c1fd..7a77a9b06695 100644 --- a/worlds/messenger/test/TestAccess.py +++ b/worlds/messenger/test/test_access.py @@ -1,5 +1,5 @@ from . import MessengerTestBase -from ..Constants import NOTES, PHOBEKINS +from ..constants import NOTES, PHOBEKINS class AccessTest(MessengerTestBase): @@ -7,7 +7,7 @@ class AccessTest(MessengerTestBase): "shuffle_shards": "true", } - def testTabi(self) -> None: + def test_tabi(self) -> None: """locations that hard require the Lightfoot Tabi""" locations = [ "Searing Crags - Pyro", "Underworld - Key of Chaos", "Underworld Seal - Sharp and Windy Climb", @@ -19,7 +19,7 @@ def testTabi(self) -> None: items = [["Lightfoot Tabi"]] self.assertAccessDependency(locations, items) - def testDart(self) -> None: + def test_dart(self) -> None: """locations that hard require the Rope Dart""" locations = [ "Ninja Village Seal - Tree House", "Autumn Hills - Key of Hope", "Howling Grotto Seal - Crushing Pits", @@ -31,7 +31,7 @@ def testDart(self) -> None: items = [["Rope Dart"]] self.assertAccessDependency(locations, items) - def testWingsuit(self) -> None: + def test_wingsuit(self) -> None: """locations that hard require the Wingsuit""" locations = [ "Ninja Village - Candle", "Ninja Village Seal - Tree House", "Autumn Hills - Climbing Claws", @@ -57,7 +57,7 @@ def testWingsuit(self) -> None: items = [["Wingsuit"]] self.assertAccessDependency(locations, items) - def testVertical(self) -> None: + def test_vertical(self) -> None: """locations that require either the Rope Dart or the Wingsuit""" locations = [ "Ninja Village Seal - Tree House", "Howling Grotto Seal - Crushing Pits", @@ -92,7 +92,7 @@ def testVertical(self) -> None: items = [["Wingsuit", "Rope Dart"]] self.assertAccessDependency(locations, items) - def testAmulet(self) -> None: + def test_amulet(self) -> None: """Locations that require Ruxxtin's Amulet""" locations = [ "Cloud Ruins - Acro", "Cloud Ruins Seal - Ghost Pit", "Cloud Ruins Seal - Toothbrush Alley", @@ -103,7 +103,7 @@ def testAmulet(self) -> None: items = [["Ruxxtin's Amulet"]] self.assertAccessDependency(locations, items) - def testFirefly(self) -> None: + def test_firefly(self) -> None: """Elemental Skylands and Corrupted Future require the Magic Firefly""" locations = [ "Elemental Skylands - Key of Symbiosis", "Elemental Skylands Seal - Air", "Elemental Skylands Seal - Fire", @@ -113,7 +113,7 @@ def testFirefly(self) -> None: items = [["Magic Firefly"]] self.assertAccessDependency(locations, items) - def testCrests(self) -> None: + def test_crests(self) -> None: """Test Key of Love nonsense""" locations = ["Sunken Shrine - Key of Love"] items = [["Sun Crest", "Moon Crest"]] @@ -124,19 +124,19 @@ def testCrests(self) -> None: self.collect_by_name("Sun Crest") self.assertEqual(self.can_reach_location("Sunken Shrine - Key of Love"), False) - def testThistle(self) -> None: + def test_thistle(self) -> None: """I'm a chuckster!""" locations = ["Searing Crags - Key of Strength"] items = [["Power Thistle"]] self.assertAccessDependency(locations, items) - def testCrown(self) -> None: + def test_crown(self) -> None: """Crocomire but not""" locations = ["Corrupted Future - Key of Courage"] items = [["Demon King Crown"]] self.assertAccessDependency(locations, items) - def testGoal(self) -> None: + def test_goal(self) -> None: """Test some different states to verify goal requires the correct items""" self.collect_all_but([*NOTES, "Rescue Phantom"]) self.assertEqual(self.can_reach_location("Rescue Phantom"), False) @@ -153,7 +153,7 @@ class ItemsAccessTest(MessengerTestBase): "accessibility": "items", } - def testSelfLockingItems(self) -> None: + def test_self_locking_items(self) -> None: """Force items that can be self locked to ensure it's valid placement.""" location_lock_pairs = { "Searing Crags - Key of Strength": ["Power Thistle"], diff --git a/worlds/messenger/test/TestLocations.py b/worlds/messenger/test/test_locations.py similarity index 81% rename from worlds/messenger/test/TestLocations.py rename to worlds/messenger/test/test_locations.py index ccb358568ccf..0c330be4bd3a 100644 --- a/worlds/messenger/test/TestLocations.py +++ b/worlds/messenger/test/test_locations.py @@ -1,5 +1,5 @@ from . import MessengerTestBase -from ..SubClasses import MessengerLocation +from ..subclasses import MessengerLocation class LocationsTest(MessengerTestBase): @@ -10,7 +10,7 @@ class LocationsTest(MessengerTestBase): @property def run_default_tests(self) -> bool: return False - - def testLocationsExist(self): + + def test_locations_exist(self) -> None: for location in self.multiworld.worlds[1].location_name_to_id: self.assertIsInstance(self.multiworld.get_location(location, self.player), MessengerLocation) diff --git a/worlds/messenger/test/TestLogic.py b/worlds/messenger/test/test_logic.py similarity index 96% rename from worlds/messenger/test/TestLogic.py rename to worlds/messenger/test/test_logic.py index 932bc1386701..53ea92992212 100644 --- a/worlds/messenger/test/TestLogic.py +++ b/worlds/messenger/test/test_logic.py @@ -1,5 +1,3 @@ -from typing import Iterable, List - from BaseClasses import ItemClassification from . import MessengerTestBase @@ -10,7 +8,7 @@ class HardLogicTest(MessengerTestBase): "shuffle_shards": "true", } - def testVertical(self) -> None: + def test_vertical(self) -> None: """Test the locations that still require wingsuit or rope dart.""" locations = [ # tower of time @@ -54,7 +52,7 @@ def testVertical(self) -> None: items = [["Wingsuit", "Rope Dart"]] self.assertAccessDependency(locations, items) - def testWindmill(self) -> None: + def test_windmill(self) -> None: """Windmill Shuriken isn't progression on normal difficulty, so test it's marked correctly and required.""" self.assertEqual(ItemClassification.progression, self.get_item_by_name("Windmill Shuriken").classification) windmill_locs = [ @@ -81,8 +79,8 @@ def testWindmill(self) -> None: item = self.get_item_by_name("Rope Dart") self.collect(item) self.assertTrue(self.can_reach_location(special_loc)) - - def testGlacial(self) -> None: + + def test_glacial(self) -> None: """Test Glacial Peak locations.""" self.assertAccessDependency(["Glacial Peak Seal - Ice Climbers"], [["Second Wind", "Meditation"], ["Rope Dart"], ["Wingsuit"]], @@ -100,7 +98,7 @@ class NoLogicTest(MessengerTestBase): "logic_level": "oob", } - def testAccess(self) -> None: + def test_access(self) -> None: """Test the locations with rules still require things.""" all_locations = [ "Bamboo Creek - Claustro", "Searing Crags - Key of Strength", "Elemental Skylands - Key of Symbiosis", diff --git a/worlds/messenger/test/TestNotes.py b/worlds/messenger/test/test_notes.py similarity index 80% rename from worlds/messenger/test/TestNotes.py rename to worlds/messenger/test/test_notes.py index c4292e4900d8..46cec5f3c819 100644 --- a/worlds/messenger/test/TestNotes.py +++ b/worlds/messenger/test/test_notes.py @@ -1,5 +1,5 @@ from . import MessengerTestBase -from ..Constants import NOTES +from ..constants import NOTES class TwoNoteGoalTest(MessengerTestBase): @@ -7,7 +7,7 @@ class TwoNoteGoalTest(MessengerTestBase): "notes_needed": 2, } - def testPrecollectedNotes(self) -> None: + def test_precollected_notes(self) -> None: self.assertEqual(self.multiworld.state.count_group("Notes", self.player), 4) @@ -16,15 +16,15 @@ class FourNoteGoalTest(MessengerTestBase): "notes_needed": 4, } - def testPrecollectedNotes(self) -> None: + def test_precollected_notes(self) -> None: self.assertEqual(self.multiworld.state.count_group("Notes", self.player), 2) class DefaultGoalTest(MessengerTestBase): - def testPrecollectedNotes(self) -> None: + def test_precollected_notes(self) -> None: self.assertEqual(self.multiworld.state.count_group("Notes", self.player), 0) - def testGoal(self) -> None: + def test_goal(self) -> None: self.assertBeatable(False) self.collect_by_name(NOTES) rope_dart = self.get_item_by_name("Rope Dart") diff --git a/worlds/messenger/test/TestShop.py b/worlds/messenger/test/test_shop.py similarity index 89% rename from worlds/messenger/test/TestShop.py rename to worlds/messenger/test/test_shop.py index 89ea93624ddd..bfd3b417a875 100644 --- a/worlds/messenger/test/TestShop.py +++ b/worlds/messenger/test/test_shop.py @@ -1,7 +1,7 @@ from typing import Dict from . import MessengerTestBase -from ..Shop import SHOP_ITEMS, FIGURINES +from ..shop import SHOP_ITEMS, FIGURINES class ShopCostTest(MessengerTestBase): @@ -10,13 +10,13 @@ class ShopCostTest(MessengerTestBase): "shuffle_shards": "true", } - def testShopRules(self) -> None: + def test_shop_rules(self) -> None: for loc in SHOP_ITEMS: loc = f"The Shop - {loc}" with self.subTest("has cost", loc=loc): self.assertFalse(self.can_reach_location(loc)) - def testShopPrices(self) -> None: + def test_shop_prices(self) -> None: prices: Dict[str, int] = self.multiworld.worlds[self.player].shop_prices for loc, price in prices.items(): with self.subTest("prices", loc=loc): @@ -24,7 +24,7 @@ def testShopPrices(self) -> None: self.assertTrue(loc in SHOP_ITEMS) self.assertEqual(len(prices), len(SHOP_ITEMS)) - def testDBoost(self) -> None: + def test_dboost(self) -> None: locations = [ "Riviere Turquoise Seal - Bounces and Balls", "Forlorn Temple - Demon King", "Forlorn Temple Seal - Rocket Maze", "Forlorn Temple Seal - Rocket Sunset", @@ -33,10 +33,10 @@ def testDBoost(self) -> None: items = [["Path of Resilience", "Meditation", "Second Wind"]] self.assertAccessDependency(locations, items) - def testCurrents(self) -> None: + def test_currents(self) -> None: self.assertAccessDependency(["Elemental Skylands Seal - Water"], [["Currents Master"]]) - def testStrike(self) -> None: + def test_strike(self) -> None: locations = [ "Glacial Peak Seal - Projectile Spike Pit", "Elemental Skylands Seal - Fire", ] @@ -50,22 +50,22 @@ class ShopCostMinTest(ShopCostTest): "shuffle_seals": "false", } - def testShopRules(self) -> None: + def test_shop_rules(self) -> None: if self.multiworld.worlds[self.player].total_shards: - super().testShopRules() + super().test_shop_rules() else: for loc in SHOP_ITEMS: loc = f"The Shop - {loc}" with self.subTest("has cost", loc=loc): self.assertTrue(self.can_reach_location(loc)) - def testDBoost(self) -> None: + def test_dboost(self) -> None: pass - def testCurrents(self) -> None: + def test_currents(self) -> None: pass - def testStrike(self) -> None: + def test_strike(self) -> None: pass @@ -79,7 +79,7 @@ class PlandoTest(MessengerTestBase): }, } - def testCosts(self) -> None: + def test_costs(self) -> None: for loc in SHOP_ITEMS: loc = f"The Shop - {loc}" with self.subTest("has cost", loc=loc): diff --git a/worlds/messenger/test/TestShopChest.py b/worlds/messenger/test/test_shop_chest.py similarity index 94% rename from worlds/messenger/test/TestShopChest.py rename to worlds/messenger/test/test_shop_chest.py index ad4178fbd718..058a2004478e 100644 --- a/worlds/messenger/test/TestShopChest.py +++ b/worlds/messenger/test/test_shop_chest.py @@ -8,11 +8,11 @@ class AllSealsRequired(MessengerTestBase): "goal": "power_seal_hunt", } - def testSealsShuffled(self) -> None: + def test_seals_shuffled(self) -> None: """Shuffle seals should be forced on when shop chest is the goal so test it.""" self.assertTrue(self.multiworld.shuffle_seals[self.player]) - def testChestAccess(self) -> None: + def test_chest_access(self) -> None: """Defaults to a total of 45 power seals in the pool and required.""" with self.subTest("Access Dependency"): self.assertEqual(len([seal for seal in self.multiworld.itempool if seal.name == "Power Seal"]), @@ -38,7 +38,7 @@ class HalfSealsRequired(MessengerTestBase): "percent_seals_required": 50, } - def testSealsAmount(self) -> None: + def test_seals_amount(self) -> None: """Should have 45 power seals in the item pool and half that required""" self.assertEqual(self.multiworld.total_seals[self.player], 45) self.assertEqual(self.multiworld.worlds[self.player].total_seals, 45) @@ -57,7 +57,7 @@ class ThirtyThirtySeals(MessengerTestBase): "percent_seals_required": 34, } - def testSealsAmount(self) -> None: + def test_seals_amount(self) -> None: """Should have 30 power seals in the pool and 33 percent of that required.""" self.assertEqual(self.multiworld.total_seals[self.player], 30) self.assertEqual(self.multiworld.worlds[self.player].total_seals, 30) @@ -75,7 +75,7 @@ class MaxSealsNoShards(MessengerTestBase): "total_seals": 85, } - def testSealsAmount(self) -> None: + def test_seals_amount(self) -> None: """Should set total seals to 70 since shards aren't shuffled.""" self.assertEqual(self.multiworld.total_seals[self.player], 85) self.assertEqual(self.multiworld.worlds[self.player].total_seals, 70) @@ -88,7 +88,7 @@ class MaxSealsWithShards(MessengerTestBase): "shuffle_shards": "true", } - def testSealsAmount(self) -> None: + def test_seals_amount(self) -> None: """Should have 85 seals in the pool with all required and be a valid seed.""" self.assertEqual(self.multiworld.total_seals[self.player], 85) self.assertEqual(self.multiworld.worlds[self.player].total_seals, 85)