浏览代码

add test state: test to load a dumped state

Bastien Sevajol 6 年前
父节点
当前提交
8cc9e70e82
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. 15 0
      tests/test_state.py

+ 15 - 0
tests/test_state.py 查看文件

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)