Tetsuya Morimoto avatar Tetsuya Morimoto committed 3dbcc77

added HistoryTaskEvent component tests

Comments (0)

Files changed (2)

tests/test_core.py

     assert _isinstances(history_list, history_classes)
 
     # clear history
-    start = time.time()
-    end = start + 3600
-    for hist in history_list:
-        hist.addExecution(object(), start, end, True)
-        assert 1 == len(hist.history)
-    core.clearHistory()
-    for hist in history_list:
-        assert 0 == len(hist.history)
+    core.clearHistory()  # initialize
+    try:
+        start = time.time()
+        end = start + 3600
+        for hist in history_list:
+            hist.addExecution(object(), start, end, True)
+            assert 1 == len(hist.history)
+    finally:
+        core.clearHistory()
+        for hist in history_list:
+            assert 0 == len(hist.history)
 
 
 def test_getTaskListnerList(core):

tests/test_history_task_event.py

+# -*- coding: utf-8 -*-
+import pytest
+
+
+def pytest_funcarg__task(request, component):
+    task = component['heart_beat_task']
+    return task
+
+def pytest_funcarg__memory_history_store(request, component):
+    memory_history_store = component['memory_history_store']
+    return memory_history_store
+
+def pytest_funcarg__history_task_event(request, component):
+    history_task_event = component['history_task_event']
+    return history_task_event
+
+
+def test_history_task_event_basic(history_task_event,
+                                  task, memory_history_store):
+    assert 'history_task_event' == history_task_event.getId()
+
+    memory_history_store.clear()  # initialize
+    # operate tasks
+    try:
+        history_task_event.onStartTask(task)
+        history_task_event.onEndTask(task, True)
+        assert 1 == len(list(memory_history_store.getExecution()))
+
+        history_task_event.onStartTask(task)
+        history_task_event.onEndTask(task, True)
+        assert 2 == len(list(memory_history_store.getExecution()))
+    finally:
+        memory_history_store.clear()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.