fixed issue when sorting hook when saving to xml, due to enum refactoring, updated test case to hit this potential issue in the future

This commit is contained in:
Blake Harnden 2020-05-11 12:41:57 -07:00
parent 3fac6bc7ec
commit 124d655dc6
2 changed files with 7 additions and 2 deletions

View file

@ -312,7 +312,7 @@ class CoreXmlWriter:
def write_session_hooks(self) -> None:
# hook scripts
hooks = etree.Element("session_hooks")
for state in sorted(self.session._hooks.keys()):
for state in sorted(self.session._hooks, key=lambda x: x.value):
for file_name, data in self.session._hooks[state]:
hook = etree.SubElement(hooks, "hook")
add_attribute(hook, "name", file_name)

View file

@ -17,12 +17,17 @@ class TestXml:
:param session: session for test
:param tmpdir: tmpdir to create data in
"""
# create hook
# create hooks
file_name = "runtime_hook.sh"
data = "#!/bin/sh\necho hello"
state = EventTypes.RUNTIME_STATE
session.add_hook(state, file_name, None, data)
file_name = "instantiation_hook.sh"
data = "#!/bin/sh\necho hello"
state = EventTypes.INSTANTIATION_STATE
session.add_hook(state, file_name, None, data)
# save xml
xml_file = tmpdir.join("session.xml")
file_path = xml_file.strpath