Beispiel #1
0
def test_conflict_game_02_03():
    # arrange
    situation: Situation = Situation(
        orders=[
            # conflict 02:
            mk_order("Au A Vie mve Mun"),
            mk_order_0("Ge A Mun"),
            # conflict 03:
            mk_order("En F Lon mve NTH"),
            mk_order("En F CHN msup Lon"),
            mk_order("Ge F NTH con Kie"),
            mk_order("Ge A Kie mve Lon"),
        ], )
    # act
    result = conflict_game(situation)
    # assert
    expected = ConflictResolution(
        orders=[
            # conflict 02: Vie can not move, Mun holds
            mk_oresult("Au A Vie mve Mun !"),
            mk_oresult("Ge A Mun hld Mun"),
            # conflict 03: Lon moves and breaks convoy, NTH dislodged, Kie fails.
            mk_oresult("En F Lon mve NTH"),
            mk_oresult("En F CHN msup Lon"),
            mk_oresult("Ge F NTH con Kie >"),
            mk_oresult("Ge A Kie mve Lon !"),
        ],
        pattfields=set())
    assert result <= expected, f"\nres: {result.__log__()} !=\nexp: {expected.__log__()}"  # or use == with clear_originals().
Beispiel #2
0
def test_6_a_11():
    """
    === 6.A.11. TEST CASE, SIMPLE BOUNCE ===

    Two armies bouncing on each other.

        Austria:
        A Vienna - Tyrolia

        Italy:
        A Venice - Tyrolia

    The two units bounce.
    """
    # arrange
    situation: Situation = Situation(orders=[
        mk_order("Au A Vie mve Tyr"),
        mk_order("It A Ven mve Tyr"),
    ], )
    # act
    result = conflict_game(situation)
    # assert
    expected = ConflictResolution(
        orders=[
            mk_oresult(
                "Au A Vie mve Tyr !"
            ),  # TODO check if its ok to not change dest field along with order.
            mk_oresult(
                "It A Ven mve Tyr !"
            ),  # TODO check if its ok to not change dest field along with order.
        ],
        pattfields={"Tyr"})
    result.show(sys.stderr, line_prefix="| ")
    # '<=' ignores 'original'
    assert result <= expected, f"\nres: {result.__log__()} !=\nexp: {expected.__log__()}"
Beispiel #3
0
 def test_testdata(self, id, orders, order_results, pattfields):
     # arrange
     situation: Situation = Situation(orders=orders)
     # act
     result = conflict_game(situation)
     # assert
     expected = ConflictResolution(orders=order_results,
                                   pattfields=pattfields)
     # '<=' ignores 'original'
     assert result <= expected, f"\nres: {result.__log__()} !=\nexp: {expected.__log__()}"
Beispiel #4
0
def test_conflict_game_01():
    # arrange
    situation: Situation = Situation(orders=[
        mk_order_h("Ge A Mun hld"),
    ], )
    # act
    result = conflict_game(situation)
    # assert
    expected = ConflictResolution(orders=[
        mk_oresult("Ge A Mun hld Mun"),
    ],
                                  pattfields=set())
    assert result <= expected  # or use == with clear_originals().
Beispiel #5
0
def test_conflict_game_01a():
    # arrange
    situation: Situation = Situation(orders=[
        mk_order("Ge A Mun mve Kie"),
    ], )
    # act
    result = conflict_game(situation)
    # assert
    expected = ConflictResolution(orders=[
        mk_oresult("Ge A Mun mve Kie"),
    ],
                                  pattfields=set())
    # '<=' ignores 'original'
    assert result <= expected, f"\nres: {result.__log__()} !=\nexp: {expected.__log__()}"
Beispiel #6
0
def test_conflict_game_03():
    # arrange
    situation: Situation = Situation(orders=[
        mk_order("En F Lon mve NTH"),
        mk_order("En F CHN msup Lon"),
        mk_order("Ge F NTH con Kie"),
        mk_order("Ge A Kie mve Lon"),
    ], )
    # act
    result = conflict_game(situation)
    # assert
    expected = ConflictResolution(orders=[
        mk_oresult("En F Lon mve NTH"),
        mk_oresult("En F CHN msup Lon"),
        mk_oresult("Ge F NTH con Kie >"),
        mk_oresult("Ge A Kie mve Lon !"),
    ],
                                  pattfields=set())
    assert result <= expected  # or use == with clear_originals().
Beispiel #7
0
def test_conflict_game_patt_01():
    # arrange
    situation: Situation = Situation(orders=[
        mk_order("Ge A Mun mve Vie"),
        mk_order("Au A Tri mve Vie"),
    ], )
    # act
    result = conflict_game(situation)
    # assert
    expected = ConflictResolution(
        orders=[
            mk_oresult("Ge A Mun hld Vie !"
                       ),  # TODO check if changed order but kept dest is ok
            mk_oresult("Au A Tri hld Vie !"
                       ),  # TODO check if changed order but kept dest is ok
        ],
        pattfields={"Vie"})
    assert result <= expected, f"\nres: {result.__log__()}\nexp: {expected.__log__()}"  # or use == with clear_originals().
    assert result.clear_originals(
    ) == expected  # or use <= to keep information
Beispiel #8
0
def test_conflict_game_02():
    # arrange
    situation: Situation = Situation(orders=[
        mk_order("Au A Vie mve Mun"),
        mk_order_0("Ge A Mun"),
    ],
                                     switches=Switches(verbose=True))
    # act
    result = conflict_game(situation)
    # assert
    expected = ConflictResolution(
        orders=[
            mk_oresult(
                "Au A Vie hld Mun !"
            ),  # TODO check if its ok to not change dest field along with order.
            mk_oresult("Ge A Mun hld Mun"),
        ],
        pattfields=set())
    # '<=' ignores 'original'
    assert result <= expected, f"\nres: {result.__log__()} !=\nexp: {expected.__log__()}"
    # better way using '==' but loosing information.
    assert result.clear_originals(
    ) == expected, f"\nres: {result.__log__()} !=\nexp: {expected.__log__()}"