Skip to content

Commit 22a1e9e

Browse files
author
Neefs, Jef
committed
updating the test of Comment resource with the notification bool
1 parent b213f82 commit 22a1e9e

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

tests/resources/test_comment.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
class CommentTests(JiraTestCase):
55
def setUp(self):
66
JiraTestCase.setUp(self)
7-
self.issue_1 = self.test_manager.project_b_issue1
8-
self.issue_2 = self.test_manager.project_b_issue2
9-
self.issue_3 = self.test_manager.project_b_issue3
7+
self.issue_1_key = self.test_manager.project_b_issue1
8+
self.issue_2_key = self.test_manager.project_b_issue2
9+
self.issue_3_key = self.test_manager.project_b_issue3
10+
11+
def tearDown(self) -> None:
12+
for issue in [self.issue_1_key, self.issue_2_key, self.issue_3_key]:
13+
for comment in self.jira.comments(issue):
14+
comment.delete()
1015

1116
def test_comments(self):
12-
for issue in [self.issue_1, self.jira.issue(self.issue_2)]:
17+
for issue in [self.issue_1_key, self.jira.issue(self.issue_2_key)]:
1318
self.jira.issue(issue)
1419
comment1 = self.jira.add_comment(issue, "First comment")
1520
comment2 = self.jira.add_comment(issue, "Second comment")
@@ -22,24 +27,24 @@ def test_comments(self):
2227
assert len(comments) == 0
2328

2429
def test_expanded_comments(self):
25-
comment1 = self.jira.add_comment(self.issue_1, "First comment")
26-
comment2 = self.jira.add_comment(self.issue_1, "Second comment")
27-
comments = self.jira.comments(self.issue_1, expand="renderedBody")
30+
comment1 = self.jira.add_comment(self.issue_1_key, "First comment")
31+
comment2 = self.jira.add_comment(self.issue_1_key, "Second comment")
32+
comments = self.jira.comments(self.issue_1_key, expand="renderedBody")
2833
self.assertTrue(hasattr(comments[0], "renderedBody"))
2934
ret_comment1 = self.jira.comment(
30-
self.issue_1, comment1.id, expand="renderedBody"
35+
self.issue_1_key, comment1.id, expand="renderedBody"
3136
)
32-
ret_comment2 = self.jira.comment(self.issue_1, comment2.id)
37+
ret_comment2 = self.jira.comment(self.issue_1_key, comment2.id)
3338
comment1.delete()
3439
comment2.delete()
3540
self.assertTrue(hasattr(ret_comment1, "renderedBody"))
3641
self.assertFalse(hasattr(ret_comment2, "renderedBody"))
37-
comments = self.jira.comments(self.issue_1)
42+
comments = self.jira.comments(self.issue_1_key)
3843
assert len(comments) == 0
3944

4045
def test_add_comment(self):
4146
comment = self.jira.add_comment(
42-
self.issue_3,
47+
self.issue_3_key,
4348
"a test comment!",
4449
visibility={"type": "role", "value": "Administrators"},
4550
)
@@ -49,7 +54,7 @@ def test_add_comment(self):
4954
comment.delete()
5055

5156
def test_add_comment_with_issue_obj(self):
52-
issue = self.jira.issue(self.issue_3)
57+
issue = self.jira.issue(self.issue_3_key)
5358
comment = self.jira.add_comment(
5459
issue,
5560
"a new test comment!",
@@ -61,9 +66,11 @@ def test_add_comment_with_issue_obj(self):
6166
comment.delete()
6267

6368
def test_update_comment(self):
64-
comment = self.jira.add_comment(self.issue_3, "updating soon!")
69+
comment = self.jira.add_comment(self.issue_3_key, "updating soon!")
6570
comment.update(body="updated!")
66-
self.assertEqual(comment.body, "updated!")
71+
assert comment.body == "updated!"
72+
comment.update(body="updated! without notification", notify=False)
73+
assert comment.body == "updated! without notification"
6774
# self.assertEqual(comment.visibility.type, 'role')
6875
# self.assertEqual(comment.visibility.value, 'Administrators')
6976
comment.delete()

0 commit comments

Comments
 (0)