Esempio n. 1
0
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
Esempio n. 2
0
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), )
Esempio n. 3
0
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)))
Esempio n. 4
0
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), )
Esempio n. 5
0
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
Esempio n. 6
0
def test_debug():
    PDB.set_trace.reset_mock()
    with pytest.raises(SystemExit):
        cli.main(args=['--debug', 'create'])
    PDB.set_trace.assert_called_once()
Esempio n. 7
0
def test_shell():
    SHELL.reset_mock()
    cli.main(args=['shell'], test=True)
    SHELL.assert_called_once_with(local_ns=dict(log=cli.logger.log))
Esempio n. 8
0
def test_help():
    with pytest.raises(SystemExit):
        cli.main(args=['--help'])