diff options
author | Setepenre <pierre.delaunay.tr@gmail.com> | 2019-02-05 11:13:38 -0600 |
---|---|---|
committer | Setepenre <pierre.delaunay.tr@gmail.com> | 2019-04-18 11:23:06 -0400 |
commit | a1508abc80278d5004c4bf7ec6b7814a2358dbff (patch) | |
tree | d00804bd7169fe7f91a3d9005712460ccef91b50 /diplomacy/tests/test_game.py | |
parent | 0c75691479ddfde6db7f80432a1f38cfcc051eb6 (diff) |
Add _unit_owner caching (#11)
Diffstat (limited to 'diplomacy/tests/test_game.py')
-rw-r--r-- | diplomacy/tests/test_game.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/diplomacy/tests/test_game.py b/diplomacy/tests/test_game.py index 76ba146..20994c8 100644 --- a/diplomacy/tests/test_game.py +++ b/diplomacy/tests/test_game.py @@ -515,6 +515,7 @@ def test_set_current_phase(): power = game.get_power('FRANCE') power.units.remove('A PAR') game.set_current_phase('W1901A') + game.clear_cache() assert game.get_current_phase() == 'W1901A' assert game.phase_type == 'A' assert 'A PAR B' in game.get_all_possible_orders('PAR') @@ -648,3 +649,20 @@ def test_result_history(): phase_data = game.get_phase_from_history(short_phase_name) assert 'bounce' in phase_data.results['A PAR'] assert 'bounce' in phase_data.results['A MAR'] + +def test_unit_owner(): + """ Test Unit Owner Resolver making sure the cached results are correct """ + game = Game() + print(game.get_units('RUSSIA')) + + assert game._unit_owner('F STP/SC', coast_required=1) is game.get_power('RUSSIA') # pylint: disable=protected-access + assert game._unit_owner('F STP/SC', coast_required=0) is game.get_power('RUSSIA') # pylint: disable=protected-access + + assert game._unit_owner('F STP', coast_required=1) is None # pylint: disable=protected-access + assert game._unit_owner('F STP', coast_required=0) is game.get_power('RUSSIA') # pylint: disable=protected-access + + assert game._unit_owner('A WAR', coast_required=0) is game.get_power('RUSSIA') # pylint: disable=protected-access + assert game._unit_owner('A WAR', coast_required=1) is game.get_power('RUSSIA') # pylint: disable=protected-access + + assert game._unit_owner('F SEV', coast_required=0) is game.get_power('RUSSIA') # pylint: disable=protected-access + assert game._unit_owner('F SEV', coast_required=1) is game.get_power('RUSSIA') # pylint: disable=protected-access |