'The memory limit number specified in an ``Application`` is passed to
the container.'

@if_docker_configured
def test_memory_limit(self):

    EXPECTED_MEMORY_LIMIT = 100000000
    image = DockerImage.from_string(u'openshift/busybox-http-app')
    application_name = random_name(self)
    docker_client = DockerClient()
    self.addCleanup(docker_client.remove, application_name)
    deployer = ApplicationNodeDeployer(u'localhost', docker_client, node_uuid=uuid4())
    desired_state = Deployment(nodes=frozenset([Node(uuid=deployer.node_uuid, applications=frozenset([Application(name=application_name, image=image, memory_limit=EXPECTED_MEMORY_LIMIT)]))]))
    d = change_node_state(deployer, desired_state)
    d.addCallback((lambda _: wait_for_unit_state(reactor, docker_client, application_name, [u'active'])))
    def inspect_application(_):
        deferred_list = docker_client.list()
        def app_memory(unit):
            self.assertEqual(unit.mem_limit, EXPECTED_MEMORY_LIMIT)
        deferred_list.addCallback(find_unit, application_name)
        deferred_list.addCallback(app_memory)
        return deferred_list
    d.addCallback(inspect_application)
    return d
