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 ConcreteWorker(AbstractWorker):
            pass

        worker = ConcreteWorker("worker", "pass")
        workerforbuilder = AbstractWorkerForBuilder()
        # FIXME: This should call attached, instead of setting the attribute
        # directly
        workerforbuilder.worker = worker

        # The following shouldn't raise an exception.
        workerforbuilder.buildStarted()
    def test_buildStarted_missing(self):
        """
        If the worker associated to worker builder doesn't not have a
        ``buildStarted`` method, calling ``buildStarted`` on the worker builder
        doesn't raise an exception.
        """
        class ConcreteWorker(AbstractWorker):
            pass

        worker = ConcreteWorker("worker", "pass")
        workerforbuilder = AbstractWorkerForBuilder()
        # FIXME: This should call attached, instead of setting the attribute
        # directly
        workerforbuilder.worker = worker

        # The following shouldn't raise an exception.
        workerforbuilder.buildStarted()
    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 workerforbuilder as an argument.
        """
        class ConcreteWorker(AbstractWorker):
            _buildStartedCalls = []

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

        worker = ConcreteWorker("worker", "pass")
        workerforbuilder = AbstractWorkerForBuilder()
        # FIXME: This should call attached, instead of setting the attribute
        # directly
        workerforbuilder.worker = worker
        workerforbuilder.buildStarted()

        self.assertEqual(ConcreteWorker._buildStartedCalls, [workerforbuilder])
    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 workerforbuilder as an argument.
        """
        class ConcreteWorker(AbstractWorker):
            _buildStartedCalls = []

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

        worker = ConcreteWorker("worker", "pass")
        workerforbuilder = AbstractWorkerForBuilder()
        # FIXME: This should call attached, instead of setting the attribute
        # directly
        workerforbuilder.worker = worker
        workerforbuilder.buildStarted()

        self.assertEqual(ConcreteWorker._buildStartedCalls, [workerforbuilder])
    def test_worker_old_api(self):
        w = AbstractWorkerForBuilder()

        with assertNotProducesWarnings(DeprecatedWorkerAPIWarning):
            new_worker = w.worker

        with assertProducesWarning(
                DeprecatedWorkerNameWarning,
                message_pattern="'slave' attribute is deprecated"):
            old_worker = w.slave

        self.assertTrue(new_worker is old_worker)