def test_shell_cmd_not_found(): with pytest.raises(SystemExit) as excinfo: with testfixtures.LogCapture() as log_capture: cli.main(args=['create']) log_capture.check( ('gpucrate', 'ERROR', 'required command not found: doesnotexist'), ) assert excinfo.value.code == 2
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_create_root_required(): with pytest.raises(SystemExit): with testfixtures.LogCapture() as log_capture: cli.main(args=['create']) log_capture.check(('gpucrate', 'ERROR', exception.RootRequired.message), )
def test_gpu_crate_error(): with pytest.raises(SystemExit) as excinfo: with testfixtures.LogCapture() as log_capture: cli.main(args=["create"]) log_capture.check(('gpucrate', 'ERROR', 'gpucrate error')) assert excinfo.value.code == 1
def test_debug(): PDB.set_trace.reset_mock() with pytest.raises(SystemExit): cli.main(args=['--debug', 'create']) PDB.set_trace.assert_called_once()
def test_shell(): SHELL.reset_mock() cli.main(args=['shell'], test=True) SHELL.assert_called_once_with(local_ns=dict(log=cli.logger.log))
def test_help(): with pytest.raises(SystemExit): cli.main(args=['--help'])