def setUpClass(cls):
        """ Set up this TestCase module.

        This setup code sets up shared objects between each tests. This is done
        *once* before running any of the tests within this class.

        """

        # TODO: We might want this basic class setup in other TestCases. Maybe
        #       set up a generic TestCase class to inherit common stuff from?
        cls._db = Factory.get('Database')()
        cls._db.cl_init(change_program='nosetests')
        cls._db.commit = cls._db.rollback  # Let's try not to screw up the db

        cls._pe = Factory.get('Person')(cls._db)
        cls._ac = Factory.get('Account')(cls._db)
        cls._gr = Factory.get('Group')(cls._db)
        cls._ou = Factory.get('OU')(cls._db)
        cls._co = Factory.get('Constants')(cls._db)

        # Data sources
        cls.account_ds = BasicAccountSource()
        cls.person_ds = BasicPersonSource()

        # Tools for creating and destroying temporary db items
        cls.db_tools = DatabaseTools(cls._db)
        cls.db_tools._ac = cls._ac
示例#2
0
    def setUpClass(cls):
        cls._db = Factory.get('Database')()
        cls._db.cl_init(change_program='nosetests')
        cls._db.commit = cls._db.rollback  # Let's try not to screw up the db

        cls._pe = Factory.get('Person')(cls._db)
        cls._ac = Factory.get('Account')(cls._db)
        cls._co = Factory.get('Constants')(cls._db)
        cls._er = Ephorte.EphorteRole(cls._db)
        cls._ep = Ephorte.EphortePermission(cls._db)

        cls.person_ds = BasicPersonSource()
        cls.account_ds = BasicAccountSource()
        cls.db_tools = DatabaseTools(cls._db)
示例#3
0
    def setUpClass(cls):
        """ Setting up the TestCase module.

        The AD sync needs to be set up with standard configuration.
        """
        cls._db = Factory.get('Database')()
        cls._db.cl_init(change_program='nosetests')
        cls._db.commit = cls._db.rollback  # Let's try not to screw up the db
        cls._co = Factory.get('Constants')(cls._db)
        cls._ac = Factory.get('Account')(cls._db)
        cls._gr = Factory.get('Group')(cls._db)

        # Data sources
        cls.account_ds = BasicAccountSource()
        cls.person_ds = BasicPersonSource()

        # Tools for creating and destroying temporary db items
        cls.db_tools = DatabaseTools(cls._db)

        # Add some constanst for the tests
        cls.const_spread_ad_user = cls.db_tools.insert_constant(
            Constants._SpreadCode, 'account@ad_test',
            cls._co.entity_account, 'User in test AD')
        cls.const_spread_ad_group = cls.db_tools.insert_constant(
            Constants._SpreadCode, 'group@ad_test',
            cls._co.entity_group, 'Group in test AD')

        # Creating a sample config to be tweaked on in the different test cases
        # Override for the different tests.
        cls.standard_config = {
            'sync_type': 'test123',
            'domain': 'nose.local',
            'server': 'localserver',
            'target_ou': 'OU=Cerebrum,DC=nose,DC=local',
            'search_ou': 'OU=Cerebrum,DC=nose,DC=local',
            'object_classes': (
                'Cerebrum.modules.ad2.CerebrumData/CerebrumEntity',),
            'target_type': cls._co.entity_account,
        }
        # Make sure every reuquired setting is in place:
        for var in ADSync.BaseSync.settings_required:
            if var not in cls.standard_config:
                cls.standard_config[var] = 'random'
        # Override the AD client with a mock client:
        ADSync.BaseSync.server_class = MockADclient
        # Force in an object type in the Base class. The BaseSync should not
        # work, only its subclasses, but we want to be able to test the basic
        # functionality:
        ADSync.BaseSync.default_ad_object_class = 'object'
def setup_module():
    global db, ac, co, account_ds, db_tools
    db = Factory.get('Database')()
    db.cl_init(change_program='nosetests')
    db.commit = db.rollback

    account_class = Factory.get('Account')
    if PasswordHistoryMixin not in account_class.mro():
        raise SkipTest("No PasswordHistory configured, skipping module.")

    ac = account_class(db)
    co = Factory.get('Constants')(db)

    # Data sources
    account_ds = BasicAccountSource()

    # Tools for creating and destroying temporary db items
    db_tools = DatabaseTools(db)
    db_tools._ac = ac