def _assert_start_line_produces_output(self, start_line, should_fail=False, non_interactive=False):
     tool = MockTool()
     step = ValidateChangeLogs(tool, MockOptions(git_commit=None, non_interactive=non_interactive))
     diff_file = Mock()
     diff_file.filename = "mock/ChangeLog"
     diff_file.lines = [(start_line, start_line, "foo")]
     expected_stdout = expected_stderr = expected_logs = ""
     if should_fail and not non_interactive:
         expected_logs = "The diff to mock/ChangeLog looks wrong. Are you sure your ChangeLog entry is at the top of the file?\nOK to continue?\n"
     result = OutputCapture().assert_outputs(self, step._check_changelog_diff, [diff_file], expected_logs=expected_logs)
     self.assertEqual(not result, should_fail)
    def test_changelog_contains_oops(self):
        tool = MockTool()
        tool._checkout.is_path_to_changelog = lambda path: True
        step = ValidateChangeLogs(tool, MockOptions(git_commit=None, non_interactive=True, check_oops=True))
        diff_file = Mock()
        diff_file.filename = "mock/ChangeLog"
        diff_file.lines = [(1, 1, "foo"), (2, 2, "bar OOPS! bar"), (3, 3, "foo")]
        self.assertTrue(OutputCapture().assert_outputs(self, step._changelog_contains_oops, [diff_file], expected_logs=''))

        diff_file.lines = [(1, 1, "foo"), (2, 2, "bar OOPS bar"), (3, 3, "foo")]
        self.assertFalse(OutputCapture().assert_outputs(self, step._changelog_contains_oops, [diff_file], expected_logs=''))
Пример #3
0
    def test_changelog_contains_oops(self):
        tool = MockTool()
        tool._checkout.is_path_to_changelog = lambda path: True
        step = ValidateChangeLogs(tool, MockOptions(git_commit=None, non_interactive=True, check_oops=True))
        diff_file = Mock()
        diff_file.filename = "mock/ChangeLog"
        diff_file.lines = [(1, 1, "foo"), (2, 2, "bar OOPS! bar"), (3, 3, "foo")]
        self.assertTrue(OutputCapture().assert_outputs(self, step._changelog_contains_oops, [diff_file], expected_logs=''))

        diff_file.lines = [(1, 1, "foo"), (2, 2, "bar OOPS bar"), (3, 3, "foo")]
        self.assertFalse(OutputCapture().assert_outputs(self, step._changelog_contains_oops, [diff_file], expected_logs=''))
Пример #4
0
 def _assert_start_line_produces_output(self, start_line, should_fail=False, non_interactive=False):
     tool = MockTool()
     step = ValidateChangeLogs(tool, MockOptions(git_commit=None, non_interactive=non_interactive))
     diff_file = Mock()
     diff_file.filename = "mock/ChangeLog"
     diff_file.lines = [(start_line, start_line, "foo")]
     expected_stdout = expected_stderr = expected_logs = ""
     if should_fail and not non_interactive:
         expected_logs = "The diff to mock/ChangeLog looks wrong. Are you sure your ChangeLog entry is at the top of the file?\nOK to continue?\n"
     result = OutputCapture().assert_outputs(self, step._check_changelog_diff, [diff_file], expected_logs=expected_logs)
     self.assertEqual(not result, should_fail)
Пример #5
0
 def _assert_start_line_produces_output(self, start_line, should_prompt_user=False):
     tool = MockTool()
     tool._checkout.is_path_to_changelog = lambda path: True
     step = ValidateChangeLogs(tool, MockOptions(git_commit=None))
     diff_file = Mock()
     diff_file.filename = "mock/ChangeLog"
     diff_file.lines = [(start_line, start_line, "foo")]
     expected_stdout = expected_stderr = ""
     if should_prompt_user:
         expected_stdout = "OK to continue?\n"
         expected_stderr = "The diff to mock/ChangeLog looks wrong.  Are you sure your ChangeLog entry is at the top of the file?\n"
     OutputCapture().assert_outputs(self, step._check_changelog_diff, [diff_file], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
Пример #6
0
    def test_changelog_contains_oops(self):
        tool = MockTool()
        tool._checkout.is_path_to_changelog = lambda path: True
        step = ValidateChangeLogs(tool, MockOptions(git_commit=None, non_interactive=True, check_oops=True))
        diff_file = Mock()
        diff_file.filename = "mock/ChangeLog"
        diff_file.lines = [(1, 1, "foo"), (2, 2, "bar OOPS! bar"), (3, 3, "foo")]

        with OutputCapture(level=logging.INFO) as captured:
            self.assertTrue(step._changelog_contains_oops(diff_file))
        self.assertEqual(captured.root.log.getvalue(), '')

        diff_file.lines = [(1, 1, "foo"), (2, 2, "bar OOPS bar"), (3, 3, "foo")]
        with OutputCapture(level=logging.INFO) as captured:
            self.assertFalse(step._changelog_contains_oops(diff_file))
        self.assertEqual(captured.root.log.getvalue(), '')
Пример #7
0
    def _assert_start_line_produces_output(self, start_line, should_fail=False, non_interactive=False):
        tool = MockTool()
        step = ValidateChangeLogs(tool, MockOptions(git_commit=None, non_interactive=non_interactive))
        diff_file = Mock()
        diff_file.filename = "mock/ChangeLog"
        diff_file.lines = [(start_line, start_line, "foo")]

        with OutputCapture(level=logging.INFO) as captured:
            result = step._check_changelog_diff(diff_file)
        self.assertEqual(not result, should_fail)

        self.assertEqual(captured.stdout.getvalue(), '')
        self.assertEqual(captured.stderr.getvalue(), '')
        if should_fail and not non_interactive:
            self.assertEqual(
                captured.root.log.getvalue(),
                'The diff to mock/ChangeLog looks wrong. Are you sure your ChangeLog entry is at the top of the file?\nOK to continue?\n',
            )
        else:
            self.assertEqual(captured.root.log.getvalue(), '')
Пример #8
0
 def archive_last_test_results(self, patch):
     _log.info("archive_last_test_results: patch='%s'" % patch.id())
     archive = Mock()
     archive.filename = "mock-archive-%s.zip" % patch.id()
     return archive
Пример #9
0
 def archive_last_test_results(self, patch):
     log("archive_last_test_results: patch='%s'" % patch.id())
     archive = Mock()
     archive.filename = "mock-archive-%s.zip" % patch.id()
     return archive