Exemple #1
0
    def test_register_then_unregister(self):
        """Testing BaseReviewRequestAction.register then unregister for
        actions
        """
        foo_action = FooAction()
        foo_action.register()

        self.assertIn(foo_action.action_id,
                      (action.action_id for action in get_top_level_actions()))

        foo_action.unregister()

        self.assertNotIn(foo_action.action_id,
                         (action.action_id
                          for action in get_top_level_actions()))
Exemple #2
0
    def test_register_then_unregister(self):
        """Testing BaseReviewRequestAction.register then unregister for
        actions
        """
        foo_action = FooAction()
        foo_action.register()

        self.assertIn(foo_action.action_id, (
            action.action_id
            for action in get_top_level_actions()
        ))

        foo_action.unregister()

        self.assertNotIn(foo_action.action_id, (
            action.action_id
            for action in get_top_level_actions()
        ))
Exemple #3
0
    def test_unregister_actions(self):
        """Testing unregister_actions"""

        orig_action_ids = {
            action.action_id
            for action in get_top_level_actions()
        }
        self.assertIn('update-review-request-action', orig_action_ids)
        self.assertIn('review-action', orig_action_ids)

        unregister_actions(['update-review-request-action', 'review-action'])

        new_action_ids = {
            action.action_id
            for action in get_top_level_actions()
        }
        self.assertEqual(len(orig_action_ids), len(new_action_ids) + 2)
        self.assertNotIn('update-review-request-action', new_action_ids)
        self.assertNotIn('review-action', new_action_ids)
    def test_unregister_actions(self):
        """Testing unregister_actions"""

        orig_action_ids = {
            action.action_id
            for action in get_top_level_actions()
        }
        self.assertIn('update-review-request-action', orig_action_ids)
        self.assertIn('review-action', orig_action_ids)

        unregister_actions(['update-review-request-action', 'review-action'])

        new_action_ids = {
            action.action_id
            for action in get_top_level_actions()
        }
        self.assertEqual(len(orig_action_ids), len(new_action_ids) + 2)
        self.assertNotIn('update-review-request-action', new_action_ids)
        self.assertNotIn('review-action', new_action_ids)
Exemple #5
0
    def _replace_action(self, action):
        top_actions = []
        for x in get_top_level_actions():
            top_actions.append(x)

        for x in top_actions:
            x.unregister()

        new_actions = []
        for x in get_default_actions():
            if x.action_id == action.action_id:
                new_actions.append(action)
            else:
                new_actions.append(x)

        for x in reversed(new_actions):
            x.register()
Exemple #6
0
def review_request_actions(context):
    """Render all registered review request actions.

    Args:
        context (django.template.Context):
            The collection of key-value pairs available in the template.

    Returns:
        unicode: The HTML content to be rendered.
    """
    content = []

    for top_level_action in get_top_level_actions():
        try:
            content.append(top_level_action.render(context))
        except Exception:
            logging.exception('Error rendering top-level action %s',
                              top_level_action.action_id)

    return ''.join(content)
Exemple #7
0
def review_request_actions(context):
    """Render all registered review request actions.

    Args:
        context (django.template.Context):
            The collection of key-value pairs available in the template.

    Returns:
        unicode: The HTML content to be rendered.
    """
    content = []

    for top_level_action in get_top_level_actions():
        try:
            content.append(top_level_action.render(context))
        except Exception:
            logging.exception('Error rendering top-level action %s',
                              top_level_action.action_id)

    return ''.join(content)