'An ``Application`` that is stopped, and then reconfigured such that it
would be restarted if it was running, will be restarted with the
new configuration.'

def test_stopped_app_with_change_restarted(self):

    api = ApplicationNodeDeployer(u'node1.example.com', docker_client=FakeDockerClient(), node_uuid=uuid4())
    old_postgres_app = Application(name=u'postgres-example', image=DockerImage.from_string(u'clusterhq/postgres:latest'), running=False)
    new_postgres_app = old_postgres_app.transform(['image'], DockerImage.from_string(u'docker/postgres:latest'), ['running'], True)
    desired = Deployment(nodes=[Node(uuid=api.node_uuid, applications={new_postgres_app})])
    node_state = NodeState(uuid=api.node_uuid, hostname=api.hostname, applications={old_postgres_app})
    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=old_postgres_app), StartApplication(application=new_postgres_app, node_state=node_state)])])])
    self.assertEqual(expected, result)
