Пример #1
0
    def test_unregister(self):
        """Testing HostingServiceHook uninitializing"""
        hook = HostingServiceHook(extension=self.extension,
                                  service_cls=TestService)

        hook.shutdown()

        self.assertEqual(None, get_hosting_service(TestService.name))
Пример #2
0
    def test_unregister(self):
        """Testing HostingServiceHook uninitializing"""
        hook = HostingServiceHook(extension=self.extension,
                                  service_cls=TestService)

        hook.shutdown()

        self.assertEqual(None, get_hosting_service(TestService.name))
Пример #3
0
    def test_register_without_hosting_service_id(self):
        """Testing HostingServiceHook initializing without hosting_service_id
        """
        class TestServiceWithoutID(TestService):
            hosting_service_id = None

        message = 'TestServiceWithoutID.hosting_service_id must be set.'

        with self.assertRaisesMessage(ValueError, message):
            HostingServiceHook(self.extension, TestServiceWithoutID)
Пример #4
0
    def initialize(self):
        AuthBackendHook(self, BugzillaBackend)

        self.original_opcode_generator = get_diff_opcode_generator_class()
        set_diff_opcode_generator_class(NoFilterDiffOpcodeGenerator)

        initialize_pulse_handlers(self)

        URLHook(self,
                patterns('', url(r'^mozreview/', include('mozreview.urls'))))

        HeaderDropdownActionHook(
            self,
            actions=[{
                'id':
                'nav-mozreview-menu',
                'label':
                'MozReview',
                'items': [
                    {
                        'label':
                        'User Guide',
                        'url':
                        'https://mozilla-version-control-tools.readthedocs.io/en/latest/mozreview-user.html',
                    },
                    {
                        'label':
                        'Mercurial for Mozillians',
                        'url':
                        'https://mozilla-version-control-tools.readthedocs.io/en/latest/hgmozilla/index.html',
                    },
                    {
                        'label':
                        'Hacking MozReview',
                        'url':
                        'https://mozilla-version-control-tools.readthedocs.io/en/latest/hacking-mozreview.html',
                    },
                    {
                        'label':
                        'File a Bug',
                        'url':
                        'https://bugzilla.mozilla.org/enter_bug.cgi?product=MozReview&component=General',
                    },
                ],
            }])

        review_request_dropdown_actions = [
            {
                'label':
                'Automation',
                'id':
                'automation-menu',
                'items': [
                    {
                        'id': 'autoland-try-trigger',
                        'label': 'Trigger a Try Build',
                        'url': '#',
                    },
                    {
                        'id': 'autoland-trigger',
                        'label': 'Land Commits',
                        'url': '#',
                    },
                ],
            },
        ]

        ReviewRequestDropdownActionHook(
            self, actions=review_request_dropdown_actions)
        DiffViewerDropdownActionHook(self,
                                     actions=review_request_dropdown_actions)

        # Hide fields from all review requests that are not used by Mozilla
        # developers.
        main_fieldset = get_review_request_fieldset('main')
        testing_done_field = get_review_request_field('testing_done')
        if testing_done_field:
            main_fieldset.remove_field(testing_done_field)

        info_fieldset = get_review_request_fieldset('info')
        for field_name in ('branch', 'depends_on', 'blocks'):
            field = get_review_request_field(field_name)
            if field:
                info_fieldset.remove_field(field)

        # We "monkey patch" (yes, I feel dirty) the should_render method on
        # the description field so that it is not rendered
        description_field = get_review_request_field('description')
        if description_field:
            self.old_desc_should_render = description_field.should_render
            description_field.should_render = lambda self, value: False

        # All of our review request styling is injected via
        # review-stylings-css, which in turn loads the review.css static
        # bundle.
        TemplateHook(self,
                     'base-css',
                     'mozreview/review-stylings-css.html',
                     apply_to=review_request_url_names)
        TemplateHook(self,
                     'base-css',
                     'mozreview/viewdiff-stylings-css.html',
                     apply_to=diffviewer_url_names)
        TemplateHook(
            self,
            'base-css',
            'mozreview/admin-stylings-css.html',
            apply_to=['reviewboard.extensions.views.configure_extension'])
        TemplateHook(self,
                     'base-scripts-post',
                     'mozreview/review-scripts-js.html',
                     apply_to=review_request_url_names)
        TemplateHook(self,
                     'base-extrahead',
                     'mozreview/base-extrahead-login-form.html',
                     apply_to=['login'])
        TemplateHook(self,
                     'before-login-form',
                     'mozreview/before-login-form.html',
                     apply_to=['login'])
        TemplateHook(self,
                     'after-login-form',
                     'mozreview/after-login-form.html',
                     apply_to=['login'])
        TemplateHook(self, 'base-after-content', 'mozreview/user-data.html')
        TemplateHook(self, 'base-after-content', 'mozreview/repository.html')
        TemplateHook(self,
                     'base-after-content',
                     'mozreview/user_review_flag.html',
                     apply_to=review_request_url_names)
        TemplateHook(self,
                     'base-after-content',
                     'mozreview/diff-data.html',
                     apply_to=diffviewer_url_names)
        TemplateHook(self, 'review-summary-body',
                     'mozreview/review_summary_flag_info.html')

        ReviewRequestFieldsHook(self, 'main', [CommitsListField])
        ReviewRequestFieldsHook(self, 'main', [CommitDetailField])
        CommitContextTemplateHook(self,
                                  'mozreview-pre-review-request-box',
                                  'mozreview/commits.html',
                                  apply_to=review_request_url_names)

        # The above hack forced Commits at the top, but the rest of these
        # fields are fine below the Description.
        ReviewRequestFieldsHook(self, 'main', [CombinedReviewersField])
        ReviewRequestFieldsHook(self, 'main', [TryField])
        ReviewRequestFieldsHook(self, 'main', [BaseCommitField])
        ReviewRequestFieldsHook(self, 'main', [FileDiffReviewerField])

        ReviewRequestFieldsHook(self, 'info', [CommitAuthorField])

        # Use a custom method to calculate a review approval state.
        MozReviewApprovalHook(self)

        # Instantiate the various signal handlers
        initialize_signal_handlers(self)

        HostingServiceHook(self, HMORepository)
        HostingServiceHook(self, BMOBugTracker)
Пример #5
0
    def test_register(self):
        """Testing HostingServiceHook initializing"""
        HostingServiceHook(extension=self.extension, service_cls=TestService)

        self.assertNotEqual(None, get_hosting_service(TestService.name))
Пример #6
0
    def test_register(self):
        """Testing HostingServiceHook initializing"""
        HostingServiceHook(self.extension, TestService)

        self.assertEqual(get_hosting_service('test-service'), TestService)
Пример #7
0
    def test_unregister(self):
        """Testing HostingServiceHook uninitializing"""
        hook = HostingServiceHook(self.extension, TestService)
        hook.disable_hook()

        self.assertIsNone(get_hosting_service('test-service'))