Exemple #1
0
    def test_register_actions_with_too_deep(self):
        """Testing register_actions with exceeding max depth"""
        actions = self.make_nested_actions(MAX_DEPTH_LIMIT + 1)
        invalid_action = BarAction(str(len(actions)), [actions[-1]])

        error_message = ('%s exceeds the maximum depth limit of %d' %
                         (invalid_action.action_id, MAX_DEPTH_LIMIT))

        with self.assertRaisesMessage(DepthLimitExceededError, error_message):
            register_actions([invalid_action])
Exemple #2
0
    def test_register_actions_with_invalid_parent_id(self):
        """Testing register_actions with an invalid parent ID"""
        foo_action = FooAction()

        message = (
            'bad-id does not correspond to a registered review request action')

        foo_action.register()

        with self.assertRaisesMessage(KeyError, message):
            register_actions([foo_action], 'bad-id')
Exemple #3
0
    def test_register_actions_with_too_deep(self):
        """Testing register_actions with exceeding max depth"""
        actions = self.make_nested_actions(MAX_DEPTH_LIMIT + 1)
        invalid_action = BarAction(str(len(actions)), [actions[-1]])

        error_message = (
            '%s exceeds the maximum depth limit of %d'
            % (invalid_action.action_id, MAX_DEPTH_LIMIT)
        )

        with self.assertRaisesMessage(DepthLimitExceededError, error_message):
            register_actions([invalid_action])
Exemple #4
0
    def test_register_actions_with_invalid_parent_id(self):
        """Testing register_actions with an invalid parent ID"""
        foo_action = FooAction()

        message = (
            'bad-id does not correspond to a registered review request action'
        )

        foo_action.register()

        with self.assertRaisesMessage(KeyError, message):
            register_actions([foo_action], 'bad-id')
Exemple #5
0
    def test_register_actions_with_already_registered_action(self):
        """Testing register_actions with an already registered action"""
        foo_action = FooAction()

        message = (
            '%s already corresponds to a registered review request action' %
            foo_action.action_id)

        foo_action.register()

        with self.assertRaisesMessage(KeyError, message):
            register_actions([foo_action])
Exemple #6
0
    def test_register_actions_with_already_registered_action(self):
        """Testing register_actions with an already registered action"""
        foo_action = FooAction()

        message = (
            '%s already corresponds to a registered review request action'
            % foo_action.action_id
        )

        foo_action.register()

        with self.assertRaisesMessage(KeyError, message):
            register_actions([foo_action])
Exemple #7
0
    def test_register_actions_with_max_depth(self):
        """Testing register_actions with max_depth"""
        actions = self.make_nested_actions(MAX_DEPTH_LIMIT)
        extra_action = BarAction('extra')
        foo_action = FooAction()

        for d, action in enumerate(actions):
            self.assertEquals(action.max_depth, d)

        register_actions([extra_action], actions[0].action_id)
        actions = [extra_action] + actions

        for d, action in enumerate(actions):
            self.assertEquals(action.max_depth, d)

        register_actions([foo_action])
        self.assertEquals(foo_action.max_depth, 0)
    def test_register_actions_with_max_depth(self):
        """Testing register_actions with max_depth"""
        actions = self.make_nested_actions(MAX_DEPTH_LIMIT)
        extra_action = BarAction('extra')
        foo_action = FooAction()

        for d, action in enumerate(actions):
            self.assertEquals(action.max_depth, d)

        register_actions([extra_action], actions[0].action_id)
        actions = [extra_action] + actions

        for d, action in enumerate(actions):
            self.assertEquals(action.max_depth, d)

        register_actions([foo_action])
        self.assertEquals(foo_action.max_depth, 0)