Пример #1
0
 def test_commit_message_for_current_diff(self):
     tool = MockBugzillaTool()
     mock_commit_message_for_this_commit = Mock()
     mock_commit_message_for_this_commit.message = lambda: "Mock message"
     tool._scm.commit_message_for_this_commit = lambda: mock_commit_message_for_this_commit
     expected_stdout = "Mock message\n"
     self.assert_execute_outputs(CommitMessageForCurrentDiff(), [], expected_stdout=expected_stdout, tool=tool)
 def test_commit_message_for_current_diff(self):
     tool = MockBugzillaTool()
     mock_commit_message_for_this_commit = Mock()
     mock_commit_message_for_this_commit.message = lambda: "Mock message"
     tool._scm.commit_message_for_this_commit = lambda: mock_commit_message_for_this_commit
     expected_stdout = "Mock message\n"
     self.assert_execute_outputs(CommitMessageForCurrentDiff(), [],
                                 expected_stdout=expected_stdout,
                                 tool=tool)
Пример #3
0
    def test_patches_to_commit_queue(self):
        expected_stdout = "http://example.com/104&action=edit\n"
        expected_stderr = "197 already has cq=+\n128 already has cq=+\n105 committer = \"Eric Seidel\" <*****@*****.**>\n"
        options = Mock()
        options.bugs = False
        self.assert_execute_outputs(PatchesToCommitQueue(), None, expected_stdout, expected_stderr, options=options)

        expected_stdout = "http://example.com/77\n"
        options.bugs = True
        self.assert_execute_outputs(PatchesToCommitQueue(), None, expected_stdout, expected_stderr, options=options)
Пример #4
0
    def test_mark_bug_fixed(self):
        tool = MockBugzillaTool()
        tool._scm.last_svn_commit_log = lambda: "r9876 |"
        options = Mock()
        options.bug_id = 42
        expected_stderr = """Bug: <http://example.com/42> Bug with two r+'d and cq+'d patches, one of which has an invalid commit-queue setter.
Revision: 9876
MOCK: user.open_url: http://example.com/42
Adding comment to Bug 42.
"""
        self.assert_execute_outputs(MarkBugFixed(), [], expected_stderr=expected_stderr, tool=tool, options=options)
    def test_mark_bug_fixed(self):
        tool = MockBugzillaTool()
        tool._scm.last_svn_commit_log = lambda: "r9876 |"
        options = Mock()
        options.bug_id = 42
        expected_stderr = """Bug: <http://example.com/42> Bug with two r+'d and cq+'d patches, one of which has an invalid commit-queue setter.
Revision: 9876
MOCK: user.open_url: http://example.com/42
Adding comment to Bug 42.
"""
        self.assert_execute_outputs(MarkBugFixed(), [],
                                    expected_stderr=expected_stderr,
                                    tool=tool,
                                    options=options)
Пример #6
0
 def __init__(self):
     self.bugs = MockBugzilla()
     self.buildbot = MockBuildBot()
     self.executive = Mock()
     self.user = MockUser()
     self._scm = MockSCM()
     self.status_server = MockStatusServer()
 def test_guess_reviewer_from_bug(self):
     capture = OutputCapture()
     step = UpdateChangeLogsWithReviewer(MockBugzillaTool(), Mock())
     expected_stderr = "0 reviewed patches on bug 75, cannot infer reviewer.\n"
     capture.assert_outputs(self,
                            step._guess_reviewer_from_bug, [75],
                            expected_stderr=expected_stderr)
Пример #8
0
 def _run_step(self, step, tool=None, options=None, state=None):
     if not tool:
         tool = MockBugzillaTool()
     if not options:
         options = Mock()
     if not state:
         state = {}
     step(tool, options).run(state)
Пример #9
0
    def test_patches_to_commit_queue(self):
        expected_stdout = "http://example.com/104&action=edit\n"
        expected_stderr = "197 already has cq=+\n128 already has cq=+\n105 committer = \"Eric Seidel\" <*****@*****.**>\n"
        options = Mock()
        options.bugs = False
        self.assert_execute_outputs(PatchesToCommitQueue(),
                                    None,
                                    expected_stdout,
                                    expected_stderr,
                                    options=options)

        expected_stdout = "http://example.com/77\n"
        options.bugs = True
        self.assert_execute_outputs(PatchesToCommitQueue(),
                                    None,
                                    expected_stdout,
                                    expected_stderr,
                                    options=options)
Пример #10
0
    def test_git_config_calls(self):
        executive_mock = Mock()
        credentials = Credentials("example.com", executive=executive_mock)
        credentials._read_git_config("foo")
        executive_mock.run_command.assert_called_with(["git", "config", "--get", "foo"], error_handler=Executive.ignore_error)

        credentials = Credentials("example.com", git_prefix="test_prefix", executive=executive_mock)
        credentials._read_git_config("foo")
        executive_mock.run_command.assert_called_with(["git", "config", "--get", "test_prefix.foo"], error_handler=Executive.ignore_error)
Пример #11
0
 def test_empty_state(self):
     capture = OutputCapture()
     step = CloseBugForLandDiff(MockBugzillaTool(), Mock())
     expected_stderr = "Committed r49824: <http://trac.webkit.org/changeset/49824>\nNo bug id provided.\n"
     capture.assert_outputs(self,
                            step.run, [{
                                "commit_text": "Mock commit text"
                            }],
                            expected_stderr=expected_stderr)
Пример #12
0
    def _assert_security_call(self, username=None):
        executive_mock = Mock()
        credentials = Credentials("example.com", executive=executive_mock)

        expected_stderr = "Reading Keychain for example.com account and password.  Click \"Allow\" to continue...\n"
        OutputCapture().assert_outputs(self, credentials._run_security_tool, [username], expected_stderr=expected_stderr)

        security_args = ["/usr/bin/security", "find-internet-password", "-g", "-s", "example.com"]
        if username:
            security_args += ["-a", username]
        executive_mock.run_command.assert_called_with(security_args)
Пример #13
0
 def assert_execute_outputs(self,
                            command,
                            args,
                            expected_stdout="",
                            expected_stderr="",
                            options=Mock(),
                            tool=MockBugzillaTool()):
     command.bind_to_tool(tool)
     OutputCapture().assert_outputs(self,
                                    command.execute, [options, args, tool],
                                    expected_stdout=expected_stdout,
                                    expected_stderr=expected_stderr)
 def test_empty_state(self):
     capture = OutputCapture()
     step = UpdateChangeLogsWithReviewer(MockBugzillaTool(), Mock())
     capture.assert_outputs(self, step.run, [{}])
Пример #15
0
 def __init__(self):
     Mock.__init__(self)
     self.queries = MockBugzillaQueries(self)
     self.committers = CommitterList(reviewers=[Reviewer("Foo Bar",
                                                         "*****@*****.**")])
Пример #16
0
 def __init__(self):
     Mock.__init__(self)
     self.checkout_root = os.getcwd()
Пример #17
0
 def test_update_step(self):
     options = Mock()
     options.update = True
     self._run_step(Update, options)
Пример #18
0
 def __init__(self, bugzilla):
     Mock.__init__(self)
     self._bugzilla = bugzilla
Пример #19
0
 def _default_options(self):
     options = Mock()
     options.force_clean = False
     options.clean = True
     options.check_builders = True
     options.quiet = False
     options.non_interactive = False
     options.update = True
     options.build = True
     options.test = True
     options.close_bug = True
     options.complete_rollout = False
     return options
Пример #20
0
 def __init__(self):
     Mock.__init__(self)
     self.queries = MockBugzillaQueries(self)
     self.committers = CommitterList(
         reviewers=[Reviewer("Foo Bar", "*****@*****.**")])
Пример #21
0
 def __init__(self):
     Mock.__init__(self)
     self.checkout_root = os.getcwd()
Пример #22
0
 def test_load_query(self):
     queries = BugzillaQueries(Mock())
     queries._load_query("request.cgi?action=queue&type=review&group=type")
Пример #23
0
 def status_server(self):
     return Mock()
Пример #24
0
 def test_update_step(self):
     options = Mock()
     options.update = True
     self._run_step(Update, options)
Пример #25
0
 def _default_options(self):
     options = Mock()
     options.force_clean = False
     options.clean = True
     options.check_builders = True
     options.quiet = False
     options.non_interactive = False
     options.update = True
     options.build = True
     options.test = True
     options.close_bug = True
     options.complete_rollout = False
     return options
Пример #26
0
    def assert_queue_outputs(self, queue, args=None, work_item=None, expected_stdout=None, expected_stderr=None, options=Mock(), tool=MockBugzillaTool()):
        if not expected_stdout:
            expected_stdout = {}
        if not expected_stderr:
            expected_stderr = {}
        if not args:
            args = []
        if not work_item:
            work_item = self.mock_work_item
        tool.user.prompt = lambda message: "yes"

        queue.execute(options, args, tool, engine=MockQueueEngine)

        OutputCapture().assert_outputs(self,
                queue.queue_log_path,
                expected_stdout=expected_stdout.get("queue_log_path", ""),
                expected_stderr=expected_stderr.get("queue_log_path", ""))
        OutputCapture().assert_outputs(self,
                queue.work_item_log_path,
                args=[work_item],
                expected_stdout=expected_stdout.get("work_item_log_path", ""),
                expected_stderr=expected_stderr.get("work_item_log_path", ""))
        OutputCapture().assert_outputs(self,
                queue.begin_work_queue,
                expected_stdout=expected_stdout.get("begin_work_queue", ""),
                expected_stderr=expected_stderr.get("begin_work_queue", ""))
        OutputCapture().assert_outputs(self,
                queue.should_continue_work_queue,
                expected_stdout=expected_stdout.get("should_continue_work_queue", ""), expected_stderr=expected_stderr.get("should_continue_work_queue", ""))
        OutputCapture().assert_outputs(self,
                queue.next_work_item,
                expected_stdout=expected_stdout.get("next_work_item", ""),
                expected_stderr=expected_stderr.get("next_work_item", ""))
        OutputCapture().assert_outputs(self,
                queue.should_proceed_with_work_item,
                args=[work_item],
                expected_stdout=expected_stdout.get("should_proceed_with_work_item", ""),
                expected_stderr=expected_stderr.get("should_proceed_with_work_item", ""))
        OutputCapture().assert_outputs(self,
                queue.process_work_item,
                args=[work_item],
                expected_stdout=expected_stdout.get("process_work_item", ""),
                expected_stderr=expected_stderr.get("process_work_item", ""))
        OutputCapture().assert_outputs(self,
                queue.handle_unexpected_error,
                args=[work_item, "Mock error message"],
                expected_stdout=expected_stdout.get("handle_unexpected_error", ""),
                expected_stderr=expected_stderr.get("handle_unexpected_error", ""))
Пример #27
0
 def __init__(self, bugzilla):
     Mock.__init__(self)
     self._bugzilla = bugzilla