Пример #1
0
    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'