Selenium - implement managed_history decorator for tests.

Creates and deletes a history for tests - good for tests meant to aim at production servers that need to have useful metadata and need to be cleaned up.
This commit is contained in:
John Chilton
2017-10-02 09:50:37 -04:00
parent 14d4367cc4
commit 395eefcbb2
4 changed files with 41 additions and 4 deletions
+22
View File
@@ -60,6 +60,28 @@ except ImportError:
return x
def managed_history(f):
"""Ensure a Selenium test has a distinct, named history.
Cleanup the history after the job is complete as well unless
GALAXY_TEST_NO_CLEANUP is set in the environment.
"""
@wraps(f)
def func_wrapper(self, *args, **kwds):
self.home()
history_name = f.__name__ + datetime.datetime.now().strftime("%Y%m%d%H%M%s")
self.history_panel_create_new_with_name(history_name)
try:
f(self, *args, **kwds)
finally:
if "GALAXY_TEST_NO_CLEANUP" not in os.environ:
current_history_id = self.current_history_id()
self.api_delete("histories/%s" % current_history_id)
return func_wrapper
@nottest
def selenium_test(f):