def __init__(self, issue, session=None): super(Issue, self).__init__(issue, session) self._api = issue.get('url', '') #: :class:`User <github3.users.User>` representing the user the issue # was assigned to. self.assignee = issue.get('assignee') if self.assignee: self.assignee = User(issue.get('assignee'), self._session) #: Body (description) of the issue. self.body = issue.get('body', '') #: HTML formatted body of the issue. self.body_html = issue.get('body_html', '') #: Plain text formatted body of the issue. self.body_text = issue.get('body_text', '') # If an issue is still open, this field will be None #: datetime object representing when the issue was closed. self.closed_at = None if issue.get('closed_at'): self.closed_at = self._strptime(issue.get('closed_at')) #: Number of comments on this issue. self.comments = issue.get('comments') #: datetime object representing when the issue was created. self.created_at = self._strptime(issue.get('created_at')) #: URL to view the issue at GitHub. self.html_url = issue.get('html_url') #: Unique ID for the issue. self.id = issue.get('id') #: Returns the list of :class:`Label <Label>`\ s on this issue. self.labels = [Label(l, self._session) for l in issue.get('labels')] #: :class:`Milestone <Milestone>` this issue was assigned to. self.milestone = None if issue.get('milestone'): self.milestone = Milestone(issue.get('milestone'), self._session) #: Issue number (e.g. #15) self.number = issue.get('number') #: Dictionary URLs for the pull request (if they exist) self.pull_request = issue.get('pull_request') m = match('https://github\.com/(\S+)/(\S+)/issues/\d+', self.html_url) #: Returns ('owner', 'repository') this issue was filed on. self.repository = m.groups() #: State of the issue, e.g., open, closed self.state = issue.get('state') #: Title of the issue. self.title = issue.get('title') #: datetime object representing the last time the issue was updated. self.updated_at = self._strptime(issue.get('updated_at')) #: :class:`User <github3.users.User>` who opened the issue. self.user = User(issue.get('user'), self._session)
def test_due_on(self): json = self.m.to_json().copy() json['due_on'] = '2012-12-31T23:59:59Z' m = Milestone(json) assert isinstance(m.due_on, datetime.datetime)
def setUp(self): super(TestMilestone, self).setUp() self.m = Milestone(self.m.to_json(), self.g)
def __init__(self, methodName='runTest'): super(TestMilestone, self).__init__(methodName) self.m = Milestone(load('milestone')) self.api = ("https://api.github.com/repos/kennethreitz/requests/" "milestones/18")
class TestMilestone(BaseCase): def __init__(self, methodName='runTest'): super(TestMilestone, self).__init__(methodName) self.m = Milestone(load('milestone')) self.api = ("https://api.github.com/repos/kennethreitz/requests/" "milestones/18") def setUp(self): super(TestMilestone, self).setUp() self.m = Milestone(self.m.to_json(), self.g) def test_repr(self): assert repr(self.m) == '<Milestone [v1.0.0]>' def test_str(self): assert str(self.m) == 'v1.0.0' def test_delete(self): self.response('', 204) self.delete(self.api) self.assertRaises(github3.GitHubError, self.m.delete) self.not_called() self.login() assert self.m.delete() self.mock_assertions() def test_due_on(self): json = self.m.to_json().copy() json['due_on'] = '2012-12-31T23:59:59Z' m = Milestone(json) assert isinstance(m.due_on, datetime.datetime) def test_iter_labels(self): self.response('label', _iter=True) self.get(self.api + '/labels') i = self.m.iter_labels() assert isinstance(i, github3.structs.GitHubIterator) assert isinstance((next(i)), Label) self.mock_assertions() def test_update(self): self.response('milestone', 200) self.patch(self.api) self.conf = { 'data': { 'title': 'foo', 'state': 'closed', 'description': ':sparkles:', 'due_on': '2013-12-31T23:59:59Z' } } self.assertRaises(github3.GitHubError, self.m.update, None) self.login() assert self.m.update(None) is False self.not_called() assert self.m.update(state='closed') assert self.m.update('foo', 'closed', ':sparkles:', '2013-12-31T23:59:59Z') self.mock_assertions()