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)
Example #2
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)
    def test_security_output_parse_entry_not_found(self):
        credentials = Credentials("foo.example.com")
        if not credentials._is_mac_os_x():
            return # This test does not run on a non-Mac.

        # Note, we ignore the captured output because it is already covered
        # by the test case CredentialsTest._assert_security_call (below).
        outputCapture = OutputCapture()
        outputCapture.capture_output()
        self.assertEqual(credentials._run_security_tool(), None)
        outputCapture.restore_output()
Example #4
0
 def test_add_cc_to_bug(self):
     bugzilla = Bugzilla()
     bugzilla.browser = MockBrowser()
     bugzilla.authenticate = lambda: None
     expected_stderr = "Adding ['*****@*****.**'] to the CC list for bug 42\n"
     OutputCapture().assert_outputs(self,
                                    bugzilla.add_cc_to_bug,
                                    [42, ["*****@*****.**"]],
                                    expected_stderr=expected_stderr)
 def test_required_arguments(self):
     two_required_arguments = TrivialCommand(
         argument_names="ARG1 ARG2 [ARG3]")
     expected_missing_args_error = "2 arguments required, 1 argument provided.  Provided: 'foo'  Required: ARG1 ARG2\nSee 'trivial-tool help trivial' for usage.\n"
     exit_code = OutputCapture().assert_outputs(
         self,
         two_required_arguments.check_arguments_and_execute,
         [None, ["foo"], TrivialTool()],
         expected_stderr=expected_missing_args_error)
     self.assertEqual(exit_code, 1)
Example #6
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)
 def _assert_tool_main_outputs(self,
                               tool,
                               main_args,
                               expected_stdout,
                               expected_stderr="",
                               expected_exit_code=0):
     exit_code = OutputCapture().assert_outputs(
         self,
         tool.main, [main_args],
         expected_stdout=expected_stdout,
         expected_stderr=expected_stderr)
     self.assertEqual(exit_code, expected_exit_code)
Example #8
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)
Example #9
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", ""))
Example #10
0
    def test_security_output_parse_entry_not_found(self):
        credentials = Credentials("foo.example.com")
        if not credentials._is_mac_os_x():
            return # This test does not run on a non-Mac.

        # Note, we ignore the captured output because it is already covered
        # by the test case CredentialsTest._assert_security_call (below).
        outputCapture = OutputCapture()
        outputCapture.capture_output()
        self.assertEqual(credentials._run_security_tool(), None)
        outputCapture.restore_output()
 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)
 def _assert_log_progress_output(self, patch_ids, progress_output):
     OutputCapture().assert_outputs(self,
                                    TestQueue().log_progress, [patch_ids],
                                    expected_stderr=progress_output)
 def test_empty_state(self):
     capture = OutputCapture()
     step = UpdateChangeLogsWithReviewer(MockBugzillaTool(), Mock())
     capture.assert_outputs(self, step.run, [{}])
 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)
 def test_empty_state(self):
     capture = OutputCapture()
     step = UpdateChangeLogsWithReviewer(MockBugzillaTool(), Mock())
     capture.assert_outputs(self, step.run, [{}])