Beispiel #1
0
    def setUp(self):
        _BaseTestCase.setUp(self)

        self.checks = ExtensionOrder(components=self.acctmgr.checks,
                                     list=self.acctmgr.register_checks)
        self.check_list = [
            'BasicCheck', 'EmailCheck', 'BotTrapCheck', 'RegExpCheck',
            'UsernamePermCheck'
        ]
        # Mock _setorder function call.
        for c in self.checks.get_all_components():
            c_name = c.__class__.__name__
            self.checks[c] = c_name in self.check_list and \
                             self.check_list.index(c_name) + 1 or 0
            continue
Beispiel #2
0
class ExtensionOrderTestCase(_BaseTestCase):
    def setUp(self):
        _BaseTestCase.setUp(self)

        self.checks = ExtensionOrder(components=self.acctmgr.checks,
                                     list=self.acctmgr.register_checks)
        self.check_list = [
            'BasicCheck', 'EmailCheck', 'BotTrapCheck', 'RegExpCheck',
            'UsernamePermCheck'
        ]
        # Mock _setorder function call.
        for c in self.checks.get_all_components():
            c_name = c.__class__.__name__
            self.checks[c] = c_name in self.check_list and \
                             self.check_list.index(c_name) + 1 or 0
            continue

    def test_component_count(self):
        self.assertEqual(self.checks.component_count(), 7)

    def test_get_enabled_components(self):
        enabled_components_count = 0
        for c in self.checks.get_enabled_components():
            c_name = c.__class__.__name__
            self.assertTrue(c_name in self.check_list + \
                            ['BadCheck', 'DummyCheck'])
            self.assertFalse(c_name in ['DisabledCheck'])
            enabled_components_count += 1
        self.assertEqual(enabled_components_count, 5)

    def test_get_enabled_component_names(self):
        self.assertEqual(self.checks.get_enabled_component_names(),
                         self.check_list)

    def test_get_all_components(self):
        all_components_count = 0
        for c in self.checks.get_all_components():
            c_name = c.__class__.__name__
            self.assertTrue(c_name in self.check_list + \
                            ['BadCheck', 'DummyCheck'])
            self.assertFalse(c_name in ['DisabledCheck'])
            all_components_count += 1
        self.assertEqual(all_components_count, 7)
class ExtensionOrderTestCase(_BaseTestCase):
    def setUp(self):
        _BaseTestCase.setUp(self)

        self.checks = ExtensionOrder(components=self.acctmgr.checks,
                                     list=self.acctmgr.register_checks)
        self.check_list = ['BasicCheck', 'EmailCheck', 'BotTrapCheck',
                           'RegExpCheck', 'UsernamePermCheck']
        # Mock _setorder function call.
        for c in self.checks.get_all_components():
            c_name = c.__class__.__name__
            self.checks[c] = c_name in self.check_list and \
                             self.check_list.index(c_name) + 1 or 0
            continue

    def test_component_count(self):
        self.assertEqual(self.checks.component_count(), 7)

    def test_get_enabled_components(self):
        enabled_components_count = 0
        for c in self.checks.get_enabled_components():
            c_name = c.__class__.__name__
            self.assertTrue(c_name in self.check_list +
                            ['BadCheck', 'DummyCheck'])
            self.assertFalse(c_name in ['DisabledCheck'])
            enabled_components_count += 1
        self.assertEqual(enabled_components_count, 5)

    def test_get_enabled_component_names(self):
        self.assertEqual(self.checks.get_enabled_component_names(),
                         self.check_list)

    def test_get_all_components(self):
        all_components_count = 0
        for c in self.checks.get_all_components():
            c_name = c.__class__.__name__
            self.assertTrue(c_name in self.check_list +
                            ['BadCheck', 'DummyCheck'])
            self.assertFalse(c_name in ['DisabledCheck'])
            all_components_count += 1
        self.assertEqual(all_components_count, 7)
    def setUp(self):
        _BaseTestCase.setUp(self)

        self.checks = ExtensionOrder(components=self.acctmgr.checks,
                                     list=self.acctmgr.register_checks)
        self.check_list = ['BasicCheck', 'EmailCheck', 'BotTrapCheck',
                           'RegExpCheck', 'UsernamePermCheck']
        # Mock _setorder function call.
        for c in self.checks.get_all_components():
            c_name = c.__class__.__name__
            self.checks[c] = c_name in self.check_list and \
                             self.check_list.index(c_name) + 1 or 0
            continue