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=''))
예제 #2
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=''))
예제 #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")]

        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(), '')
 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_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)
예제 #6
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)
예제 #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(), '')