

def test_request(self):
    logging.debug('')
    logging.debug('test_request')
    assembly = Assembly()
    comp1 = assembly.add('comp1', ExtCode())
    comp2 = assembly.add('comp2', ExtCode())
    sub = assembly.add('sub', Assembly())
    comp3 = sub.add('comp3', ExtCode())
    comp1.resources = dict(min_cpus=10, max_cpus=10, resource_limits=dict(virtual_memory=100, cpu_time=120), rerunnable=True, accounting_id='frobozz', queue_name='debug', job_category='MPI')
    comp2.resources = dict(max_cpus=2, resource_limits=dict(wallclock_time=1000000))
    comp3.resources = dict(min_cpus=200, resource_limits=dict(virtual_memory=20, cpu_time=1000, wallclock_time=500), rerunnable=True, accounting_id='frobozz', queue_name='debug', job_category='MPI')
    req = RAM.max_request(assembly)
    expected = dict(min_cpus=200, max_cpus=200, resource_limits=dict(virtual_memory=100, cpu_time=1000, wallclock_time=1000000))
    logging.debug('req: %r', req)
    logging.debug('exp: %r', expected)
    self.assertEqual(req, expected)
    req = RAM.total_request(assembly)
    expected = dict(min_cpus=200, max_cpus=200, resource_limits=dict(virtual_memory=100, cpu_time=1120, wallclock_time=1000500), rerunnable=True, accounting_id='frobozz', queue_name='debug', job_category='MPI')
    logging.debug('req: %r', req)
    logging.debug('exp: %r', expected)
    self.assertEqual(req, expected)
    comp3.resources['accounting_id'] = 'xyzzy'
    try:
        RAM.total_request(assembly)
    except ValueError as err:
        self.assertTrue(("Incompatible settings for 'accounting_id':" in str(err)))
        self.assertTrue(("'xyzzy'" in str(err)))
        self.assertTrue(("'frobozz'" in str(err)))
    else:
        self.fail('Exception expected')

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