Skip to content

Commit adf33b6

Browse files
mrbahraniabahrani97crazyscientist
authored
Rename method getcomments to get_comments for better readablity (#226)
Using the api, I used to think the only way to retrieve the comments is to go through a Bugzilla instance. Later, I figured out the the Bug objects have the method `get_attachments` and I was amazed that there is no `get_comments`. Digging into the code I realized the method has been named `getcomments`. I have changed all the occurrences of `getcomments` method of the Bug class to `get_comment` --------- Co-authored-by: abahrani <[email protected]> Co-authored-by: Andreas Hasenkopf <[email protected]>
1 parent 2d3ba4e commit adf33b6

5 files changed

Lines changed: 11 additions & 7 deletions

File tree

bugzilla/bug.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,14 @@ def addcomment(self, comment, private=False):
292292

293293
return self.bugzilla.update_bugs(self.bug_id, vals)
294294

295-
def getcomments(self):
295+
def get_comments(self):
296296
"""
297297
Returns an array of comment dictionaries for this bug
298298
"""
299299
comment_list = self.bugzilla.get_comments([self.bug_id])
300300
return comment_list['bugs'][str(self.bug_id)]['comments']
301301

302-
302+
getcomments = get_comments
303303
#####################
304304
# Get/Set bug flags #
305305
#####################

examples/getbug.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434
# comments must be fetched separately on stock bugzilla. this just returns
3535
# a raw dict with all the info.
36-
comments = bug.getcomments()
36+
comments = bug.get_comments()
3737
print("\nLast comment data:\n%s" % pprint.pformat(comments[-1]))
3838

39-
# getcomments is just a wrapper around bzapi.get_comments(), which can be
39+
# get_comments is just a wrapper around bzapi.get_comments(), which can be
4040
# used for bulk comments fetching

examples/update.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838

3939

4040
# Now let's add a comment
41-
comments = bug.getcomments()
41+
comments = bug.get_comments()
4242
print("Bug originally has %d comments" % len(comments))
4343

4444
update = bzapi.build_update(comment="new example comment %s" % time.time())
4545
bzapi.update_bugs([bug.id], update)
4646

4747
# refresh() actually isn't required here because comments are fetched
4848
# on demand
49-
comments = bug.getcomments()
49+
comments = bug.get_comments()
5050
print("Bug now has %d comments. Last comment=%s" % (len(comments),
5151
comments[-1]["text"]))
5252

tests/test_api_bug.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def _get_fake_bug(apiname):
200200
# Stub API testing
201201
bug = fakebz.getbug(1165434)
202202
bug.get_history_raw()
203+
bug.get_comments()
203204
bug.getcomments()
204205

205206
# Some hackery to hit a few attachment code paths

tests/test_rw_functional.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,11 @@ def test05ModifyStatus(run_cli, backends):
318318
assert bug.longdescs[-1]["text"] == comment
319319
assert bug.longdescs[-1]["is_private"] == 0
320320

321-
# Confirm comments is same as getcomments
321+
# Confirm comments is same as get_comments
322+
assert bug.comments == bug.get_comments()
323+
# This method will be removed in a future version
322324
assert bug.comments == bug.getcomments()
325+
assert bug.get_comments() == bug.getcomments()
323326

324327
# Reset state
325328
run_cli(cmd + "--status %s" % origstatus, bz)

0 commit comments

Comments
 (0)