コード例 #1
0
    def test_buildStarted_missing(self):
        """
        If the worker associated to worker builder doesn not have a
        ``buildStarted`` method, calling ``buildStarted`` on the worker builder
        doesn't raise an exception.
        """
        class ConcreteBuildWorker(AbstractBuildWorker):
            pass

        worker = ConcreteBuildWorker("worker", "pass")
        workerbuilder = AbstractWorkerBuilder()
        # FIXME: This should call attached, instead of setting the attribute
        # directly
        workerbuilder.worker = worker

        # The following shouldn't raise an exception.
        workerbuilder.buildStarted()
コード例 #2
0
    def test_buildStarted_called(self):
        """
        If the worker associated to worker builder has a ``buildStarted`` method,
        calling ``buildStarted`` on the worker builder calls the method on the
        worker with the workerbuilder as an argument.
        """
        class ConcreteBuildWorker(AbstractBuildWorker):
            _buildStartedCalls = []

            def buildStarted(self, workerbuilder):
                self._buildStartedCalls.append(workerbuilder)

        worker = ConcreteBuildWorker("worker", "pass")
        workerbuilder = AbstractWorkerBuilder()
        # FIXME: This should call attached, instead of setting the attribute
        # directly
        workerbuilder.worker = worker
        workerbuilder.buildStarted()

        self.assertEqual(ConcreteBuildWorker._buildStartedCalls, [workerbuilder])