예제 #1
0
 def test_allows_only_checklists_from_whitelist(self):
     checklist_ok = Checklist('foo', [])
     checklist_error = Checklist('bar', [])
     whitelist = [checklist_ok.name]
     predicate = WhitelistChecklistFilterPredicate(whitelist)
     self.assertTrue(predicate(checklist_ok))
     self.assertFalse(predicate(checklist_error))
예제 #2
0
 def setUp(self):
     self._name = 'test_checklist'
     self._result1 = mock.Mock(TaskResult)
     self._result1.status = TaskResultStatus.INFO
     self._result1.message = 'msg1'
     self._task1 = asynctest.mock.Mock(BaseTask)
     self._task1.execute.return_value = self._result1
     self._result2 = mock.Mock(TaskResult)
     self._result2.status = TaskResultStatus.SUCCESS
     self._result2.message = 'msg2'
     self._task2 = asynctest.mock.Mock(BaseTask)
     self._task2.execute.return_value = self._result2
     self._result_builder = mock.Mock(MultiTaskResultBuilder)
     self._checklist = Checklist(self._name, [self._task1, self._task2],
                                 self._result_builder)
예제 #3
0
 def get_checklist(
         self,
         configuration: BaseChecklistSourceConfiguration) -> Checklist:
     return Checklist("simple_checklist", [FileExistsTask(Path(__file__))])
 def __init__(self, sources: Iterator[yarl.URL]) -> None:
     super().__init__(
         StaticChecklistsProvider([
             Checklist('external', (ExternalChecklistTask(source)
                                    for source in sources))
         ]))
예제 #5
0
 async def test_defaults(self):
     _checklist = Checklist(self._name, [self._task1, self._task2])
     result = await _checklist.execute()
     self.assertEqual(result.status, TaskResultStatus.SUCCESS)
     self.assertEqual(result.message,
                      'Checklist [test_checklist]: Task success.')
예제 #6
0
 def test_always_return_true(self):
     predicate = AllowAllChecklistsFilterPredicate()
     inputs = ['', None, Checklist('test', [])]
     for arg in inputs:
         self.assertTrue(predicate(arg))
예제 #7
0
 def test_requires_container(self):
     predicate = WhitelistChecklistFilterPredicate(None)
     with self.assertRaises(TypeError):
         predicate(Checklist('foo', []))