[test] tests/randomize_order_test.py fails
Closed this issue · 1 comments
trigaten commented
Running pytest tests/
yields the following for this test:
________________________ TestRandomizeDipnet.test ________________________
self = <randomize_order_test.TestRandomizeDipnet object at 0x2b9fb4b3a0b8>
def test(self):
# The following three tests check that build, disband and remove commands do not get changed when input into the order randomizer.
ord = [(('FRA', "AMY", 'PAR'), 'BLD')]
assert ord == random_list_orders(ord)
ord = [(('FRA', "AMY", 'PAR'), 'DSB')]
assert ord == random_list_orders(ord)
ord = [(('FRA', "AMY", 'PAR'), 'REM')]
assert ord == random_list_orders(ord)
# The following three tests check that when orders that contain movements, holds, convoys and other moves get
# input into the order randomizer, they come out differnent.
orders = [(("FRA", "FLT", "NTH"), "CVY", ('FRA', 'AMY', 'HOL'), 'CTO', "NWY"), (("FRA", "AMY", "HOL"), "CTO", 'NWY',"VIA", ('NTH')), (("FRA", "AMY", "BER"), "HLD")]
> assert(random_list_orders(orders) != orders)
tests/randomize_order_test.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/baseline_bots/randomize_order.py:109: in random_list_orders
map(lambda order: randomize(order), orders)
src/baseline_bots/randomize_order.py:109: in <lambda>
map(lambda order: randomize(order), orders)
src/baseline_bots/randomize_order.py:168: in randomize
return tag_to_func[tag](order)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
order = (('FRA', 'AMY', 'HOL'), 'CTO', 'NWY', 'VIA', 'NTH')
def random_convoy_to(order: Tuple) -> Tuple:
"""
This takes a convoy order and returns the longest alternate convoy.
:param order: A "convoy to" (CTO) order
:type order: Tuple
:return: A deviant order (with some chance of being the same order).
:rtype: Tuple
"""
(_, _, amy_loc), _, province, _, (sea_provinces) = order
sea_provinces = list(reversed(sea_provinces))
for i, sea in enumerate(
sea_provinces
): # searches through the sea provinces in reversed order to find the longest possible alternate convoy
# fmt : off
valid = [
loc
> for loc in ADJACENCY[sea]
if TYPES[loc] == "COAST"
and loc != [province]
and loc not in ADJACENCY[amy_loc]
] # the location must not be the one the unit is already convoying to
E KeyError: 'H'
src/baseline_bots/randomize_order.py:188: KeyError