Example #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
Example #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), )
Example #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)))
Example #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), )
Example #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
Example #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()
Example #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))
Example #8
0
def test_help():
    with pytest.raises(SystemExit):
        cli.main(args=['--help'])