'Applications that are not running and are not supposed to be on the
local node are added to the list of applications to stop.'

def test_not_local_not_running_applications_stopped(self):

    api = ApplicationNodeDeployer(u'example.com', docker_client=FakeDockerClient())
    to_stop = Application(name=u'myapp', image=DockerImage.from_string(u'postgres'), running=False)
    node_state = NodeState(hostname=api.hostname, applications={to_stop})
    result = api.calculate_changes(desired_configuration=EMPTY, current_cluster_state=DeploymentState(nodes=[node_state]), local_state=NodeLocalState(node_state=node_state))
    expected = sequentially(changes=[in_parallel(changes=[StopApplication(application=to_stop)])])
    self.assertEqual(expected, result)
