def test_equality(self): """Show that two instances of Label are equal.""" label = Label(get_issue_label_example_data()) assert self.instance == label label._uniq = ('https://https//api.github.com/repos/sigmavirus24/' 'github3.py/labels/wontfix') assert self.instance != label
class TestLabel(BaseCase): def __init__(self, methodName='runTest'): super(TestLabel, self).__init__(methodName) self.l = Label(load('label')) self.api = ("https://api.github.com/repos/sigmavirus24/github3.py/" "labels/Bug") def setUp(self): super(TestLabel, self).setUp() self.l = Label(self.l.to_json(), self.g) def test_equality(self): l = Label(load('label')) assert self.l == l l._uniq = ("https://api.github.com/repos/sigmavirus24/github3.py/" "labels/wontfix") assert self.l != l def test_repr(self): assert repr(self.l) == '<Label [{0}]>'.format(self.l.name) def test_str(self): assert str(self.l) == self.l.name def test_delete(self): self.response('', 204) self.delete(self.api) self.assertRaises(github3.GitHubError, self.l.delete) self.not_called() self.login() assert self.l.delete() def test_update(self): self.response('label', 200) self.patch(self.api) self.conf = {'data': {'name': 'newname', 'color': 'afafaf'}} self.assertRaises(github3.GitHubError, self.l.update, None, None) self.login() assert self.l.update(None, None) is False self.not_called() assert self.l.update('newname', 'afafaf') self.mock_assertions() assert self.l.update('newname', '#afafaf') self.mock_assertions()
class TestLabel(BaseCase): def __init__(self, methodName='runTest'): super(TestLabel, self).__init__(methodName) self.l = Label(load('label')) self.api = ("https://api.github.com/repos/sigmavirus24/github3.py/" "labels/bug") def setUp(self): super(TestLabel, self).setUp() self.l = Label(self.l.to_json(), self.g) def test_equality(self): l = Label(load('label')) expect(self.l) == l l._api = "https://api.github.com/repos/sigmavirus24/github3.py/labels/wontfix" expect(self.l) != l def test_repr(self): expect(repr(self.l)) == '<Label [{0}]>'.format(self.l.name) def test_str(self): expect(str(self.l)) == self.l.name def test_delete(self): self.response('', 204) self.delete(self.api) with expect.githuberror(): self.l.delete() self.not_called() self.login() expect(self.l.delete()).is_True() def test_update(self): self.response('label', 200) self.patch(self.api) self.conf = {'data': {'name': 'newname', 'color': 'afafaf'}} with expect.githuberror(): self.l.update(None, None) self.login() expect(self.l.update(None, None)).is_False() self.not_called() expect(self.l.update('newname', 'afafaf')).is_True() self.mock_assertions() expect(self.l.update('newname', '#afafaf')).is_True() self.mock_assertions()
def add_labels(self, *args): """Add labels to this issue. :param str args: (required), names of the labels you wish to add :returns: list of :class:`Label`\ s """ url = self._build_url('labels', base_url=self._api) json = self._json(self._post(url, data=args), 200) return [Label(l, self) for l in json] if json else []
def replace_labels(self, labels): """Replace all labels on this issue with ``labels``. :param list labels: label names :returns: bool """ url = self._build_url('labels', base_url=self._api) json = self._json(self._put(url, data=dumps(labels)), 200) return [Label(l, self) for l in json] if json else []
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_equality(self): l = Label(load('label')) assert self.l == l l._uniq = ("https://api.github.com/repos/sigmavirus24/github3.py/" "labels/wontfix") assert self.l != l
def setUp(self): super(TestLabel, self).setUp() self.l = Label(self.l.to_json(), self.g)
def __init__(self, methodName='runTest'): super(TestLabel, self).__init__(methodName) self.l = Label(load('label')) self.api = ("https://api.github.com/repos/sigmavirus24/github3.py/" "labels/Bug")
def test_equality(self): l = Label(load('label')) expect(self.l) == l l._api = "https://api.github.com/repos/sigmavirus24/github3.py/labels/wontfix" expect(self.l) != l