'Given Docker units, verifies that the correct applications are
discovered on the node by ``discover_state``.
:param units: ``units`` to pass into the constructor of the
``FakeDockerClient``.
:param expected_applications: A ``PSet`` of ``Application`` instances
expected to be in the ``NodeState`` returned by ``discover_state``
given the ``units`` in the ``FakeDockerClient``.
:param NodeState current_state: The local_state to pass into the call
of ``discover_state``.
:param bool start_applications: Whether to run ``StartApplication`` on
each of the applications before running ``discover_state``.'

def _verify_discover_state_applications(self, units, expected_applications, current_state=None, start_applications=False):

    if (current_state is None):
        current_state = self.EMPTY_NODESTATE
    fake_docker = FakeDockerClient(units=units)
    api = ApplicationNodeDeployer(self.hostname, node_uuid=self.node_uuid, docker_client=fake_docker)
    if start_applications:
        for app in expected_applications:
            StartApplication(node_state=NodeState(uuid=api.node_uuid, hostname=api.hostname), application=app).run(api, state_persister=InMemoryStatePersister())
    cluster_state = DeploymentState(nodes={current_state})
    d = api.discover_state(cluster_state, persistent_state=PersistentState())
    self.assertEqual(NodeState(uuid=api.node_uuid, hostname=api.hostname, applications=expected_applications), self.successResultOf(d).node_state)
