'The metadata is downloaded, decoded and returned.'

def test_success(self):

    expected_value = random_name(self)
    listening = webserver_for_test(self, url_path=('/' + '/'.join(METADATA_RELATIVE_PATH)), response_content=json.dumps({'test_key': expected_value}))
    connecting = listening.addCallback((lambda port: deferToThread(metadata_from_service, metadata_service_endpoint=next(((a.host, a.port) for a in [port.getHost()])))))
    def check(result):
        self.assertEqual(expected_value, result['test_key'])
    checking = connecting.addCallback(check)
    return checking
