コード例 #1
0
    def test_patches_to_commit_queue(self):
        expected_stdout = "http://example.com/197&action=edit\n"
        expected_stderr = "128 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/42\n"
        options.bugs = True
        self.assert_execute_outputs(PatchesToCommitQueue(), None, expected_stdout, expected_stderr, options=options)
コード例 #2
0
 def __init__(self):
     self.bugs = MockBugzilla()
     self.buildbot = MockBuildBot()
     self.executive = Mock()
     self.user = MockUser()
     self._scm = MockSCM()
     self.status_bot = MockStatusBot()
コード例 #3
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)
コード例 #4
0
    def test_patches_to_commit_queue(self):
        expected_stdout = "http://example.com/197&action=edit\n"
        expected_stderr = "128 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/42\n"
        options.bugs = True
        self.assert_execute_outputs(PatchesToCommitQueue(),
                                    None,
                                    expected_stdout,
                                    expected_stderr,
                                    options=options)
コード例 #5
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)
コード例 #6
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)
コード例 #7
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)
コード例 #8
0
 def __init__(self):
     Mock.__init__(self)
     self.checkout_root = os.getcwd()
コード例 #9
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
コード例 #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
        options.confirm = False  # FIXME: We should have a tool.user that we can mock.

        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", ""))
コード例 #11
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
コード例 #12
0
 def __init__(self):
     Mock.__init__(self)
     self.checkout_root = os.getcwd()
コード例 #13
0
 def test_update_step(self):
     options = Mock()
     options.update = True
     self._run_step(UpdateStep, options)