示例#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 _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
     return 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)
 def test_no_iteration_count(self):
     queue = TestQueue()
     queue.options = Mock()
     self.assertTrue(queue.should_continue_work_queue())
     self.assertTrue(queue.should_continue_work_queue())
     self.assertTrue(queue.should_continue_work_queue())
     self.assertTrue(queue.should_continue_work_queue())
示例#8
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)
示例#9
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)
示例#10
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", ""))
 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
     return options