Ejemplo n.º 1
0
def test_init_new_role_already_exists(temp_dir, init_new_role_command_args,
                                      patched_logger_critical):
    init._init_new_role(init_new_role_command_args)

    with pytest.raises(SystemExit) as e:
        init._init_new_role(init_new_role_command_args)

    assert 1 == e.value.code

    msg = 'The directory test-role exists. Cannot create new role.'
    patched_logger_critical.assert_called_once_with(msg)
Ejemplo n.º 2
0
def test_init_new_role(temp_dir, init_new_role_command_args,
                       patched_logger_info, patched_logger_success):
    init._init_new_role(init_new_role_command_args)

    msg = 'Initializing new role test-role...'
    patched_logger_info.assert_called_once_with(msg)

    assert os.path.isdir('./test-role')
    assert os.path.isdir('./test-role/molecule/default')
    assert os.path.isdir('./test-role/molecule/default/tests')

    role_directory = os.path.join(temp_dir.strpath, 'test-role')
    msg = 'Initialized role in {} successfully.'.format(role_directory)
    patched_logger_success.assert_called_once_with(msg)