'Applications that are not running but are supposed to be on the local
node are restarted by Flocker (we cannot rely on Docker restart
policies to do so because FLOC-3148).'

def test_local_not_running_applications_restarted(self):

    api = ApplicationNodeDeployer(u'n.example.com', docker_client=FakeDockerClient(), node_uuid=uuid4())
    application_desired = Application(name=u'mysql-hybridcluster', image=DockerImage(repository=u'clusterhq/flocker', tag=u'release-14.0'))
    application_stopped = application_desired.set('running', False)
    nodes_desired = frozenset([Node(uuid=api.node_uuid, applications=frozenset([application_desired]))])
    node_state = NodeState(hostname=api.hostname, uuid=api.node_uuid, applications=[application_stopped])
    desired = Deployment(nodes=nodes_desired)
    result = api.calculate_changes(desired_configuration=desired, current_cluster_state=DeploymentState(nodes=[node_state]), local_state=NodeLocalState(node_state=node_state))
    expected = sequentially(changes=[in_parallel(changes=[sequentially(changes=[StopApplication(application=application_stopped), StartApplication(application=application_desired, node_state=node_state)])])])
    self.assertEqual(expected, result)
