Skip to content

Commit

Permalink
Update test_stuck_running()
Browse files Browse the repository at this point in the history
For #19
  • Loading branch information
peterstory committed Jul 8, 2024
1 parent d246513 commit 2b5a21e
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions tests/test_gui.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
import unittest
from unittest.mock import patch

from pydiode.gui.common import stuck_running
from pydiode.gui.common import ProcessPipeline


class TestGUI(unittest.TestCase):
def test_stuck_running(self):
self.assertTrue(stuck_running([None, 0]))
self.assertTrue(stuck_running([None, None, 0]))
self.assertTrue(stuck_running([None, 0, None]))

self.assertFalse(stuck_running([0]))
self.assertFalse(stuck_running([None]))
def setUp(self):
self.pipeline = ProcessPipeline()

self.assertFalse(stuck_running([0, 0]))
self.assertFalse(stuck_running([0, None]))
self.assertFalse(stuck_running([0, None, None]))
self.assertFalse(stuck_running([0, 0, None]))
self.assertFalse(stuck_running([None, None]))
@patch.object(ProcessPipeline, "_returncodes")
def test_stuck_running(self, mock_returncodes):
# Stuck pipelines
mock_returncodes.return_value = [None, 0]
self.assertTrue(self.pipeline.stuck_running())
mock_returncodes.return_value = [None, None, 0]
self.assertTrue(self.pipeline.stuck_running())
mock_returncodes.return_value = [None, 0, None]
self.assertTrue(self.pipeline.stuck_running())

# Simple non-stuck pipelines
mock_returncodes.return_value = [0]
self.assertFalse(self.pipeline.stuck_running())
mock_returncodes.return_value = [None]
self.assertFalse(self.pipeline.stuck_running())

# Complex non-stuck pipelines
mock_returncodes.return_value = [0, 0]
self.assertFalse(self.pipeline.stuck_running())
mock_returncodes.return_value = [0, None]
self.assertFalse(self.pipeline.stuck_running())
mock_returncodes.return_value = [0, None, None]
self.assertFalse(self.pipeline.stuck_running())
mock_returncodes.return_value = [0, 0, None]
self.assertFalse(self.pipeline.stuck_running())
mock_returncodes.return_value = [None, None]
self.assertFalse(self.pipeline.stuck_running())

0 comments on commit 2b5a21e

Please sign in to comment.