示例#1
0
    def test_addProcessor_if_argument_CanProcess(self):
        composite = CanProcessComposite()

        with patch.object(composite, "_append_processor") as appendProcessorMock:
            composite.add_processor(CanProcess())

        self.assertEqual(appendProcessorMock.call_count, 1)
示例#2
0
    def test_addProcessor_if_argument_not_CanProcess(self):
        composite = CanProcessComposite()

        with patch.object(composite, "_append_processor") as appendProcessorMock:
            composite.add_processor(None)

        appendProcessorMock.assert_not_called()
    def test_process_calls_doBeforeProcess_if_present(self):
        composite = CanProcessComposite()

        with patch.object(composite, 'doBeforeProcess', create=True) as doBeforeProcessMock:
            composite.process(3.0)

        doBeforeProcessMock.assert_called_once_with(3.0)
    def test_addProcessor_if_argument_not_CanProcess(self):
        composite = CanProcessComposite()

        with patch.object(composite, '_append_processor') as appendProcessorMock:
            composite.add_processor(None)

        appendProcessorMock.assert_not_called()
    def test_addProcessor_if_argument_CanProcess(self):
        composite = CanProcessComposite()

        with patch.object(composite, '_append_processor') as appendProcessorMock:
            composite.add_processor(CanProcess())

        self.assertEqual(appendProcessorMock.call_count, 1)
    def test_process_calls_doBeforeProcess_if_present(self):
        composite = CanProcessComposite()

        with patch.object(composite, 'doBeforeProcess', create=True) as doBeforeProcessMock:
            composite.process(3.0)

        doBeforeProcessMock.assert_called_once_with(3.0)
    def test_init_from_iterable(self):
        with patch.object(CanProcess, 'doProcess', create=True) as mockProcessMethod:
            devices = (CanProcess(), CanProcess(),)

            composite = CanProcessComposite(devices)
            composite(4.0)

            mockProcessMethod.assert_has_calls([call(4.0), call(4.0)])