コード例 #1
0
 def test_file_object_for_upload(self):
     bugzilla = Bugzilla()
     file_object = StringIO()
     unicode_tor = u"WebKit \u2661 Tor Arne Vestb\u00F8!"
     utf8_tor = unicode_tor.encode("utf-8")
     self.assertEqual(bugzilla._file_object_for_upload(file_object),
                      file_object)
     self.assertEqual(
         bugzilla._file_object_for_upload(utf8_tor).read(), utf8_tor)
     self.assertEqual(
         bugzilla._file_object_for_upload(unicode_tor).read(), utf8_tor)
コード例 #2
0
 def test_filename_for_upload(self):
     bugzilla = Bugzilla()
     mock_file = Mock()
     mock_file.name = "foo"
     self.assertEqual(bugzilla._filename_for_upload(mock_file, 1234), 'foo')
     mock_timestamp = lambda: "now"
     filename = bugzilla._filename_for_upload(StringIO(),
                                              1234,
                                              extension="patch",
                                              timestamp=mock_timestamp)
     self.assertEqual(filename, "bug-1234-now.patch")
コード例 #3
0
ファイル: bugzilla_unittest.py プロジェクト: Man1029/webkit
    def test__parse_attachment_id_from_add_patch_to_bug_response(self):
        bugzilla = Bugzilla()

        title_html = b'<title>Attachment 317591 added to Bug 175247</title>'
        self.assertEqual(bugzilla._parse_attachment_id_from_add_patch_to_bug_response(title_html), b'317591')

        title_html = b'<title>Attachment 317591; malformed</title>'
        self.assertEqual(bugzilla._parse_attachment_id_from_add_patch_to_bug_response(title_html), None)

        title_html = b'<title>Attachment A added to Bug 175247</title>'
        self.assertEqual(bugzilla._parse_attachment_id_from_add_patch_to_bug_response(title_html), None)
コード例 #4
0
ファイル: bugzilla_unittest.py プロジェクト: Man1029/webkit
    def _assert_reopen(self, item_names=None, selected_index=None, extra_logs=None):
        bugzilla = Bugzilla()
        bugzilla.browser = MockBrowser()
        bugzilla.authenticate = lambda: None

        mock_find_control = self._mock_find_control(item_names, selected_index)
        bugzilla.browser.find_control = mock_find_control
        expected_logs = "Re-opening bug 42\n['comment']\n"
        if extra_logs:
            expected_logs += extra_logs
        OutputCapture().assert_outputs(self, bugzilla.reopen_bug, [42, ["comment"]], expected_logs=expected_logs)
コード例 #5
0
    def test__check_create_bug_response(self):
        bugzilla = Bugzilla()

        title_html_bugzilla_323 = "<title>Bug 101640 Submitted</title>"
        self.assertEqual(
            bugzilla._check_create_bug_response(title_html_bugzilla_323),
            '101640')

        title_html_bugzilla_425 = "<title>Bug 101640 Submitted &ndash; Testing webkit-patch again</title>"
        self.assertEqual(
            bugzilla._check_create_bug_response(title_html_bugzilla_425),
            '101640')
コード例 #6
0
ファイル: bugzilla_mock.py プロジェクト: wuyibo0817/webkit
    def fetch_attachment(self, attachment_id, throw_on_access_error=False):
        if self._override_patch:
            return self._override_patch

        attachment_dictionary = self.attachment_cache.get(int(attachment_id))
        if not attachment_dictionary:
            print("MOCK: fetch_attachment: %s is not a known attachment id" % attachment_id)
            return None
        bug = self.fetch_bug(attachment_dictionary["bug_id"])
        if bug.is_security_sensitive() and throw_on_access_error:
            raise Bugzilla.AccessError(attachment_id, Bugzilla.AccessError.NOT_PERMITTED, 'Bug Access Denied')
        for attachment in bug.attachments(include_obsolete=True):
            if attachment.id() == int(attachment_id):
                return attachment
コード例 #7
0
 def test_add_cc_to_bug(self):
     bugzilla = Bugzilla()
     bugzilla.browser = MockBrowser()
     bugzilla.authenticate = lambda: None
     with OutputCapture(level=logging.INFO) as captured:
         bugzilla.add_cc_to_bug(42, ['*****@*****.**'])
     self.assertEqual(
         captured.root.log.getvalue(),
         "Adding ['*****@*****.**'] to the CC list for bug 42\n")
コード例 #8
0
    def _assert_reopen(self,
                       item_names=None,
                       selected_index=None,
                       extra_logs=None):
        bugzilla = Bugzilla()
        bugzilla.browser = MockBrowser()
        bugzilla.authenticate = lambda: None

        mock_find_control = self._mock_find_control(item_names, selected_index)
        bugzilla.browser.find_control = mock_find_control
        with OutputCapture(level=logging.INFO) as captured:
            bugzilla.reopen_bug(42, ['comment'])
        self.assertEqual(
            captured.root.log.getvalue(),
            "Re-opening bug 42\n['comment']\n" + (extra_logs or ''))
コード例 #9
0
 def test_url_creation(self):
     # FIXME: These would be all better as doctests
     bugs = Bugzilla()
     self.assertIsNone(bugs.bug_url_for_bug_id(None))
     self.assertIsNone(bugs.short_bug_url_for_bug_id(None))
     self.assertIsNone(bugs.attachment_url_for_id(None))
コード例 #10
0
 def test_attachment_detail_bug_parsing(self):
     bugzilla = Bugzilla()
     self.assertEqual(
         27314,
         bugzilla._parse_bug_id_from_attachment_page(
             self._sample_attachment_detail_page))
コード例 #11
0
 def test_parse_bug_dictionary_from_xml(self):
     bug = Bugzilla()._parse_bug_dictionary_from_xml(self._single_bug_xml)
     self._assert_dictionaries_equal(bug,
                                     self._expected_example_bug_parsing)
コード例 #12
0
    def test_commit_queue_flag(self):
        bugzilla = Bugzilla()

        bugzilla.committers = CommitterList(
            reviewers=[Reviewer("WebKit Reviewer", "*****@*****.**")],
            committers=[Committer("WebKit Committer", "*****@*****.**")],
            contributors=[
                Contributor("WebKit Contributor", "*****@*****.**")
            ])

        def assert_commit_queue_flag(commit_flag, expected, username=None):
            bugzilla.username = username
            capture = OutputCapture()
            capture.capture_output()
            try:
                self.assertEqual(bugzilla._commit_queue_flag(commit_flag),
                                 expected)
            finally:
                capture.restore_output()

        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_nothing,
                                 expected='X',
                                 username='******')
        assert_commit_queue_flag(
            commit_flag=CommitQueueFlag.mark_for_commit_queue,
            expected='?',
            username='******')
        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_landing,
                                 expected='?',
                                 username='******')

        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_nothing,
                                 expected='X',
                                 username='******')
        assert_commit_queue_flag(
            commit_flag=CommitQueueFlag.mark_for_commit_queue,
            expected='?',
            username='******')
        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_landing,
                                 expected='?',
                                 username='******')

        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_nothing,
                                 expected='X',
                                 username='******')
        assert_commit_queue_flag(
            commit_flag=CommitQueueFlag.mark_for_commit_queue,
            expected='?',
            username='******')
        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_landing,
                                 expected='+',
                                 username='******')

        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_nothing,
                                 expected='X',
                                 username='******')
        assert_commit_queue_flag(
            commit_flag=CommitQueueFlag.mark_for_commit_queue,
            expected='?',
            username='******')
        assert_commit_queue_flag(commit_flag=CommitQueueFlag.mark_for_landing,
                                 expected='+',
                                 username='******')
コード例 #13
0
 def test_parse_bug_dictionary_from_xml_for_not_permitted_bug(self):
     bug = Bugzilla()._parse_bug_dictionary_from_xml(
         self._single_not_permitted_bug_xml)
     self.assertEqual(bug, {})
コード例 #14
0
ファイル: bugzilla_unittest.py プロジェクト: Man1029/webkit
 def test_parse_bug_id(self):
     # Test that we can parse the urls we produce.
     bugs = Bugzilla()
     self.assertEqual(12345, urls.parse_bug_id(bugs.short_bug_url_for_bug_id(12345)))
     self.assertEqual(12345, urls.parse_bug_id(bugs.bug_url_for_bug_id(12345)))
     self.assertEqual(12345, urls.parse_bug_id(bugs.bug_url_for_bug_id(12345, xml=True)))
コード例 #15
0
ファイル: bugzilla_unittest.py プロジェクト: Man1029/webkit
 def test_add_cc_to_bug(self):
     bugzilla = Bugzilla()
     bugzilla.browser = MockBrowser()
     bugzilla.authenticate = lambda: None
     expected_logs = "Adding ['*****@*****.**'] to the CC list for bug 42\n"
     OutputCapture().assert_outputs(self, bugzilla.add_cc_to_bug, [42, ["*****@*****.**"]], expected_logs=expected_logs)