Commits

Tetsuya Morimoto committed 436b087

added MemoryHistoryStore component tests

  • Participants
  • Parent commits 19d3955

Comments (0)

Files changed (2)

File tests/test_memory_history_store.py

+# -*- coding: utf-8 -*-
+import time
+
+import pytest
+
+from traccron.history import MemoryHistoryStore
+
+time_now = time.time()
+
+
+def pytest_funcarg__memory_history_store(request, component):
+    memory_history_store = component['memory_history_store']
+    return memory_history_store
+
+@pytest.mark.parametrize("values", [
+    [],
+
+    [(object(), time_now + 1, time_now + 11, True)],
+
+    [(object(), time_now + 2, time_now + 12, True),
+     (object(), time_now + 3, time_now + 13, False),
+     (object(), time_now + 4, time_now + 14, True),
+     ],
+])
+def test_memory_history_store_basic_action(memory_history_store, values):
+    init_num = len(memory_history_store.history)
+    hist_value_num = len(values)
+    for value in values:
+        memory_history_store.addExecution(*value)
+    current_num = init_num + hist_value_num
+    assert current_num == len(MemoryHistoryStore.history)
+    assert current_num == len(list(memory_history_store.getExecution()))
+    memory_history_store.clear()
+    assert 0 == len(memory_history_store.history)

File tests/test_ticker.py

     return ticker
 
 
-def test_basic_ticker_action(ticker):
+def test_ticker_basic_action(ticker):
     try:
         assert ticker.timer.isAlive()
         assert 60 == ticker.timer.interval