def test_map_action(simple_act_state_processor: SimpleActStateProcessor,
                    gamestate_stub: GameState, random_action_id: int):
    if random_action_id < GLOBAL_ACTIONSPACE:
        expected = simple_act_state_processor.penalize_action(
            simple_act_state_processor._map_global_actions(
                random_action_id, gamestate_stub), gamestate_stub)
        assert expected == simple_act_state_processor.map_action(
            random_action_id, gamestate_stub)
    else:
        random_city_action_id = random_action_id - GLOBAL_ACTIONSPACE
        expected = simple_act_state_processor.penalize_action(
            simple_act_state_processor._map_city_actions(
                random_city_action_id, gamestate_stub), gamestate_stub)
        assert expected == simple_act_state_processor.map_action(
            random_action_id, gamestate_stub)
def test_penalize_action(simple_act_state_processor: SimpleActStateProcessor,
                         gamestate_stub: Mock, monkeypatch,
                         chosen_action: Optional[Action],
                         possible_actions: List[Action],
                         expected_penalty: int):
    # GIVEN
    monkeypatch.setattr('models.actions.generate_possible_actions',
                        lambda _: possible_actions)
    # THEN
    assert simple_act_state_processor.penalize_action(chosen_action, gamestate_stub) \
           == (chosen_action, expected_penalty)