

def test_resources(self):
    logging.debug('')
    logging.debug('test_resources')
    result = RAM.allocate({
        'localhost': False,
    })
    self.assertEqual(result, (None, None))
    result = RAM.allocate({
        'exclude': [platform.node()],
    })
    self.assertEqual(result, (None, None))
    result = RAM.allocate({
        'min_cpus': 1000000,
    })
    self.assertEqual(result, (None, None))
    result = RAM.allocate({
        'orphan_modules': ['xyzzy'],
    })
    self.assertEqual(result, (None, None))
    result = RAM.allocate({
        'python_version': '2.999',
    })
    self.assertEqual(result, (None, None))
    start_time = datetime.datetime(2012, 2, 8, 16, 42)
    resource_limits = {
        
    }
    for (i, limit) in enumerate(RESOURCE_LIMITS):
        resource_limits[limit] = i
    RAM.validate_resources(dict(remote_command='echo', args=['hello', 'world'], submit_as_hold=True, rerunnable=True, job_environment={
        'ENV_VAR': 'env_value',
    }, working_directory='.', job_category='MPI', min_cpus=256, max_cpus=512, email=['user1@host1', 'user2@host2'], email_on_started=True, email_on_terminated=True, job_name='TestJob', input_path='echo.in', output_path='echo.out', error_path='echo.err', join_files=True, reservation_id='res-1234', queue_name='debug_q', priority=42, start_time=start_time, resource_limits=resource_limits, accounting_id='CFD-R-US', native_specification=('-ac', 'name=value')))
    code = 'RAM.validate_resources(dict(max_cpus=2))'
    assert_raises(self, code, globals(), locals(), KeyError, "'min_cpus required if max_cpus specified'")
    code = 'RAM.validate_resources(dict(min_cpus=2, max_cpus=1))'
    assert_raises(self, code, globals(), locals(), ValueError, 'max_cpus 1 < min_cpus 2')
    code = 'RAM.validate_resources(dict(min_cpus=-2))'
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'min_cpus': -2")
    code = "RAM.validate_resources(dict(args='hello'))"
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'args': 'hello'")
    code = "RAM.validate_resources(dict(args=['hello', 42]))"
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'args': ['hello', 42]")
    code = "RAM.validate_resources(dict(allocator='NoSuchAllocator'))"
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'allocator': 'NoSuchAllocator'")
    code = "RAM.validate_resources(dict(job_environment='hello'))"
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'job_environment': 'hello'")
    env = {
        
    }
    env[3] = 'hello'
    code = 'RAM.validate_resources(dict(job_environment=env))'
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'job_environment': {3: 'hello'}")
    env = {
        
    }
    env['hello there'] = 'world'
    code = 'RAM.validate_resources(dict(job_environment=env))'
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'job_environment': {'hello there': 'world'}")
    env = {
        
    }
    env['hello'] = 3
    code = 'RAM.validate_resources(dict(job_environment=env))'
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'job_environment': {'hello': 3}")
    code = "RAM.validate_resources(dict(resource_limits='hello'))"
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'resource_limits': 'hello'")
    limits = {
        
    }
    limits['no-such-resource'] = 1
    code = 'RAM.validate_resources(dict(resource_limits=limits))'
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'resource_limits': {'no-such-resource': 1}")
    limits = {
        
    }
    limits['wallclock_time'] = 'infinite'
    code = 'RAM.validate_resources(dict(resource_limits=limits))'
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'resource_limits': {'wallclock_time': 'infinite'}")
    limits = {
        
    }
    limits['wallclock_time'] = (- 1)
    code = 'RAM.validate_resources(dict(resource_limits=limits))'
    assert_raises(self, code, globals(), locals(), ValueError, "Invalid resource value for 'resource_limits': {'wallclock_time': -1}")
    code = 'RAM.validate_resources(dict(no_such_resource=2))'
    assert_raises(self, code, globals(), locals(), KeyError, '"Invalid resource key \'no_such_resource\'"')

dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/test/test_resource.py TestCase.test_resources/original