Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0751ee8

Browse files
committed
Remove GistComment dependence on BaseComment
Update our example response for unit tests to make this more testableand an accurate representation of what github3.py gets back.
1 parentd2fb594 commit0751ee8

File tree

2 files changed

+83
-20
lines changed

2 files changed

+83
-20
lines changed

‎github3/gists/comment.py‎

Lines changed: 80 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,102 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
github3.gists.comment
4-
---------------------
5-
6-
Module containing the logic for a GistComment
7-
8-
"""
2+
"""Module containing the logic for a GistComment."""
93
from __future__importunicode_literals
104

5+
from ..importdecorators
6+
from ..importmodels
117
from ..importusers
12-
from ..modelsimportBaseComment
138

149

15-
classGistComment(BaseComment):
10+
classGistComment(models.GitHubCore):
11+
"""Representation of a comment left on a :class:`~github3.gists.Gist`.
12+
13+
See also: http://developer.github.com/v3/gists/comments/
1614
17-
"""This object represents a comment on a gist.
15+
.. versionchanged:: 1.0.0
1816
19-
Two comment instances can be checked like so::
17+
The ``links``, ``html_url``, and ``pull_request_url`` attributes were
18+
removed as none of them exist in the response from GitHub.
2019
21-
c1 == c2
22-
c1 != c2
20+
This object has the following attributes:
2321
24-
And is equivalent to::
22+
.. attribute:: author_association
2523
26-
c1.id == c2.id
27-
c1.id != c2.id
24+
The comment author's (:attr:`user`) association with this gist.
2825
29-
See also: http://developer.github.com/v3/gists/comments/
26+
.. attribute:: body
27+
28+
The markdown formatted original text written by the author.
29+
30+
.. attribute:: body_html
31+
32+
The HTML formatted comment body.
33+
34+
.. attribute:: body_text
35+
36+
The plain-text formatted comment body.
37+
38+
.. attribute:: created_at
3039
40+
A :class:`~datetime.datetime` object representing the date and time
41+
when this comment was created.
42+
43+
.. attribute:: id
44+
45+
The unique identifier for this comment.
46+
47+
.. attribute:: updated_at
48+
49+
A :class:`~datetime.datetime` object representing the date and time
50+
when this comment was most recently updated.
51+
52+
.. attribute:: user
53+
54+
A :class:`~github3.users.ShortUser` representing the author of this
55+
comment.
3156
"""
3257

3358
def_update_attributes(self,comment):
34-
self._api=self._get_attribute(comment,'url')
35-
#: :class:`User <github3.users.User>` who made the comment
36-
#: Unless it is not associated with an account
59+
self._api=comment['url']
60+
self.author_association=comment['author_association']
61+
self.body=comment['body']
62+
self.body_html=comment['body_html']
63+
self.body_text=comment['body_text']
64+
self.created_at=comment['created_at']
65+
self.id=comment['id']
66+
self.updated_at=comment['updated_at']
3767
self.user=self._class_attribute(
3868
comment,'user',users.ShortUser,self,
3969
)
4070

4171
def_repr(self):
4272
return'<Gist Comment [{0}]>'.format(self.user.login)
73+
74+
@decorators.requires_auth
75+
defdelete(self):
76+
"""Delete this comment from the gist.
77+
78+
:returns:
79+
True if successful, False otherwise
80+
:rtype:
81+
bool
82+
"""
83+
returnself._boolean(self._delete(self._api),204,404)
84+
85+
@decorators.requires_auth
86+
defedit(self,body):
87+
"""Edit this comment.
88+
89+
:param str body:
90+
(required), new body of the comment, Markdown-formatted
91+
:returns:
92+
True if successful, False otherwise
93+
:rtype:
94+
bool
95+
"""
96+
ifbody:
97+
json=self._json(self._patch(self._api,
98+
json={'body':body}),200)
99+
ifjson:
100+
self._update_attributes(json)
101+
returnTrue
102+
returnFalse

‎tests/unit/json/gist_comment_example‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
2+
"author_association": "OWNER",
23
"body": "I was using curl, but this is awesome, too :)\r\n\r\n`curl -u <username> -XDELETE https://api.github.com/gists/<gist_id>/comments/<comment_id>`",
4+
"body_html": "I was using curl, but this is awesome, too",
5+
"body_text": "I was using curl, but this is awesome, too",
36
"created_at": "2012-12-17T19:56:05Z",
47
"id": 655725,
58
"updated_at": "2012-12-17T19:56:05Z",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp