'Determine whether or not the test requirements are satisfied.
If not, record the reason a skip or failure.
This may throw exceptions, which are immediate failure.
Args:
test_name: [string] The name of the test.
spec: [dict] The profile specification containing requirements.
This argument will be pruned as values are consumed from it.
Returns:
True if requirements are satisifed, False if not.'

def validate_test_requirements(self, test_name, spec):

    if (not ('api' in spec)):
        raise ValueError('Test    "{name}"    is    missing    an    "api"    spec.'.format(name=test_name))
    requires = spec.pop('requires', {})
    configuration = requires.pop('configuration', {})
    our_config = vars(self.options)
    for (key, value) in configuration.items():
        if (key not in our_config):
            message = 'Unknown    configuration    key    "{0}"    for    test    "{1}"'.format(key, test_name)
            raise KeyError(message)
        if (value != our_config[key]):
            reason = 'Skipped    test    {name}    because    {key}={want}    !=    {have}'.format(name=test_name, key=key, want=value, have=our_config[key])
            logging.warning(reason)
            with self.__lock:
                self.__skipped.append((test_name, reason))
            return False
    services = set(requires.pop('services', []))
    services.add(spec.pop('api'))
    if requires:
        raise ValueError('Unexpected    fields    in    {name}.requires:    {remaining}'.format(name=test_name, remaining=requires))
    if spec:
        raise ValueError('Unexpected    fields    in    {name}    specification:    {remaining}'.format(name=test_name, remaining=spec))
    thread_pool = ThreadPool(len(services))
    thread_pool.map(self.wait_on_service, services)
    thread_pool.terminate()
    return True
