22
22
"SEARCH_QUERY" : "is:open repo:user/repo" ,
23
23
"GH_TOKEN" : "test_token" ,
24
24
"DRAFT_PR_TRACKING" : "True" ,
25
+ "HIDE_CREATED_AT" : "False" ,
25
26
},
26
27
)
27
28
class TestWriteToMarkdown (unittest .TestCase ):
@@ -44,6 +45,7 @@ def test_write_to_markdown(self):
44
45
title = "Issue 1" ,
45
46
html_url = "https://github.com/user/repo/issues/1" ,
46
47
author = "alice" ,
48
+ created_at = timedelta (days = - 5 ),
47
49
time_to_first_response = timedelta (days = 1 ),
48
50
time_to_close = timedelta (days = 2 ),
49
51
time_to_answer = timedelta (days = 3 ),
@@ -54,6 +56,7 @@ def test_write_to_markdown(self):
54
56
title = "Issue 2\r " ,
55
57
html_url = "https://github.com/user/repo/issues/2" ,
56
58
author = "bob" ,
59
+ created_at = timedelta (days = - 5 ),
57
60
time_to_first_response = timedelta (days = 3 ),
58
61
time_to_close = timedelta (days = 4 ),
59
62
time_to_answer = timedelta (days = 5 ),
@@ -129,12 +132,12 @@ def test_write_to_markdown(self):
129
132
"| Number of most active mentors | 5 |\n "
130
133
"| Total number of items created | 2 |\n \n "
131
134
"| Title | URL | Author | Time to first response | Time to close |"
132
- " Time to answer | Time in draft | Time spent in bug |\n "
133
- "| --- | --- | --- | --- | --- | --- | --- | --- |\n "
135
+ " Time to answer | Time in draft | Time spent in bug | Created At | \n "
136
+ "| --- | --- | --- | --- | --- | --- | --- | --- | --- | \n "
134
137
"| Issue 1 | https://github.com/user/repo/issues/1 | [alice](https://github.com/alice) | 1 day, 0:00:00 | "
135
- "2 days, 0:00:00 | 3 days, 0:00:00 | 1 day, 0:00:00 | 4 days, 0:00:00 |\n "
138
+ "2 days, 0:00:00 | 3 days, 0:00:00 | 1 day, 0:00:00 | 4 days, 0:00:00 | -5 days, 0:00:00 | \n "
136
139
"| Issue 2 | https://github.com/user/repo/issues/2 | [bob](https://github.com/bob) | 3 days, 0:00:00 | "
137
- "4 days, 0:00:00 | 5 days, 0:00:00 | 1 day, 0:00:00 | 2 days, 0:00:00 |\n \n "
140
+ "4 days, 0:00:00 | 5 days, 0:00:00 | 1 day, 0:00:00 | 2 days, 0:00:00 | -5 days, 0:00:00 | \n \n "
138
141
"_This report was generated with the [Issue Metrics Action](https://github.com/github/issue-metrics)_\n "
139
142
"Search query used to find these items: `is:issue is:open label:bug`\n "
140
143
)
@@ -156,6 +159,7 @@ def test_write_to_markdown_with_vertical_bar_in_title(self):
156
159
title = "Issue 1" ,
157
160
html_url = "https://github.com/user/repo/issues/1" ,
158
161
author = "alice" ,
162
+ created_at = timedelta (days = - 5 ),
159
163
time_to_first_response = timedelta (days = 1 ),
160
164
time_to_close = timedelta (days = 2 ),
161
165
time_to_answer = timedelta (days = 3 ),
@@ -166,6 +170,7 @@ def test_write_to_markdown_with_vertical_bar_in_title(self):
166
170
title = "feat| Issue 2" , # title contains a vertical bar
167
171
html_url = "https://github.com/user/repo/issues/2" ,
168
172
author = "bob" ,
173
+ created_at = timedelta (days = - 5 ),
169
174
time_to_first_response = timedelta (days = 3 ),
170
175
time_to_close = timedelta (days = 4 ),
171
176
time_to_answer = timedelta (days = 5 ),
@@ -238,12 +243,12 @@ def test_write_to_markdown_with_vertical_bar_in_title(self):
238
243
"| Number of most active mentors | 5 |\n "
239
244
"| Total number of items created | 2 |\n \n "
240
245
"| Title | URL | Author | Time to first response | Time to close |"
241
- " Time to answer | Time in draft | Time spent in bug |\n "
242
- "| --- | --- | --- | --- | --- | --- | --- | --- |\n "
246
+ " Time to answer | Time in draft | Time spent in bug | Created At | \n "
247
+ "| --- | --- | --- | --- | --- | --- | --- | --- | --- | \n "
243
248
"| Issue 1 | https://github.com/user/repo/issues/1 | [alice](https://github.com/alice) | 1 day, 0:00:00 | "
244
- "2 days, 0:00:00 | 3 days, 0:00:00 | 1 day, 0:00:00 | 1 day, 0:00:00 |\n "
249
+ "2 days, 0:00:00 | 3 days, 0:00:00 | 1 day, 0:00:00 | 1 day, 0:00:00 | -5 days, 0:00:00 | \n "
245
250
"| feat| Issue 2 | https://github.com/user/repo/issues/2 | [bob](https://github.com/bob) | 3 days, 0:00:00 | "
246
- "4 days, 0:00:00 | 5 days, 0:00:00 | None | 2 days, 0:00:00 |\n \n "
251
+ "4 days, 0:00:00 | 5 days, 0:00:00 | None | 2 days, 0:00:00 | -5 days, 0:00:00 | \n \n "
247
252
"_This report was generated with the [Issue Metrics Action](https://github.com/github/issue-metrics)_\n "
248
253
)
249
254
self .assertEqual (content , expected_content )
@@ -287,6 +292,7 @@ def test_write_to_markdown_no_issues(self):
287
292
{
288
293
"SEARCH_QUERY" : "is:open repo:user/repo" ,
289
294
"GH_TOKEN" : "test_token" ,
295
+ "HIDE_CREATED_AT" : "False" ,
290
296
"HIDE_TIME_TO_FIRST_RESPONSE" : "True" ,
291
297
"HIDE_TIME_TO_CLOSE" : "True" ,
292
298
"HIDE_TIME_TO_ANSWER" : "True" ,
@@ -309,6 +315,7 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self):
309
315
title = "Issue 1" ,
310
316
html_url = "https://github.com/user/repo/issues/1" ,
311
317
author = "alice" ,
318
+ created_at = timedelta (days = - 5 ),
312
319
time_to_first_response = timedelta (minutes = 10 ),
313
320
time_to_close = timedelta (days = 1 ),
314
321
time_to_answer = timedelta (hours = 2 ),
@@ -321,6 +328,7 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self):
321
328
title = "Issue 2" ,
322
329
html_url = "https://github.com/user/repo/issues/2" ,
323
330
author = "bob" ,
331
+ created_at = timedelta (days = - 5 ),
324
332
time_to_first_response = timedelta (minutes = 20 ),
325
333
time_to_close = timedelta (days = 2 ),
326
334
time_to_answer = timedelta (hours = 4 ),
@@ -363,17 +371,18 @@ def test_writes_markdown_file_with_non_hidden_columns_only(self):
363
371
# Check that the function writes the correct markdown file
364
372
with open ("issue_metrics.md" , "r" , encoding = "utf-8" ) as file :
365
373
content = file .read ()
374
+
366
375
expected_content = (
367
376
"# Issue Metrics\n \n "
368
377
"| Metric | Count |\n "
369
378
"| --- | ---: |\n "
370
379
"| Number of items that remain open | 2 |\n "
371
380
"| Number of most active mentors | 5 |\n "
372
381
"| Total number of items created | 2 |\n \n "
373
- "| Title | URL | Author |\n "
374
- "| --- | --- | --- |\n "
375
- "| Issue 1 | https://www.github.com/user/repo/issues/1 | [alice](https://github.com/alice) |\n "
376
- "| Issue 2 | https://www.github.com/user/repo/issues/2 | [bob](https://github.com/bob) |\n \n "
382
+ "| Title | URL | Author | Created At | \n "
383
+ "| --- | --- | --- | --- | \n "
384
+ "| Issue 1 | https://www.github.com/user/repo/issues/1 | [alice](https://github.com/alice) | -5 days, 0:00:00 | \n "
385
+ "| Issue 2 | https://www.github.com/user/repo/issues/2 | [bob](https://github.com/bob) | -5 days, 0:00:00 | \n \n "
377
386
"_This report was generated with the [Issue Metrics Action](https://github.com/github/issue-metrics)_\n "
378
387
"Search query used to find these items: `repo:user/repo is:issue`\n "
379
388
)
0 commit comments