def test_task_result_is_skipped(self):
        mock_host = MagicMock()
        mock_task = MagicMock()

        # test with no skipped in result
        tr = TaskResult(mock_host, mock_task, dict())
        self.assertFalse(tr.is_skipped())

        # test with skipped in the result
        tr = TaskResult(mock_host, mock_task, dict(skipped=True))
        self.assertTrue(tr.is_skipped())

        # test with multiple results but none skipped
        mock_task.loop = 'foo'
        tr = TaskResult(mock_host, mock_task, dict(results=[dict(foo='bar'), dict(bam='baz'), True]))
        self.assertFalse(tr.is_skipped())

        # test with multiple results and one skipped
        mock_task.loop = 'foo'
        tr = TaskResult(mock_host, mock_task, dict(results=[dict(skipped=False), dict(skipped=True), dict(some_key=False)]))
        self.assertFalse(tr.is_skipped())

        # test with multiple results and all skipped
        mock_task.loop = 'foo'
        tr = TaskResult(mock_host, mock_task, dict(results=[dict(skipped=True), dict(skipped=True), dict(skipped=True)]))
        self.assertTrue(tr.is_skipped())

        # test with multiple squashed results (list of strings)
        # first with the main result having skipped=False
        mock_task.loop = 'foo'
        tr = TaskResult(mock_host, mock_task, dict(results=["a", "b", "c"], skipped=False))
        self.assertFalse(tr.is_skipped())
        # then with the main result having skipped=True
        tr = TaskResult(mock_host, mock_task, dict(results=["a", "b", "c"], skipped=True))
        self.assertTrue(tr.is_skipped())
Example #2
0
    def test_task_result_is_skipped(self):
        mock_host = MagicMock()
        mock_task = MagicMock()

        # test with no skipped in result
        tr = TaskResult(mock_host, mock_task, dict())
        self.assertFalse(tr.is_skipped())

        # test with skipped in the result
        tr = TaskResult(mock_host, mock_task, dict(skipped=True))
        self.assertTrue(tr.is_skipped())

        # test with multiple results but none skipped
        mock_task.loop = 'foo'
        tr = TaskResult(mock_host, mock_task, dict(results=[dict(foo='bar'), dict(bam='baz'), True]))
        self.assertFalse(tr.is_skipped())

        # test with multiple results and one skipped
        mock_task.loop = 'foo'
        tr = TaskResult(mock_host, mock_task, dict(results=[dict(skipped=False), dict(skipped=True), dict(some_key=False)]))
        self.assertFalse(tr.is_skipped())

        # test with multiple results and all skipped
        mock_task.loop = 'foo'
        tr = TaskResult(mock_host, mock_task, dict(results=[dict(skipped=True), dict(skipped=True), dict(skipped=True)]))
        self.assertTrue(tr.is_skipped())

        # test with multiple squashed results (list of strings)
        # first with the main result having skipped=False
        mock_task.loop = 'foo'
        tr = TaskResult(mock_host, mock_task, dict(results=["a", "b", "c"], skipped=False))
        self.assertFalse(tr.is_skipped())
        # then with the main result having skipped=True
        tr = TaskResult(mock_host, mock_task, dict(results=["a", "b", "c"], skipped=True))
        self.assertTrue(tr.is_skipped())
    def test_task_result_is_skipped(self):
        mock_host = MagicMock()
        mock_task = MagicMock()

        # test with no skipped in result
        tr = TaskResult(mock_host, mock_task, dict())
        self.assertFalse(tr.is_skipped())

        # test with skipped in the result
        tr = TaskResult(mock_host, mock_task, dict(skipped=True))
        self.assertTrue(tr.is_skipped())

        # test with multiple results but none skipped
        mock_task.loop = 'foo'
        tr = TaskResult(mock_host, mock_task,
                        dict(results=[dict(
                            foo='bar'), dict(bam='baz'), True]))
        self.assertFalse(tr.is_skipped())

        # test with multiple results and one skipped
        mock_task.loop = 'foo'
        tr = TaskResult(
            mock_host, mock_task,
            dict(results=[
                dict(skipped=False),
                dict(skipped=True),
                dict(some_key=False)
            ]))
        self.assertFalse(tr.is_skipped())

        # test with multiple results and all skipped
        mock_task.loop = 'foo'
        tr = TaskResult(
            mock_host, mock_task,
            dict(results=[
                dict(skipped=True),
                dict(skipped=True),
                dict(skipped=True)
            ]))
        self.assertTrue(tr.is_skipped())