# Path: tldap/transaction.py
# class TransactionManagementError(Exception):
# class Transaction(object):
# def enter_transaction_management(using=None):
# def leave_transaction_management(using=None):
# def is_dirty(using=None):
# def is_managed(using=None):
# def commit(using=None):
# def rollback(using=None):
#     def __init__(self, entering, exiting, using):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, traceback):
#     def __call__(self, func):
#         def inner(*args, **kwargs):
# def _transaction_func(entering, exiting, using):
# def commit_on_success(using=None):
#     def entering(using):
#     def exiting(exc_value, using):
# def commit_manually(using=None):
#     def entering(using):
#     def exiting(exc_value, using):


import os
import pytest
import tldap
import tldap.backend
import tldap.database
from ldap3.core import exceptions
from pytest_bdd import given, when, then, parsers
from tldap import transaction




@pytest.fixture
def settings():
    return {
        'default': {
            'ENGINE': 'tldap.backend.fake_transactions',
            'URI': os.environ['LDAP_URL'],
            'USER': os.environ['LDAP_DN'],
            'PASSWORD': os.environ['LDAP_PASSWORD'],
            'USE_TLS': False,
            'TLS_CA': None,
            'LDAP_ACCOUNT_BASE': os.environ['LDAP_ACCOUNT_BASE'],
            'LDAP_GROUP_BASE': os.environ['LDAP_GROUP_BASE'],
            'NUMBER_SCHEME': 'default',
        }
    }


@pytest.fixture
def ldap(settings):
    tldap.backend.setup(settings)

    connection = tldap.backend.connections['default']


# Path: tldap/transaction.py
# class TransactionManagementError(Exception):
# class Transaction(object):
# def enter_transaction_management(using=None):
# def leave_transaction_management(using=None):
# def is_dirty(using=None):
# def is_managed(using=None):
# def commit(using=None):
# def rollback(using=None):
#     def __init__(self, entering, exiting, using):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, traceback):
#     def __call__(self, func):
#         def inner(*args, **kwargs):
# def _transaction_func(entering, exiting, using):
# def commit_on_success(using=None):
#     def entering(using):
#     def exiting(exc_value, using):
# def commit_manually(using=None):
#     def entering(using):
#     def exiting(exc_value, using):


# Path: tests/b_integration/conftest.py
import os
import pytest
import tldap
import tldap.backend
import tldap.database
from ldap3.core import exceptions
from pytest_bdd import given, when, then, parsers
from tldap import transaction





@pytest.fixture
def settings():
    return {
        'default': {
            'ENGINE': 'tldap.backend.fake_transactions',
            'URI': os.environ['LDAP_URL'],
            'USER': os.environ['LDAP_DN'],
            'PASSWORD': os.environ['LDAP_PASSWORD'],
            'USE_TLS': False,
            'TLS_CA': None,
            'LDAP_ACCOUNT_BASE': os.environ['LDAP_ACCOUNT_BASE'],
            'LDAP_GROUP_BASE': os.environ['LDAP_GROUP_BASE'],
            'NUMBER_SCHEME': 'default',
        }
    }


@pytest.fixture
def ldap(settings):
    tldap.backend.setup(settings)

    connection = tldap.backend.connections['default']


    with tldap.transaction.commit_manually():