diff options
author | Philip Paquette <pcpaquette@gmail.com> | 2019-09-13 12:33:52 -0400 |
---|---|---|
committer | Philip Paquette <pcpaquette@gmail.com> | 2019-09-14 18:18:53 -0400 |
commit | 90055c13d87970133230fd65ce3bbe14c4160ea6 (patch) | |
tree | 98a3833b057e9175fc4a641b852445236590efe0 /diplomacy/maps | |
parent | 12d712ab773c31e2d22f0708fc65366b85bd6c66 (diff) |
Implemented an internal convoy cache for common maps
- Displaying a message when convoy cache is being generated for other maps
Diffstat (limited to 'diplomacy/maps')
-rw-r--r-- | diplomacy/maps/convoy_paths_cache.pkl | bin | 0 -> 1383835 bytes | |||
-rw-r--r-- | diplomacy/maps/tests/test_map_gen.py | 19 |
2 files changed, 19 insertions, 0 deletions
diff --git a/diplomacy/maps/convoy_paths_cache.pkl b/diplomacy/maps/convoy_paths_cache.pkl Binary files differnew file mode 100644 index 0000000..d597dfc --- /dev/null +++ b/diplomacy/maps/convoy_paths_cache.pkl diff --git a/diplomacy/maps/tests/test_map_gen.py b/diplomacy/maps/tests/test_map_gen.py index 48084fb..c231d23 100644 --- a/diplomacy/maps/tests/test_map_gen.py +++ b/diplomacy/maps/tests/test_map_gen.py @@ -19,9 +19,11 @@ """ import glob import os +import pickle import sys from diplomacy.engine.map import Map +from diplomacy.utils.convoy_paths import INTERNAL_CACHE_PATH, get_file_md5 MODULE_PATH = sys.modules['diplomacy'].__path__[0] @@ -43,3 +45,20 @@ def test_map_with_full_path(): this_map = Map(current_map) assert this_map.error == [], 'Map %s should have no errors' % current_map del this_map + +def test_internal_cache(): + """ Tests that all maps with a SVG are in the internal cache """ + maps = glob.glob(os.path.join(MODULE_PATH, 'maps', '*.map')) + assert maps, 'Expected maps to be found.' + assert os.path.exists(INTERNAL_CACHE_PATH), 'Expected internal cache to exist' + + # Checking that maps with a svg are in the internal cache + with open(INTERNAL_CACHE_PATH, 'rb') as cache_file: + internal_cache = pickle.load(cache_file) + for current_map in maps: + map_name = current_map[current_map.rfind('/') + 1:].replace('.map', '') + this_map = Map(map_name) + if not this_map.svg_path: + continue + assert get_file_md5(current_map) in internal_cache, 'Map "%s" not found in internal cache' % map_name + del this_map |