def test_create_no_volume_root(): with pytest.raises(SystemExit): with testfixtures.LogCapture() as log_capture: with testfixtures.TempDirectory() as d: d.write('config', 'volume_root:') config.load(path=os.path.join(d.path, 'config')) cli.main(args=['create']) log_capture.check(('gpucrate', 'ERROR', exception.NoVolumeRoot.message), )
def test_create_volume_root_dne(): with testfixtures.LogCapture() as log_capture: with testfixtures.TempDirectory() as d: vroot = os.path.join(d.path, 'vroot') d.write('config', 'volume_root: {vroot}'.format(vroot=vroot)) config.load(path=os.path.join(d.path, 'config')) cli.main(args=['create']) assert os.path.isdir(vroot) log_capture.check( ('gpucrate', 'INFO', 'Volume root {vroot} does not exist - creating'.format(vroot=vroot)))
def test_singularity_gpu_volume_dne(): with pytest.raises(SystemExit): with testfixtures.LogCapture() as log_capture: with testfixtures.TempDirectory() as d: vroot = os.path.join(d.path, 'vroot') vol = os.path.join(vroot, TEST_DRIVER_VERSION) d.write('config', 'volume_root: {vroot}'.format(vroot=vroot)) config.load(path=os.path.join(d.path, 'config')) SINGULARITY.reset_mock() cli.singularity_gpu( args='exec -B /some/path:/some/path c.img'.split()) log_capture.check( ('gpucrate', 'ERROR', 'volume {vol} does not exist - run "gpucrate create"'.format( vol=vol)))
def test_with_config_file(): with testfixtures.TempDirectory() as d: vroot = '/path/to/some/gpucrate/root' d.write('config', 'volume_root: {vroot}'.format(vroot=vroot)) config.load(path=os.path.join(d.path, 'config')) assert config.get('volume_root') == vroot
def test_no_config_file(): with testfixtures.LogCapture() as log_capture: config.load() log_capture.check( ('gpucrate', 'WARNING', "Config not found: {cfg} - using internal " "defaults".format(cfg=config.DEFAULT_CONFIG_PATH)))