Files
Grinch-AP/test/general/TestLocations.py
alwaysintreble 8af7908cd0 Tests: datapackage and more multiworld renaming (#1454)
* Tests: add a test that created items and locations exist in the datapackage

* move FF validation to `assert_generate` and remove test exclusion

* test created location addresses are correct

* make the assertion proper and more verbose

* make item count test ~~a bit faster~~ a lot nicer

* 120 blaze it

* name test multiworld setup better and fix another over 120 line in FFR
2023-02-15 22:46:10 +01:00

26 lines
1.3 KiB
Python

import unittest
from collections import Counter
from worlds.AutoWorld import AutoWorldRegister
from . import setup_solo_multiworld
class TestBase(unittest.TestCase):
def testCreateDuplicateLocations(self):
"""Tests that no two Locations share a name."""
for game_name, world_type in AutoWorldRegister.world_types.items():
multiworld = setup_solo_multiworld(world_type)
locations = Counter(multiworld.get_locations())
if locations:
self.assertLessEqual(locations.most_common(1)[0][1], 1,
f"{world_type.game} has duplicate of location {locations.most_common(1)}")
def testLocationsInDatapackage(self):
"""Tests that created locations not filled before fill starts exist in the datapackage."""
for game_name, world_type in AutoWorldRegister.world_types.items():
with self.subTest("Game", game_name=game_name):
multiworld = setup_solo_multiworld(world_type)
locations = multiworld.get_unfilled_locations() # do unfilled locations to avoid Events
for location in locations:
self.assertIn(location.name, world_type.location_name_to_id)
self.assertEqual(location.address, world_type.location_name_to_id[location.name])