Browse Source

add test state: test to load a dumped state

Bastien Sevajol 5 years ago
parent
commit
8cc9e70e82
1 changed files with 15 additions and 0 deletions
  1. 15 0
      tests/test_state.py

+ 15 - 0
tests/test_state.py View File

@@ -1,5 +1,6 @@
1 1
 # coding: utf-8
2 2
 from collections import OrderedDict
3
+import time
3 4
 
4 5
 import pytest
5 6
 from synergine2.config import Config
@@ -173,3 +174,17 @@ def test_state__ok__dump(
173 174
         </subject>
174 175
     </subjects>
175 176
 </state>""" == state_xml_str
177
+
178
+def test_state__ok__dump_and_load(
179
+    config: Config,
180
+    simulation_for_dump: TileStrategySimulation,
181
+    state_loader,
182
+):
183
+    state_dumper = StateDumper(config, simulation_for_dump)
184
+    state_xml_str = state_dumper.get_state_dump()
185
+
186
+    tmp_file_name = '/tmp/{}.xml'.format(time.time())
187
+    with open(tmp_file_name, 'w+') as file:
188
+        file.write(state_xml_str)
189
+
190
+    state_loader.get_state(tmp_file_name)