Browse Source

add test state: test to load a dumped state

Bastien Sevajol 6 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
 # coding: utf-8
1
 # coding: utf-8
2
 from collections import OrderedDict
2
 from collections import OrderedDict
3
+import time
3
 
4
 
4
 import pytest
5
 import pytest
5
 from synergine2.config import Config
6
 from synergine2.config import Config
173
         </subject>
174
         </subject>
174
     </subjects>
175
     </subjects>
175
 </state>""" == state_xml_str
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)