-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
31 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |