|
9 | 9 | import os
|
10 | 10 | import unittest
|
11 | 11 | from datetime import timedelta
|
12 |
| -from unittest.mock import mock_open, patch |
| 12 | +from unittest.mock import call, mock_open, patch |
13 | 13 |
|
14 | 14 | from classes import IssueWithMetrics
|
15 | 15 | from markdown_writer import write_to_markdown
|
@@ -219,11 +219,19 @@ def test_write_to_markdown_no_issues(self):
|
219 | 219 | write_to_markdown(None, None, None, None, None, None, None)
|
220 | 220 |
|
221 | 221 | # Check that the file was written correctly
|
222 |
| - expected_output = "no issues found for the given search criteria\n\n" |
223 |
| - mock_open_file.assert_called_once_with( |
224 |
| - "issue_metrics.md", "w", encoding="utf-8" |
| 222 | + expected_output = [ |
| 223 | + "# Issue Metrics\n\n", |
| 224 | + "no issues found for the given search criteria\n\n", |
| 225 | + "\n_This report was generated with the [Issue Metrics Action](https://github.com/github/issue-metrics)_\n", |
| 226 | + ] |
| 227 | + # Check that the markdown file was written with the three calls in expected output |
| 228 | + mock_open_file.assert_has_calls( |
| 229 | + [ |
| 230 | + call().write(expected_output[0]), |
| 231 | + call().write(expected_output[1]), |
| 232 | + call().write(expected_output[2]), |
| 233 | + ] |
225 | 234 | )
|
226 |
| - mock_open_file().write.assert_called_once_with(expected_output) |
227 | 235 |
|
228 | 236 |
|
229 | 237 | class TestWriteToMarkdownWithEnv(unittest.TestCase):
|
|
0 commit comments