From 6eeeef96f877d44a8e54a75846617fa5b225b313 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 11:33:54 +0100 Subject: [PATCH 01/32] Add per-file licensing info. Removes a -10 'packaging smell', and basically for free with ucopy ;) --- .ucopy.cfg | 21 ++++++++++++ AUTHORS | 49 ++++++++++++++++------------ doc/.templates/layout.html | 7 ++++ doc/api/client.rst | 8 +++++ doc/api/commit.rst | 6 ++++ doc/api/core.rst | 6 ++++ doc/api/index.rst | 6 ++++ doc/api/issues.rst | 6 ++++ doc/api/network.rst | 6 ++++ doc/api/object.rst | 6 ++++ doc/api/organizations.rst | 6 ++++ doc/api/pull_requests.rst | 6 ++++ doc/api/repos.rst | 6 ++++ doc/api/request.rst | 6 ++++ doc/api/teams.rst | 6 ++++ doc/api/users.rst | 6 ++++ doc/bugs.rst | 6 ++++ doc/contributing.rst | 6 ++++ doc/index.rst | 9 ++--- doc/install.rst | 7 ++++ doc/license.rst | 6 ++++ doc/problems.rst | 6 ++++ doc/quickstart.rst | 6 ++++ doc/release.rst | 6 ++++ doc/wild.rst | 7 ++++ examples/friend-or-follow.py | 5 +++ github2/__init__.py | 6 ++++ github2/bin/__init__.py | 4 +++ github2/bin/manage_collaborators.py | 7 ++-- github2/bin/search_repos.py | 4 +++ github2/client.py | 15 +++++++++ github2/commits.py | 9 +++++ github2/core.py | 13 ++++++++ github2/issues.py | 10 ++++++ github2/organizations.py | 7 ++++ github2/pull_requests.py | 9 +++++ github2/repositories.py | 17 ++++++++++ github2/request.py | 21 ++++++++++++ github2/teams.py | 6 ++++ github2/users.py | 9 +++++ setup.py | 10 ++++++ tests/test_charset_header.py | 5 +++ tests/test_commits.py | 5 +++ tests/test_date_handling.py | 4 +++ tests/test_issues.py | 5 +++ tests/test_organizations.py | 5 +++ tests/test_pull_requests.py | 5 +++ tests/test_regression.py | 5 +++ tests/test_repositories.py | 7 ++++ tests/test_request.py | 5 +++ tests/test_teams.py | 5 +++ tests/test_tz_aware_date_handling.py | 4 +++ tests/test_unit.py | 7 ++++ tests/test_user.py | 5 +++ tests/utils.py | 5 +++ 55 files changed, 413 insertions(+), 27 deletions(-) create mode 100644 .ucopy.cfg diff --git a/.ucopy.cfg b/.ucopy.cfg new file mode 100644 index 0000000..530185a --- /dev/null +++ b/.ucopy.cfg @@ -0,0 +1,21 @@ +[repo] +name = python-github2 +license-from = bsd-3 +vcs = git + +[files] +ignore-from = git +ignore-glob = COPYING, README.rst, .keep, test/data/github.com,api* + +[patch] +unicode = python + +[author-override] +Ask Solem = +Chris Vale = +Claudio B. = +Daniel Greenfeld = +Donald von Stufft = +Michael Basnight = +Sameer Al-Sakran = +Stéphane Angel = diff --git a/AUTHORS b/AUTHORS index 99f5070..5e14ae3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,31 +1,38 @@ -Ask Solem -Mark Paschal -Donald von Stufft -Maximillian Dornseif +python-github2 was written by: + +Ask Solem + +with contributions from the following people: + +Adam Vandenberg Asheesh Laroia -Rick Harris -Cody Soyland -Fernando Perez -Evan Broder -Scott Torborg -Claudio B. +Barthelemy Dagenais Chris Vale -Adam Vandenberg -Kenneth Reitz +Christopher MacGown +Claudio B. +Cody Soyland Daniel Greenfeld +Donald von Stufft +Evan Broder +Fernando Perez +Ionuț Arțăriși +James Rowe +Jens Ohlig Jeremy Dunck Jonas Obrist -Sameer Al-Sakran -Vincent Driessen -James Rowe Josh Weinberg -Barthelemy Dagenais -Surajram Kumarave -broderboy -Patryk Zawadzki +Justin Quick +Kenneth Reitz +Mark Paschal +Maximillian Dornseif Michael Basnight -Christopher MacGown +Patryk Zawadzki +Rick Harris Rok Garbas -Ionuț Arțăriși +Sameer Al-Sakran +Scott Torborg Stéphane Angel +Surajram Kumaravel +Vincent Driessen +broderboy modocache diff --git a/doc/.templates/layout.html b/doc/.templates/layout.html index 3560b06..b251a03 100644 --- a/doc/.templates/layout.html +++ b/doc/.templates/layout.html @@ -1,3 +1,10 @@ +{# + Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, and is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. +#} {% extends "!layout.html" %} {% block extrahead %} diff --git a/doc/api/client.rst b/doc/api/client.rst index b11eaa8..1cf0ea9 100644 --- a/doc/api/client.rst +++ b/doc/api/client.rst @@ -1,3 +1,11 @@ +.. Copyright (C) 2011-2012 James Rowe + Michael Basnight + modocache + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. module:: github2.client Creating a client diff --git a/doc/api/commit.rst b/doc/api/commit.rst index e4a69bf..ffca1a2 100644 --- a/doc/api/commit.rst +++ b/doc/api/commit.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. module:: github2.commits Commit diff --git a/doc/api/core.rst b/doc/api/core.rst index 9b9e297..1e26d09 100644 --- a/doc/api/core.rst +++ b/doc/api/core.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. module:: github2.core Core diff --git a/doc/api/index.rst b/doc/api/index.rst index cbe2c5c..36fa3a0 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + API documentation ================= diff --git a/doc/api/issues.rst b/doc/api/issues.rst index 6ba740c..1f2dcfb 100644 --- a/doc/api/issues.rst +++ b/doc/api/issues.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. module:: github2.issues Issues diff --git a/doc/api/network.rst b/doc/api/network.rst index f07baa9..1d7312d 100644 --- a/doc/api/network.rst +++ b/doc/api/network.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. currentmodule:: github2.client Network diff --git a/doc/api/object.rst b/doc/api/object.rst index 79842c7..106b685 100644 --- a/doc/api/object.rst +++ b/doc/api/object.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. currentmodule:: github2.client Object diff --git a/doc/api/organizations.rst b/doc/api/organizations.rst index fc46950..b4fb0f6 100644 --- a/doc/api/organizations.rst +++ b/doc/api/organizations.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. module:: github2.organizations Organizations diff --git a/doc/api/pull_requests.rst b/doc/api/pull_requests.rst index 140a824..ee6f518 100644 --- a/doc/api/pull_requests.rst +++ b/doc/api/pull_requests.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. module:: github2.pull_requests Pull requests diff --git a/doc/api/repos.rst b/doc/api/repos.rst index 4f777ee..1d96337 100644 --- a/doc/api/repos.rst +++ b/doc/api/repos.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. module:: github2.repositories Repository diff --git a/doc/api/request.rst b/doc/api/request.rst index 0dd71f2..b3ffc49 100644 --- a/doc/api/request.rst +++ b/doc/api/request.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. module:: github2.request Requests diff --git a/doc/api/teams.rst b/doc/api/teams.rst index dc2102b..4e72746 100644 --- a/doc/api/teams.rst +++ b/doc/api/teams.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. module:: github2.teams Teams diff --git a/doc/api/users.rst b/doc/api/users.rst index 052092a..d9ac95d 100644 --- a/doc/api/users.rst +++ b/doc/api/users.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + .. module:: github2.users Users diff --git a/doc/bugs.rst b/doc/bugs.rst index 6105987..1c838a1 100644 --- a/doc/bugs.rst +++ b/doc/bugs.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, and is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + Reporting bugs ============== diff --git a/doc/contributing.rst b/doc/contributing.rst index 8c3b47a..ad846be 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, and is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + Contributing ============ diff --git a/doc/index.rst b/doc/index.rst index 55814bf..5b21867 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,7 +1,8 @@ -.. python-github2 documentation master file, created by - sphinx-quickstart on Mon Apr 11 16:16:25 2011. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, and is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. .. If you prefer you can also read the pre-built documentation at diff --git a/doc/install.rst b/doc/install.rst index 8d309ee..84b57de 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -1,3 +1,10 @@ +.. Copyright (C) 2011-2012 James Rowe + Michael Basnight + + This file is part of python-github2, and is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + Installation ------------ diff --git a/doc/license.rst b/doc/license.rst index 7e1c1b4..316b2ae 100644 --- a/doc/license.rst +++ b/doc/license.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, and is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + License ======= diff --git a/doc/problems.rst b/doc/problems.rst index 5fabddf..31d3052 100644 --- a/doc/problems.rst +++ b/doc/problems.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, and is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + Solving problems ================ diff --git a/doc/quickstart.rst b/doc/quickstart.rst index bb41f5e..2d3988f 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2011-2012 James Rowe + + This file is part of python-github2, and is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + Quickstart ========== diff --git a/doc/release.rst b/doc/release.rst index b7baf79..745d419 100644 --- a/doc/release.rst +++ b/doc/release.rst @@ -1,3 +1,9 @@ +.. Copyright (C) 2012 James Rowe + + This file is part of python-github2, and is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + Release HOWTO ============= diff --git a/doc/wild.rst b/doc/wild.rst index 8a49b96..07bd653 100644 --- a/doc/wild.rst +++ b/doc/wild.rst @@ -1,3 +1,10 @@ +.. Copyright (C) 2011-2012 James Rowe + Stéphane Angel + + This file is part of python-github2, and is licensed under the 3-clause BSD + License. See the LICENSE file in the top distribution directory for the full + license text. + In the wild ----------- diff --git a/examples/friend-or-follow.py b/examples/friend-or-follow.py index ccef96a..9a19b74 100644 --- a/examples/friend-or-follow.py +++ b/examples/friend-or-follow.py @@ -1,3 +1,8 @@ +# Copyright (C) 2010-2012 Ask Solem +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + import sys import optparse from subprocess import Popen, PIPE diff --git a/github2/__init__.py b/github2/__init__.py index 30d323e..cf56247 100644 --- a/github2/__init__.py +++ b/github2/__init__.py @@ -1,4 +1,10 @@ "Github API v2 library for Python" +# Copyright (C) 2009-2012 Ask Solem +# James Rowe +# Maximillian Dornseif +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. from github2 import _version diff --git a/github2/bin/__init__.py b/github2/bin/__init__.py index 792d600..6c5b974 100644 --- a/github2/bin/__init__.py +++ b/github2/bin/__init__.py @@ -1 +1,5 @@ # +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. diff --git a/github2/bin/manage_collaborators.py b/github2/bin/manage_collaborators.py index 3efafee..6e320fb 100755 --- a/github2/bin/manage_collaborators.py +++ b/github2/bin/manage_collaborators.py @@ -8,8 +8,11 @@ """ # Created by Maximillian Dornseif on 2009-12-31 for HUDORA. -# Copyright (c) 2009 HUDORA. All rights reserved. -# BSD licensed +# Copyright (C) 2009-2012 James Rowe +# Maximillian Dornseif +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. import logging import sys diff --git a/github2/bin/search_repos.py b/github2/bin/search_repos.py index c52be46..3064ff2 100755 --- a/github2/bin/search_repos.py +++ b/github2/bin/search_repos.py @@ -1,6 +1,10 @@ #! /usr/bin/env python # coding: utf-8 """github_search_repos - search for repositories on GitHub""" +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. import logging diff --git a/github2/client.py b/github2/client.py index c585f3b..122fdfa 100644 --- a/github2/client.py +++ b/github2/client.py @@ -1,3 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2009-2012 Ask Solem +# Christopher MacGown +# Evan Broder +# James Rowe +# Jeremy Dunck +# Michael Basnight +# Patryk Zawadzki +# Surajram Kumaravel +# Vincent Driessen +# modocache +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from github2.request import GithubRequest from github2.issues import Issues from github2.repositories import Repositories diff --git a/github2/commits.py b/github2/commits.py index 8910937..f33a9e2 100644 --- a/github2/commits.py +++ b/github2/commits.py @@ -1,3 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2009-2012 Ask Solem +# James Rowe +# Stéphane Angel +# Vincent Driessen +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from github2.core import (BaseData, GithubCommand, Attribute, DateAttribute, repr_string) diff --git a/github2/core.py b/github2/core.py index 856a489..67587f5 100644 --- a/github2/core.py +++ b/github2/core.py @@ -1,3 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2009-2012 Ask Solem +# Fernando Perez +# James Rowe +# Mark Paschal +# Patryk Zawadzki +# Sameer Al-Sakran +# Stéphane Angel +# Vincent Driessen +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + import logging import sys diff --git a/github2/issues.py b/github2/issues.py index 851f813..217a154 100644 --- a/github2/issues.py +++ b/github2/issues.py @@ -1,3 +1,13 @@ +# Copyright (C) 2009-2012 Adam Vandenberg +# Ask Solem +# Barthelemy Dagenais +# Fernando Perez +# James Rowe +# Scott Torborg +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + try: from urllib.parse import quote_plus # For Python 3 except ImportError: diff --git a/github2/organizations.py b/github2/organizations.py index 38eac83..cd99c03 100644 --- a/github2/organizations.py +++ b/github2/organizations.py @@ -1,3 +1,10 @@ +# Copyright (C) 2011-2012 James Rowe +# Patryk Zawadzki +# Rok Garbas +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from github2.core import (BaseData, GithubCommand, Attribute, DateAttribute, requires_auth) from github2.repositories import Repository diff --git a/github2/pull_requests.py b/github2/pull_requests.py index b75d62e..3137002 100644 --- a/github2/pull_requests.py +++ b/github2/pull_requests.py @@ -1,3 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2010-2012 Christopher MacGown +# Ionuț Arțăriși +# James Rowe +# Stéphane Angel +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from github2.core import (BaseData, GithubCommand, Attribute, DateAttribute, repr_string) diff --git a/github2/repositories.py b/github2/repositories.py index 89f8e57..6d206bf 100644 --- a/github2/repositories.py +++ b/github2/repositories.py @@ -1,3 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2009-2012 Ask Solem +# Claudio B. +# Daniel Greenfeld +# James Rowe +# Jens Ohlig +# Jeremy Dunck +# Jonas Obrist +# Kenneth Reitz +# Mark Paschal +# Maximillian Dornseif +# Sameer Al-Sakran +# Stéphane Angel +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from github2.core import (BaseData, GithubCommand, Attribute, DateAttribute, requires_auth) diff --git a/github2/request.py b/github2/request.py index 9aea264..7b400bf 100644 --- a/github2/request.py +++ b/github2/request.py @@ -1,3 +1,24 @@ +# Copyright (C) 2009-2012 Adam Vandenberg +# Asheesh Laroia +# Ask Solem +# Chris Vale +# Daniel Greenfeld +# Evan Broder +# James Rowe +# Jeremy Dunck +# Josh Weinberg +# Mark Paschal +# Maximillian Dornseif +# Michael Basnight +# Patryk Zawadzki +# Rick Harris +# Sameer Al-Sakran +# Vincent Driessen +# modocache +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + import datetime import logging import re diff --git a/github2/teams.py b/github2/teams.py index b46116f..2472cf3 100644 --- a/github2/teams.py +++ b/github2/teams.py @@ -1,3 +1,9 @@ +# Copyright (C) 2011-2012 James Rowe +# Patryk Zawadzki +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from github2.core import BaseData, GithubCommand, Attribute, requires_auth from github2.repositories import Repository from github2.users import User diff --git a/github2/users.py b/github2/users.py index ad40fc1..e2c9c58 100644 --- a/github2/users.py +++ b/github2/users.py @@ -1,3 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2009-2012 Ask Solem +# James Rowe +# Sameer Al-Sakran +# Stéphane Angel +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + try: from urllib.parse import quote_plus # For Python 3 except ImportError: diff --git a/setup.py b/setup.py index 8613f1f..06c56bb 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,15 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +# Copyright (C) 2009-2012 Ask Solem +# Cody Soyland +# Donald von Stufft +# James Rowe +# Maximillian Dornseif +# Michael Basnight +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + import codecs import sys diff --git a/tests/test_charset_header.py b/tests/test_charset_header.py index 40aff70..3b29635 100644 --- a/tests/test_charset_header.py +++ b/tests/test_charset_header.py @@ -1,3 +1,8 @@ +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from nose.tools import assert_equals from github2.request import charset_from_headers diff --git a/tests/test_commits.py b/tests/test_commits.py index 5d4ee8e..20ed487 100644 --- a/tests/test_commits.py +++ b/tests/test_commits.py @@ -1,3 +1,8 @@ +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from datetime import datetime from nose.tools import assert_equals diff --git a/tests/test_date_handling.py b/tests/test_date_handling.py index fabc8d5..855ccae 100644 --- a/tests/test_date_handling.py +++ b/tests/test_date_handling.py @@ -1,4 +1,8 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. from datetime import datetime as dt diff --git a/tests/test_issues.py b/tests/test_issues.py index dfd693e..f82302b 100644 --- a/tests/test_issues.py +++ b/tests/test_issues.py @@ -1,3 +1,8 @@ +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from datetime import datetime from nose.tools import assert_equals diff --git a/tests/test_organizations.py b/tests/test_organizations.py index 9f4e56b..8571e23 100644 --- a/tests/test_organizations.py +++ b/tests/test_organizations.py @@ -1,3 +1,8 @@ +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from datetime import datetime from nose.tools import (assert_equals, assert_true) diff --git a/tests/test_pull_requests.py b/tests/test_pull_requests.py index 50197ce..9c2d35e 100644 --- a/tests/test_pull_requests.py +++ b/tests/test_pull_requests.py @@ -1,3 +1,8 @@ +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from datetime import datetime from nose.tools import assert_equals diff --git a/tests/test_regression.py b/tests/test_regression.py index a2b235c..cad7dc2 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -1,3 +1,8 @@ +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + import httplib2 from nose.tools import assert_equals diff --git a/tests/test_repositories.py b/tests/test_repositories.py index 63f39c0..1cdaab9 100644 --- a/tests/test_repositories.py +++ b/tests/test_repositories.py @@ -1,3 +1,10 @@ +# coding: utf-8 +# Copyright (C) 2011-2012 James Rowe +# Stéphane Angel +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + import datetime from nose.tools import assert_equals diff --git a/tests/test_request.py b/tests/test_request.py index 7c7f93b..0833c00 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -1,3 +1,8 @@ +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + import unittest try: diff --git a/tests/test_teams.py b/tests/test_teams.py index 85689aa..7333edd 100644 --- a/tests/test_teams.py +++ b/tests/test_teams.py @@ -1,3 +1,8 @@ +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + from nose.tools import assert_equals import utils diff --git a/tests/test_tz_aware_date_handling.py b/tests/test_tz_aware_date_handling.py index 5789593..6a501f0 100644 --- a/tests/test_tz_aware_date_handling.py +++ b/tests/test_tz_aware_date_handling.py @@ -1,4 +1,8 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. from datetime import datetime as dt diff --git a/tests/test_unit.py b/tests/test_unit.py index 7cd3113..f17f9a0 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -1,4 +1,11 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2010-2012 Adam Vandenberg +# James Rowe +# Jeremy Dunck +# modocache +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. import datetime import unittest diff --git a/tests/test_user.py b/tests/test_user.py index aff6ad5..33929db 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -1,3 +1,8 @@ +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + import datetime from nose.tools import (assert_equals, assert_false, assert_true) diff --git a/tests/utils.py b/tests/utils.py index 78fb8c4..598b068 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,3 +1,8 @@ +# Copyright (C) 2011-2012 James Rowe +# +# This file is part of python-github2, and is made available under the 3-clause +# BSD license. See LICENSE for the full details. + import os import sys import unittest From cd436188df09605ad35deef5e80caec0cc9ca6f2 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 11:39:18 +0100 Subject: [PATCH 02/32] [QA] Clean up the ignore list. --- .gitignore | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index ea2d6d3..241d83f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,17 @@ -.DS_Store -.coverage -.noseids -.ropeproject/ -.tox/ -*.py[co] -*~ -*.sqlite -*.sqlite-journal -settings_local.py -local_settings.py +*.egg-info/ + .*.sw[po] +*.py[co] + +build/ dist/ -*.egg-info doc/.build/ -build/ -locale/ +.ropeproject/ +.tox/ + +ChangeLog pip-log.txt + +.DS_Store +.coverage +.noseids From f5324acc71fda0792a1e7e54d7d9fb5c5aa1bb7e Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 15:40:41 +0100 Subject: [PATCH 03/32] [QA] Use Git*H*ub for the service name. --- README.rst | 6 +++--- doc/index.rst | 8 ++++---- examples/friend-or-follow.py | 4 ++-- github2/client.py | 8 ++++---- github2/core.py | 6 +++--- github2/issues.py | 16 ++++++++-------- github2/pull_requests.py | 8 ++++---- github2/repositories.py | 24 ++++++++++++------------ github2/request.py | 4 ++-- github2/users.py | 20 ++++++++++---------- 10 files changed, 52 insertions(+), 52 deletions(-) diff --git a/README.rst b/README.rst index 3e6ab34..a266014 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,5 @@ ================================================================================ -github2 - Github API v2 library for Python. +github2 - GitHub API v2 library for Python. ================================================================================ :Authors: @@ -16,7 +16,7 @@ github2 - Github API v2 library for Python. of work needed in moving away from GitHub's API v2. This is a Python library implementing all of the features available in version 2 -of the `Github API`_. +of the `GitHub API`_. See the ``doc/`` directory for installation instructions and usage information. If you prefer you can also read the `documentation online`_. @@ -24,7 +24,7 @@ If you prefer you can also read the `documentation online`_. .. _switch off API v2: https://github.com/blog/1090-github-api-moving-on .. _remoteobjects: https://github.com/saymedia/remoteobjects .. _micromodels: https://github.com/j4mie/micromodels -.. _Github API: http://develop.github.com/ +.. _GitHub API: http://develop.github.com/ .. _documentation online: http://packages.python.org/github2 License diff --git a/doc/index.rst b/doc/index.rst index 55814bf..93438c9 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -10,7 +10,7 @@ .. module:: github2 :synopsis: GitHub API v2 library for Python -``github2`` - Github API v2 library for Python +``github2`` - GitHub API v2 library for Python ============================================== .. warning:: @@ -31,15 +31,15 @@ :class: sidebar This is a Python library implementing all of the features available in version 2 -of the `Github API`_. +of the `GitHub API`_. -You should read the developer documentation for the `Github API`_ first. +You should read the developer documentation for the `GitHub API`_ first. :Git repository: https://github.com/ask/python-github2/ :Issue tracker: https://github.com/ask/python-github2/issues/ :Contributors: https://github.com/ask/python-github2/contributors/ -.. _Github API: http://develop.github.com/ +.. _GitHub API: http://develop.github.com/ Contents -------- diff --git a/examples/friend-or-follow.py b/examples/friend-or-follow.py index ccef96a..55b6b8d 100644 --- a/examples/friend-or-follow.py +++ b/examples/friend-or-follow.py @@ -10,10 +10,10 @@ OPTION_LIST = ( optparse.make_option('-t', '--api-token', default=None, action="store", dest="api_token", type="str", - help="Github API token. Default is to find this from git config"), + help="GitHub API token. Default is to find this from git config"), optparse.make_option('-u', '--api-user', default=None, action="store", dest="api_user", type="str", - help="Github Username. Default is to find this from git config"), + help="GitHub Username. Default is to find this from git config"), ) BY_LOWER = lambda value: value.lower() diff --git a/github2/client.py b/github2/client.py index c585f3b..a141879 100644 --- a/github2/client.py +++ b/github2/client.py @@ -59,7 +59,7 @@ def __init__(self, username=None, api_token=None, requests_per_second=None, self.pull_requests = PullRequests(self.request) def project_for_user_repo(self, user, repo): - """Return Github identifier for a user's repository + """Return GitHub identifier for a user's repository :param str user: repository owner :param str repo: repository name @@ -97,7 +97,7 @@ def get_tree(self, project, tree_sha): return tree.get("tree", []) def get_network_meta(self, project): - """Get Github metadata associated with a project + """Get GitHub metadata associated with a project :param str project: GitHub project """ @@ -106,10 +106,10 @@ def get_network_meta(self, project): "network_meta"]), {}) def get_network_data(self, project, nethash, start=None, end=None): - """Get chunk of Github network data + """Get chunk of GitHub network data :param str project: GitHub project - :param str nethash: identifier provided by ``get_network_meta`` + :param str nethash: identifier provided by :meth:`get_network_meta` :param int start: optional start point for data :param int stop: optional end point for data """ diff --git a/github2/core.py b/github2/core.py index 856a489..a83dd6d 100644 --- a/github2/core.py +++ b/github2/core.py @@ -59,7 +59,7 @@ def wrapper(datetime_): @_handle_naive_datetimes def datetime_to_ghdate(datetime_): - """Convert Python datetime to Github date string + """Convert Python datetime to GitHub date string :param datetime datetime_: datetime object to convert """ @@ -68,7 +68,7 @@ def datetime_to_ghdate(datetime_): @_handle_naive_datetimes def datetime_to_commitdate(datetime_): - """Convert Python datetime to Github date string + """Convert Python datetime to GitHub date string :param datetime datetime_: datetime object to convert """ @@ -80,7 +80,7 @@ def datetime_to_commitdate(datetime_): def datetime_to_isodate(datetime_): - """Convert Python datetime to Github date string + """Convert Python datetime to GitHub date string :param str datetime_: datetime object to convert diff --git a/github2/issues.py b/github2/issues.py index 851f813..ae6ef48 100644 --- a/github2/issues.py +++ b/github2/issues.py @@ -86,7 +86,7 @@ def show(self, project, number): """Get all the data for issue by issue-number. :param str project: GitHub project - :param int number: issue number in the Github database + :param int number: issue number in the GitHub database """ return self.get_value("show", project, str(number), filter="issue", datatype=Issue) @@ -108,7 +108,7 @@ def close(self, project, number): """Close an issue :param str project: GitHub project - :param int number: issue number in the Github database + :param int number: issue number in the GitHub database """ return self.get_value("close", project, str(number), filter="issue", datatype=Issue, method="POST") @@ -120,7 +120,7 @@ def reopen(self, project, number): .. versionadded:: 0.3.0 :param str project: GitHub project - :param int number: issue number in the Github database + :param int number: issue number in the GitHub database """ return self.get_value("reopen", project, str(number), filter="issue", datatype=Issue, method="POST") @@ -132,7 +132,7 @@ def edit(self, project, number, title, body): .. versionadded:: 0.3.0 :param str project: GitHub project - :param int number: issue number in the Github database + :param int number: issue number in the GitHub database :param str title: title for issue :param str body: body for issue """ @@ -146,7 +146,7 @@ def add_label(self, project, number, label): """Add a label to an issue :param str project: GitHub project - :param int number: issue number in the Github database + :param int number: issue number in the GitHub database :param str label: label to attach to issue """ return self.get_values("label/add", project, label, str(number), @@ -157,7 +157,7 @@ def remove_label(self, project, number, label): """Remove an existing label from an issue :param str project: GitHub project - :param int number: issue number in the Github database + :param int number: issue number in the GitHub database :param str label: label to remove from issue """ return self.get_values("label/remove", project, label, str(number), @@ -168,7 +168,7 @@ def comment(self, project, number, comment): """Comment on an issue. :param str project: GitHub project - :param int number: issue number in the Github database + :param int number: issue number in the GitHub database :param str comment: comment to attach to issue """ comment_data = {'comment': comment} @@ -180,7 +180,7 @@ def comments(self, project, number): """View comments on an issue. :param str project: GitHub project - :param int number: issue number in the Github database + :param int number: issue number in the GitHub database """ return self.get_values("comments", project, str(number), filter="comments", datatype=Comment) diff --git a/github2/pull_requests.py b/github2/pull_requests.py index b75d62e..fa13b48 100644 --- a/github2/pull_requests.py +++ b/github2/pull_requests.py @@ -53,7 +53,7 @@ def create(self, project, base, head, title=None, body=None, issue=None): issue. If an ``issue`` parameter is supplied the pull request is attached to that issue, else a new pull request is created. - :param str project: the Github project to send the pull request to + :param str project: the GitHub project to send the pull request to :param str base: branch changes should be pulled into :param str head: branch of the changes to be pulled :param str title: title for pull request @@ -78,8 +78,8 @@ def create(self, project, base, head, title=None, body=None, issue=None): def show(self, project, number): """Show a single pull request - :param str project: Github project - :param int number: pull request number in the Github database + :param str project: GitHub project + :param int number: pull request number in the GitHub database """ return self.get_value(project, str(number), filter="pull", datatype=PullRequest) @@ -87,7 +87,7 @@ def show(self, project, number): def list(self, project, state="open", page=1): """List all pull requests for a project - :param str project: Github project + :param str project: GitHub project :param str state: can be either ``open`` or ``closed`` :param int page: optional page number """ diff --git a/github2/repositories.py b/github2/repositories.py index 89f8e57..501ffbb 100644 --- a/github2/repositories.py +++ b/github2/repositories.py @@ -73,7 +73,7 @@ def list(self, user=None, page=1): logged-in user when ``user`` wasn't supplied. This functionality is brittle and will be removed in a future release! - :param str user: Github user name to list repositories for + :param str user: GitHub user name to list repositories for :param int page: optional page number """ user = user or self.request.username @@ -160,8 +160,8 @@ def list_collaborators(self, project): def add_collaborator(self, project, username): """Adds an add_collaborator to a repo - :param str project: Github project - :param str username: Github user to add as collaborator + :param str project: GitHub project + :param str username: GitHub user to add as collaborator """ return self.make_request("collaborators", project, "add", username, method="POST") @@ -170,8 +170,8 @@ def add_collaborator(self, project, username): def remove_collaborator(self, project, username): """Removes an add_collaborator from a repo - :param str project: Github project - :param str username: Github user to add as collaborator + :param str project: GitHub project + :param str username: GitHub user to add as collaborator """ return self.make_request("collaborators", project, "remove", username, method="POST") @@ -179,7 +179,7 @@ def remove_collaborator(self, project, username): def network(self, project): """Get network data for project - :param str project: Github project + :param str project: GitHub project """ return self.get_values("show", project, "network", filter="network", datatype=Repository) @@ -187,7 +187,7 @@ def network(self, project): def languages(self, project): """Get programming language data for project - :param str project: Github project + :param str project: GitHub project """ return self.get_values("show", project, "languages", filter="languages") @@ -195,28 +195,28 @@ def languages(self, project): def tags(self, project): """Get tags for project - :param str project: Github project + :param str project: GitHub project """ return self.get_values("show", project, "tags", filter="tags") def branches(self, project): """Get branch names for project - :param str project: Github project + :param str project: GitHub project """ return self.get_values("show", project, "branches", filter="branches") def watchers(self, project): """Get list of watchers for project - :param str project: Github project + :param str project: GitHub project """ return self.get_values("show", project, "watchers", filter="watchers") def watching(self, for_user=None, page=None): """Lists all the repos a user is watching - :param str for_user: optional Github user name to list repositories for + :param str for_user: optional GitHub user name to list repositories for :param int page: optional page number """ for_user = for_user or self.request.username @@ -226,7 +226,7 @@ def watching(self, for_user=None, page=None): def list_contributors(self, project): """Lists all the contributors in a project - :param str project: Github project + :param str project: GitHub project """ return self.get_values("show", project, "contributors", filter="contributors", datatype=User) diff --git a/github2/request.py b/github2/request.py index 9aea264..c05ea97 100644 --- a/github2/request.py +++ b/github2/request.py @@ -81,11 +81,11 @@ def charset_from_headers(headers): class GithubError(Exception): - """An error occurred when making a request to the Github API.""" + """An error occurred when making a request to the GitHub API.""" class HttpError(RuntimeError): - """A HTTP error occured when making a request to the Github API.""" + """A HTTP error occured when making a request to the GitHub API.""" def __init__(self, message, content, code): """Create a HttpError exception diff --git a/github2/users.py b/github2/users.py index ad40fc1..d6fd9ac 100644 --- a/github2/users.py +++ b/github2/users.py @@ -73,42 +73,42 @@ def search_by_email(self, query): @enhanced_by_auth def show(self, username): - """Get information on Github user + """Get information on GitHub user if ``username`` is ``None`` or an empty string information for the currently authenticated user is returned. - :param str username: Github user name + :param str username: GitHub user name """ return self.get_value("show", username, filter="user", datatype=User) def followers(self, username): - """Get list of Github user's followers + """Get list of GitHub user's followers - :param str username: Github user name + :param str username: GitHub user name """ return self.get_values("show", username, "followers", filter="users") def following(self, username): - """Get list of users a Github user is following + """Get list of users a GitHub user is following - :param str username: Github user name + :param str username: GitHub user name """ return self.get_values("show", username, "following", filter="users") @requires_auth def follow(self, other_user): - """Follow a Github user + """Follow a GitHub user - :param str other_user: Github user name + :param str other_user: GitHub user name """ return self.get_values("follow", other_user, method="POST") @requires_auth def unfollow(self, other_user): - """Unfollow a Github user + """Unfollow a GitHub user - :param str other_user: Github user name + :param str other_user: GitHub user name """ return self.get_values("unfollow", other_user, method="POST") From 71f17c902f8a90d2aaffa06c9e40cd521941716e Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 15:41:05 +0100 Subject: [PATCH 04/32] [QA] Function notes come before param docs. --- github2/core.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/github2/core.py b/github2/core.py index a83dd6d..3aed7c1 100644 --- a/github2/core.py +++ b/github2/core.py @@ -82,9 +82,10 @@ def datetime_to_commitdate(datetime_): def datetime_to_isodate(datetime_): """Convert Python datetime to GitHub date string + .. note:: Supports naive and timezone-aware datetimes + :param str datetime_: datetime object to convert - .. note:: Supports naive and timezone-aware datetimes """ if not datetime_.tzinfo: datetime_ = datetime_.replace(tzinfo=tz.tzutc()) From 6dcda6be8047f1672ed598a141ef4e7ac7d3711e Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 15:41:23 +0100 Subject: [PATCH 05/32] Fixed broken deprecated Sphinx directive. --- github2/repositories.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github2/repositories.py b/github2/repositories.py index 501ffbb..2d52fed 100644 --- a/github2/repositories.py +++ b/github2/repositories.py @@ -68,7 +68,7 @@ def pushable(self): def list(self, user=None, page=1): """Return a list of all repositories for a user. - .. deprecated: 0.4.0 + .. deprecated:: 0.4.0 Previous releases would attempt to display repositories for the logged-in user when ``user`` wasn't supplied. This functionality is brittle and will be removed in a future release! From 3a820369c94e9c521a7221cd12efca50abaa6ba1 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 15:47:16 +0100 Subject: [PATCH 06/32] [QA] Minor grammar fix in contributing doc. More fixes always welcome. --- doc/contributing.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/contributing.rst b/doc/contributing.rst index 8c3b47a..7c71bb2 100644 --- a/doc/contributing.rst +++ b/doc/contributing.rst @@ -4,9 +4,9 @@ Contributing Patches for :mod:`github2` are most welcome! Forks on GitHub_ and patches attached to issues are both great ways to -contribute. If you're comfortable with ``git`` using a fork hosted on GitHub is -probably the simpler solution, both for the package maintainers and you as a -contributor. +contribute. If you're comfortable with ``git`` then using a fork hosted on +GitHub is probably the simpler solution, both for the :mod:`github2` maintainers +and for you as a contributor. Following the simple guidelines below makes it easier to review and integrate your changes: From ec36b5772085c908d600f2171d622bfd690d7a2d Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 15:23:44 +0100 Subject: [PATCH 07/32] [QA] Follow PEP 257 whitespace rules. --- github2/bin/manage_collaborators.py | 4 ++- github2/bin/search_repos.py | 4 ++- github2/client.py | 10 +++++-- github2/commits.py | 2 ++ github2/core.py | 21 ++++++++++++++- github2/issues.py | 20 +++++++++++--- github2/organizations.py | 6 +++++ github2/pull_requests.py | 11 ++++++-- github2/repositories.py | 41 ++++++++++++++++++++++------- github2/request.py | 9 +++++-- github2/teams.py | 10 +++++++ github2/users.py | 22 +++++++++++----- 12 files changed, 131 insertions(+), 29 deletions(-) diff --git a/github2/bin/manage_collaborators.py b/github2/bin/manage_collaborators.py index 3efafee..5e585d2 100755 --- a/github2/bin/manage_collaborators.py +++ b/github2/bin/manage_collaborators.py @@ -26,7 +26,9 @@ def print_(text): """Python 2 & 3 compatible print function - We support <2.6, so can't use __future__.print_function""" + We support <2.6, so can't use __future__.print_function + + """ if PY3K: print(text) else: diff --git a/github2/bin/search_repos.py b/github2/bin/search_repos.py index c52be46..737caa2 100755 --- a/github2/bin/search_repos.py +++ b/github2/bin/search_repos.py @@ -19,7 +19,9 @@ def print_(text): """Python 2 & 3 compatible print function - We support <2.6, so can't use __future__.print_function""" + We support <2.6, so can't use __future__.print_function + + """ if PY3K: print(text) else: diff --git a/github2/client.py b/github2/client.py index a141879..7b3d8eb 100644 --- a/github2/client.py +++ b/github2/client.py @@ -13,8 +13,7 @@ class Github(object): def __init__(self, username=None, api_token=None, requests_per_second=None, access_token=None, cache=None, proxy_host=None, proxy_port=8080, github_url=None): - """ - An interface to GitHub's API: + """An interface to GitHub's API: http://develop.github.com/ .. versionadded:: 0.2.0 @@ -42,6 +41,7 @@ def __init__(self, username=None, api_token=None, requests_per_second=None, default to 8080 if a proxy_host is set and no port is set). :param str github_url: the hostname to connect to, for GitHub Enterprise support + """ self.request = GithubRequest(username=username, api_token=api_token, @@ -63,6 +63,7 @@ def project_for_user_repo(self, user, repo): :param str user: repository owner :param str repo: repository name + """ return "/".join([user, repo]) @@ -73,6 +74,7 @@ def get_all_blobs(self, project, tree_sha): :param str project: GitHub project :param str tree_sha: object ID of tree + """ blobs = self.request.get("blob/all", project, tree_sha) return blobs.get("blobs") @@ -83,6 +85,7 @@ def get_blob_info(self, project, tree_sha, path): :param str project: GitHub project :param str tree_sha: object ID of tree :param str path: path within tree to fetch blob for + """ blob = self.request.get("blob/show", project, tree_sha, path) return blob.get("blob") @@ -92,6 +95,7 @@ def get_tree(self, project, tree_sha): :param str project: GitHub project :param str tree_sha: object ID of tree + """ tree = self.request.get("tree/show", project, tree_sha) return tree.get("tree", []) @@ -100,6 +104,7 @@ def get_network_meta(self, project): """Get GitHub metadata associated with a project :param str project: GitHub project + """ return self.request.raw_request("/".join([self.request.github_url, project, @@ -112,6 +117,7 @@ def get_network_data(self, project, nethash, start=None, end=None): :param str nethash: identifier provided by :meth:`get_network_meta` :param int start: optional start point for data :param int stop: optional end point for data + """ data = {"nethash": nethash} if start: diff --git a/github2/commits.py b/github2/commits.py index 8910937..7030a40 100644 --- a/github2/commits.py +++ b/github2/commits.py @@ -39,6 +39,7 @@ def list(self, project, branch="master", file=None, page=1): :param str branch: branch name, or ``master`` if not given :param str file: optional file filter :param int page: optional page number + """ return self.get_values("list", project, branch, file, filter="commits", datatype=Commit, page=page) @@ -48,6 +49,7 @@ def show(self, project, sha): :param str project: project name :param str sha: commit id + """ return self.get_value("show", project, sha, filter="commit", datatype=Commit) diff --git a/github2/core.py b/github2/core.py index 3aed7c1..e783456 100644 --- a/github2/core.py +++ b/github2/core.py @@ -30,6 +30,7 @@ def string_to_datetime(string): """Convert a string to Python datetime :param str github_date: date string to parse + """ parsed = parser.parse(string) if NAIVE: @@ -41,6 +42,7 @@ def _handle_naive_datetimes(f): """Decorator to make datetime arguments use GitHub timezone :param func f: Function to wrap + """ def wrapper(datetime_): if not datetime_.tzinfo: @@ -62,6 +64,7 @@ def datetime_to_ghdate(datetime_): """Convert Python datetime to GitHub date string :param datetime datetime_: datetime object to convert + """ return datetime_.strftime(GITHUB_DATE_FORMAT) @@ -71,6 +74,7 @@ def datetime_to_commitdate(datetime_): """Convert Python datetime to GitHub date string :param datetime datetime_: datetime object to convert + """ date_without_tz = datetime_.strftime(COMMIT_DATE_FORMAT) utcoffset = GITHUB_TZ.utcoffset(datetime_) @@ -95,7 +99,8 @@ def datetime_to_isodate(datetime_): class AuthError(Exception): - """Requires authentication""" + + """Requires authentication.""" def requires_auth(f): @@ -105,6 +110,7 @@ def requires_auth(f): :param func f: Function to wrap :raises AuthError: If function called without an authenticated session + """ # When Python 2.4 support is dropped move straight to functools.wraps, # don't pass go and don't collect $200. @@ -129,6 +135,7 @@ def enhanced_by_auth(f): introspection. :param func f: Function to wrap + """ f.enhanced_by_auth = True f.__doc__ += """\n.. note:: This call is enhanced with authentication""" @@ -141,6 +148,7 @@ def __init__(self, request): """Main API binding interface :param github2.request.GithubRequest request: HTTP request handler + """ self.request = request @@ -155,6 +163,7 @@ def make_request(self, command, *args, **kwargs): data * The value of a ``page`` argument will be used to fetch a specific page of results, default of 1 is assumed if not given + """ filter = kwargs.get("filter") post_data = kwargs.get("post_data") or {} @@ -182,6 +191,7 @@ def get_value(self, *args, **kwargs): If a ``datatype`` parameter is given it defines the :class:`BaseData`-derived class we should build from the provided data + """ datatype = kwargs.pop("datatype", None) value = self.make_request(*args, **kwargs) @@ -200,6 +210,7 @@ def get_values(self, *args, **kwargs): """Process a multi-value response from the API :see: :meth:`get_value` + """ datatype = kwargs.pop("datatype", None) values = self.make_request(*args, **kwargs) @@ -221,6 +232,7 @@ def doc_generator(docstring, attributes): :param str docstring: docstring to augment :param dict attributes: attributes to add to docstring + """ docstring = docstring or "" @@ -237,6 +249,7 @@ def __init__(self, help): """Generic object attribute for use with :class:`BaseData` :param str help: Attribute description + """ self.help = help @@ -260,6 +273,7 @@ def __init__(self, *args, **kwargs): :param str format: The date format to support, see :data:`convertor_for_format` for supported options + """ self.format = kwargs.pop("format", self.format) super(DateAttribute, self).__init__(*args, **kwargs) @@ -318,12 +332,15 @@ class BaseData(BaseDataType('BaseData', (object, ), {})): .. warning:: Supports subscript attribute access purely for backwards compatibility, you shouldn't rely on that functionality in new code + """ + def __getitem__(self, key): """Access objects's attribute using subscript notation This is here purely to maintain compatibility when switching ``dict`` responses to ``BaseData`` derived objects. + """ LOGGER.warning("Subscript access on %r is deprecated, use object " "attributes" % self.__class__.__name__, @@ -336,6 +353,7 @@ def __setitem__(self, key, value): """Update object's attribute using subscript notation :see: :meth:`BaseData.__getitem__` + """ LOGGER.warning("Subscript access on %r is deprecated, use object " "attributes" % self.__class__.__name__, @@ -350,6 +368,7 @@ def repr_string(string): :param str string: string to operate on :return: string, with maximum length of 20 characters + """ if len(string) > 20: string = string[:17] + '...' diff --git a/github2/issues.py b/github2/issues.py index ae6ef48..ad7aa35 100644 --- a/github2/issues.py +++ b/github2/issues.py @@ -49,6 +49,7 @@ def search(self, project, term, state="open"): :param str project: GitHub project :param str term: term to search issues for :param str state: can be either ``open`` or ``closed``. + """ return self.get_values("search", project, state, quote_plus(term), filter="issues", datatype=Issue) @@ -58,6 +59,7 @@ def list(self, project, state="open"): :param str project: GitHub project :param str state: can be either ``open`` or ``closed``. + """ return self.get_values("list", project, state, filter="issues", datatype=Issue) @@ -69,6 +71,7 @@ def list_by_label(self, project, label): :param str project: GitHub project :param str label: a string representing a label (e.g., ``bug``). + """ return self.get_values("list", project, "label", label, filter="issues", datatype=Issue) @@ -79,6 +82,7 @@ def list_labels(self, project): .. versionadded:: 0.3.0 :param str project: GitHub project + """ return self.get_values("labels", project, filter="labels") @@ -86,7 +90,8 @@ def show(self, project, number): """Get all the data for issue by issue-number. :param str project: GitHub project - :param int number: issue number in the GitHub database + :param int number: issue number in the Github database + """ return self.get_value("show", project, str(number), filter="issue", datatype=Issue) @@ -98,6 +103,7 @@ def open(self, project, title, body): :param str project: GitHub project :param str title: title for issue :param str body: body for issue + """ issue_data = {"title": title, "body": body} return self.get_value("open", project, post_data=issue_data, @@ -108,7 +114,8 @@ def close(self, project, number): """Close an issue :param str project: GitHub project - :param int number: issue number in the GitHub database + :param int number: issue number in the Github database + """ return self.get_value("close", project, str(number), filter="issue", datatype=Issue, method="POST") @@ -120,7 +127,8 @@ def reopen(self, project, number): .. versionadded:: 0.3.0 :param str project: GitHub project - :param int number: issue number in the GitHub database + :param int number: issue number in the Github database + """ return self.get_value("reopen", project, str(number), filter="issue", datatype=Issue, method="POST") @@ -135,6 +143,7 @@ def edit(self, project, number, title, body): :param int number: issue number in the GitHub database :param str title: title for issue :param str body: body for issue + """ issue_data = {"title": title, "body": body} return self.get_value("edit", project, str(number), @@ -148,6 +157,7 @@ def add_label(self, project, number, label): :param str project: GitHub project :param int number: issue number in the GitHub database :param str label: label to attach to issue + """ return self.get_values("label/add", project, label, str(number), filter="labels", method="POST") @@ -159,6 +169,7 @@ def remove_label(self, project, number, label): :param str project: GitHub project :param int number: issue number in the GitHub database :param str label: label to remove from issue + """ return self.get_values("label/remove", project, label, str(number), filter="labels", method="POST") @@ -170,6 +181,7 @@ def comment(self, project, number, comment): :param str project: GitHub project :param int number: issue number in the GitHub database :param str comment: comment to attach to issue + """ comment_data = {'comment': comment} return self.get_value("comment", project, str(number), @@ -180,7 +192,7 @@ def comments(self, project, number): """View comments on an issue. :param str project: GitHub project - :param int number: issue number in the GitHub database + """ return self.get_values("comments", project, str(number), filter="comments", datatype=Comment) diff --git a/github2/organizations.py b/github2/organizations.py index 38eac83..8baa328 100644 --- a/github2/organizations.py +++ b/github2/organizations.py @@ -42,6 +42,7 @@ def show(self, organization): """Get information on organization :param str organization: organization to show + """ return self.get_value(organization, filter="organization", datatype=Organization) @@ -58,6 +59,7 @@ def repositories(self, organization=''): repositories for all organizations the authenticated user belongs to. :param: str organization: organization to list repositories for + """ return self.get_values(organization, 'repositories', filter="repositories", datatype=Repository) @@ -66,6 +68,7 @@ def public_repositories(self, organization): """Get list of public repositories in an organization :param str organization: organization to list public repositories for + """ return self.get_values(organization, 'public_repositories', filter="repositories", datatype=Repository) @@ -74,6 +77,7 @@ def public_members(self, organization): """Get list of public members in an organization :param str organization: organization to list members for + """ return self.get_values(organization, 'public_members', filter="users", datatype=User) @@ -82,6 +86,7 @@ def teams(self, organization): """Get list of teams in an organization :param str organization: organization to list teams for + """ return self.get_values(organization, 'teams', filter="teams", datatype=Team) @@ -94,6 +99,7 @@ def add_team(self, organization, name, permission='pull', projects=None): :param str team: name of team to add :param str permission: permissions for team(push, pull or admin) :param list projects: optional GitHub projects for this team + """ team_data = {'team[name]': name, 'team[permission]': permission} if projects: diff --git a/github2/pull_requests.py b/github2/pull_requests.py index fa13b48..9a0ba58 100644 --- a/github2/pull_requests.py +++ b/github2/pull_requests.py @@ -6,7 +6,9 @@ class PullRequest(BaseData): """Pull request encapsulation .. versionadded:: 0.5.0 + """ + state = Attribute("The pull request state") base = Attribute("The base repo") head = Attribute("The head of the pull request") @@ -43,7 +45,9 @@ class PullRequests(GithubCommand): """Operations on pull requests .. versionadded:: 0.5.0 + """ + domain = "pulls" def create(self, project, base, head, title=None, body=None, issue=None): @@ -59,6 +63,7 @@ def create(self, project, base, head, title=None, body=None, issue=None): :param str title: title for pull request :param str body: optional body for pull request :param str issue: existing issue to attach pull request to + """ post_data = {"base": base, "head": head} if issue: @@ -78,8 +83,9 @@ def create(self, project, base, head, title=None, body=None, issue=None): def show(self, project, number): """Show a single pull request - :param str project: GitHub project - :param int number: pull request number in the GitHub database + :param str project: Github project + :param int number: pull request number in the Github database + """ return self.get_value(project, str(number), filter="pull", datatype=PullRequest) @@ -90,6 +96,7 @@ def list(self, project, state="open", page=1): :param str project: GitHub project :param str state: can be either ``open`` or ``closed`` :param int page: optional page number + """ return self.get_values(project, state, filter="pulls", datatype=PullRequest, page=page) diff --git a/github2/repositories.py b/github2/repositories.py index 2d52fed..4f9b0cf 100644 --- a/github2/repositories.py +++ b/github2/repositories.py @@ -44,6 +44,7 @@ def search(self, query): Returns at most 100 repositories :param str query: term to search issues for + """ return self.get_values("search", query, filter="repositories", datatype=Repository) @@ -52,6 +53,7 @@ def show(self, project): """Get repository object for project. :param str project: GitHub project + """ return self.get_value("show", project, filter="repository", datatype=Repository) @@ -61,6 +63,7 @@ def pushable(self): """Return a list of repos you can push to that are not your own. .. versionadded:: 0.3.0 + """ return self.get_values("pushable", filter="repositories", datatype=Repository) @@ -75,6 +78,7 @@ def list(self, user=None, page=1): :param str user: GitHub user name to list repositories for :param int page: optional page number + """ user = user or self.request.username return self.get_values("show", user, filter="repositories", @@ -85,6 +89,7 @@ def watch(self, project): """Watch a project :param str project: GitHub project + """ return self.get_value("watch", project, filter='repository', datatype=Repository) @@ -94,6 +99,7 @@ def unwatch(self, project): """Unwatch a project :param str project: GitHub project + """ return self.get_value("unwatch", project, filter='repository', datatype=Repository) @@ -103,6 +109,7 @@ def fork(self, project): """Fork a project :param str project: GitHub project + """ return self.get_value("fork", project, filter="repository", datatype=Repository) @@ -115,6 +122,7 @@ def create(self, project, description=None, homepage=None, public=True): :param str description: optional project description :param str homepage: optional project homepage :param bool public: whether to make a public project + """ repo_data = {"name": project, "description": description, "homepage": homepage, "public": str(int(public))} @@ -126,6 +134,7 @@ def delete(self, project): """Delete a repository :param str project: project name to delete + """ # Two-step delete mechanism. We must echo the delete_token value back # to GitHub to actually delete a repository @@ -137,6 +146,7 @@ def set_private(self, project): """Mark repository as private :param str project: project name to set as private + """ return self.make_request("set/private", project) @@ -145,6 +155,7 @@ def set_public(self, project): """Mark repository as public :param str project: project name to set as public + """ return self.make_request("set/public", project) @@ -152,6 +163,7 @@ def list_collaborators(self, project): """Lists all the collaborators in a project :param str project: GitHub project + """ return self.get_values("show", project, "collaborators", filter="collaborators") @@ -160,8 +172,9 @@ def list_collaborators(self, project): def add_collaborator(self, project, username): """Adds an add_collaborator to a repo - :param str project: GitHub project - :param str username: GitHub user to add as collaborator + :param str project: Github project + :param str username: Github user to add as collaborator + """ return self.make_request("collaborators", project, "add", username, method="POST") @@ -170,8 +183,9 @@ def add_collaborator(self, project, username): def remove_collaborator(self, project, username): """Removes an add_collaborator from a repo - :param str project: GitHub project - :param str username: GitHub user to add as collaborator + :param str project: Github project + :param str username: Github user to add as collaborator + """ return self.make_request("collaborators", project, "remove", username, method="POST") @@ -179,7 +193,8 @@ def remove_collaborator(self, project, username): def network(self, project): """Get network data for project - :param str project: GitHub project + :param str project: Github project + """ return self.get_values("show", project, "network", filter="network", datatype=Repository) @@ -187,7 +202,8 @@ def network(self, project): def languages(self, project): """Get programming language data for project - :param str project: GitHub project + :param str project: Github project + """ return self.get_values("show", project, "languages", filter="languages") @@ -195,21 +211,24 @@ def languages(self, project): def tags(self, project): """Get tags for project - :param str project: GitHub project + :param str project: Github project + """ return self.get_values("show", project, "tags", filter="tags") def branches(self, project): """Get branch names for project - :param str project: GitHub project + :param str project: Github project + """ return self.get_values("show", project, "branches", filter="branches") def watchers(self, project): """Get list of watchers for project - :param str project: GitHub project + :param str project: Github project + """ return self.get_values("show", project, "watchers", filter="watchers") @@ -218,6 +237,7 @@ def watching(self, for_user=None, page=None): :param str for_user: optional GitHub user name to list repositories for :param int page: optional page number + """ for_user = for_user or self.request.username return self.get_values("watched", for_user, filter="repositories", @@ -226,7 +246,8 @@ def watching(self, for_user=None, page=None): def list_contributors(self, project): """Lists all the contributors in a project - :param str project: GitHub project + :param str project: Github project + """ return self.get_values("show", project, "contributors", filter="contributors", datatype=User) diff --git a/github2/request.py b/github2/request.py index c05ea97..12a9363 100644 --- a/github2/request.py +++ b/github2/request.py @@ -71,6 +71,7 @@ def charset_from_headers(headers): :param httplib2.Response headers: Request headers :return: Defined encoding, or default to ASCII + """ match = re.search("charset=([^ ;]+)", headers.get('content-type', "")) if match: @@ -81,17 +82,21 @@ def charset_from_headers(headers): class GithubError(Exception): - """An error occurred when making a request to the GitHub API.""" + + """An error occurred when making a request to the Github API.""" class HttpError(RuntimeError): - """A HTTP error occured when making a request to the GitHub API.""" + + """A HTTP error occured when making a request to the Github API.""" + def __init__(self, message, content, code): """Create a HttpError exception :param str message: Exception string :param str content: Full content of HTTP request :param int code: HTTP status code + """ self.args = (message, content, code) self.message = message diff --git a/github2/teams.py b/github2/teams.py index b46116f..c2c7945 100644 --- a/github2/teams.py +++ b/github2/teams.py @@ -4,7 +4,9 @@ class Team(BaseData): + """.. versionadded:: 0.4.0""" + id = Attribute("The team id") name = Attribute("Name of the team") permission = Attribute("Permissions of the team") @@ -14,13 +16,16 @@ def __repr__(self): class Teams(GithubCommand): + """.. versionadded:: 0.4.0""" + domain = "teams" def show(self, team_id): """Get information on team_id :param int team_id: team to get information for + """ return self.get_value(str(team_id), filter="team", datatype=Team) @@ -28,6 +33,7 @@ def members(self, team_id): """Get list of all team members :param int team_id: team to get information for + """ return self.get_values(str(team_id), "members", filter="users", datatype=User) @@ -38,6 +44,7 @@ def add_member(self, team_id, username): :param int team_id: team to add new member to :param str username: GitHub username to add to team + """ return self.get_values(str(team_id), 'members', method='POST', post_data={'name': username}, filter='users', @@ -47,6 +54,7 @@ def repositories(self, team_id): """Get list of all team repositories :param int team_id: team to get information for + """ return self.get_values(str(team_id), "repositories", filter="repositories", datatype=Repository) @@ -57,6 +65,7 @@ def add_project(self, team_id, project): :param int team_id: team to add repository to :param str project: GitHub project + """ if isinstance(project, Repository): project = project.project @@ -70,6 +79,7 @@ def remove_project(self, team_id, project): :param int team_id: team to remove project from :param str project: GitHub project + """ if isinstance(project, Repository): project = project.project diff --git a/github2/users.py b/github2/users.py index d6fd9ac..50b761e 100644 --- a/github2/users.py +++ b/github2/users.py @@ -43,7 +43,9 @@ class User(BaseData): def is_authenticated(self): """Test for user authentication - :return bool: ``True`` if user is authenticated""" + :return bool: ``True`` if user is authenticated + + """ return self.plan is not None def __repr__(self): @@ -60,6 +62,7 @@ def search(self, query): Returns at most 100 users :param str query: term to search for + """ return self.get_values("search", quote_plus(query), filter="users", datatype=User) @@ -68,6 +71,7 @@ def search_by_email(self, query): """Search for users by email address :param str query: email to search for + """ return self.get_value("email", query, filter="user", datatype=User) @@ -78,21 +82,23 @@ def show(self, username): if ``username`` is ``None`` or an empty string information for the currently authenticated user is returned. - :param str username: GitHub user name + """ return self.get_value("show", username, filter="user", datatype=User) def followers(self, username): """Get list of GitHub user's followers - :param str username: GitHub user name + :param str username: Github user name + """ return self.get_values("show", username, "followers", filter="users") def following(self, username): """Get list of users a GitHub user is following - :param str username: GitHub user name + :param str username: Github user name + """ return self.get_values("show", username, "following", filter="users") @@ -100,7 +106,8 @@ def following(self, username): def follow(self, other_user): """Follow a GitHub user - :param str other_user: GitHub user name + :param str other_user: Github user name + """ return self.get_values("follow", other_user, method="POST") @@ -108,7 +115,8 @@ def follow(self, other_user): def unfollow(self, other_user): """Unfollow a GitHub user - :param str other_user: GitHub user name + :param str other_user: Github user name + """ return self.get_values("unfollow", other_user, method="POST") @@ -123,6 +131,7 @@ def add_key(self, key, title=''): :param str key: SSH key identifier :param str title: Optional title for the SSH key + """ return self.get_values("key/add", post_data={'key': key, 'title': title}, @@ -134,6 +143,7 @@ def remove_key(self, key_id): """Remove a SSH key for the authenticated user :param int key_id: SSH key's GitHub identifier + """ return self.get_values('key/remove', post_data={'id': str(key_id)}, filter='public_keys', datatype=Key) From d4441b921c83437bd65cf62df6170224dc6e6fee Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 15:28:50 +0100 Subject: [PATCH 08/32] [QA] Use PEP 257 punctuation guidelines. --- github2/bin/manage_collaborators.py | 6 ++--- github2/bin/search_repos.py | 6 ++--- github2/client.py | 12 ++++----- github2/commits.py | 4 +-- github2/core.py | 40 ++++++++++++++--------------- github2/issues.py | 16 ++++++------ github2/organizations.py | 14 +++++----- github2/pull_requests.py | 10 ++++---- github2/repositories.py | 34 ++++++++++++------------ github2/request.py | 4 +-- github2/teams.py | 12 ++++----- github2/users.py | 22 ++++++++-------- 12 files changed, 90 insertions(+), 90 deletions(-) diff --git a/github2/bin/manage_collaborators.py b/github2/bin/manage_collaborators.py index 5e585d2..79da700 100755 --- a/github2/bin/manage_collaborators.py +++ b/github2/bin/manage_collaborators.py @@ -24,7 +24,7 @@ def print_(text): - """Python 2 & 3 compatible print function + """Python 2 & 3 compatible print function. We support <2.6, so can't use __future__.print_function @@ -36,7 +36,7 @@ def print_(text): def parse_commandline(): - """Parse the comandline and return parsed options.""" + """Parse the command line and return parsed options.""" parser = OptionParser() parser.description = __doc__ @@ -75,7 +75,7 @@ def parse_commandline(): def main(): - """This implements the actual program functionality""" + """Implement the actual program functionality.""" options, args = parse_commandline() diff --git a/github2/bin/search_repos.py b/github2/bin/search_repos.py index 737caa2..895d874 100755 --- a/github2/bin/search_repos.py +++ b/github2/bin/search_repos.py @@ -17,7 +17,7 @@ def print_(text): - """Python 2 & 3 compatible print function + """Python 2 & 3 compatible print function. We support <2.6, so can't use __future__.print_function @@ -29,7 +29,7 @@ def print_(text): def parse_commandline(): - """Parse the comandline and return parsed options.""" + """Parse the command line and return parsed options.""" parser = OptionParser() parser.description = __doc__ @@ -48,7 +48,7 @@ def parse_commandline(): def main(): - """This implements the actual program functionality""" + """Implement the actual program functionality.""" return_value = 0 options, term = parse_commandline() diff --git a/github2/client.py b/github2/client.py index 7b3d8eb..0296be4 100644 --- a/github2/client.py +++ b/github2/client.py @@ -59,7 +59,7 @@ def __init__(self, username=None, api_token=None, requests_per_second=None, self.pull_requests = PullRequests(self.request) def project_for_user_repo(self, user, repo): - """Return GitHub identifier for a user's repository + """Return Github identifier for a user's repository. :param str user: repository owner :param str repo: repository name @@ -68,7 +68,7 @@ def project_for_user_repo(self, user, repo): return "/".join([user, repo]) def get_all_blobs(self, project, tree_sha): - """Get a list of all blobs for a specific tree + """Get a list of all blobs for a specific tree. .. versionadded:: 0.3.0 @@ -80,7 +80,7 @@ def get_all_blobs(self, project, tree_sha): return blobs.get("blobs") def get_blob_info(self, project, tree_sha, path): - """Get the blob for a file within a specific tree + """Get the blob for a file within a specific tree. :param str project: GitHub project :param str tree_sha: object ID of tree @@ -91,7 +91,7 @@ def get_blob_info(self, project, tree_sha, path): return blob.get("blob") def get_tree(self, project, tree_sha): - """Get tree information for a specifc tree + """Get tree information for a specifc tree. :param str project: GitHub project :param str tree_sha: object ID of tree @@ -101,7 +101,7 @@ def get_tree(self, project, tree_sha): return tree.get("tree", []) def get_network_meta(self, project): - """Get GitHub metadata associated with a project + """Get Github metadata associated with a project. :param str project: GitHub project @@ -111,7 +111,7 @@ def get_network_meta(self, project): "network_meta"]), {}) def get_network_data(self, project, nethash, start=None, end=None): - """Get chunk of GitHub network data + """Get chunk of Github network data. :param str project: GitHub project :param str nethash: identifier provided by :meth:`get_network_meta` diff --git a/github2/commits.py b/github2/commits.py index 7030a40..2bfd152 100644 --- a/github2/commits.py +++ b/github2/commits.py @@ -28,7 +28,7 @@ class Commits(GithubCommand): domain = "commits" def list(self, project, branch="master", file=None, page=1): - """List commits on a project + """List commits on a project. .. warning:: Not all projects use ``master`` as their default branch, you can @@ -45,7 +45,7 @@ def list(self, project, branch="master", file=None, page=1): datatype=Commit, page=page) def show(self, project, sha): - """Get a specific commit + """Get a specific commit. :param str project: project name :param str sha: commit id diff --git a/github2/core.py b/github2/core.py index e783456..9329e5e 100644 --- a/github2/core.py +++ b/github2/core.py @@ -27,7 +27,7 @@ def string_to_datetime(string): - """Convert a string to Python datetime + """Convert a string to Python datetime. :param str github_date: date string to parse @@ -39,7 +39,7 @@ def string_to_datetime(string): def _handle_naive_datetimes(f): - """Decorator to make datetime arguments use GitHub timezone + """Decorator to make datetime arguments use GitHub timezone. :param func f: Function to wrap @@ -61,7 +61,7 @@ def wrapper(datetime_): @_handle_naive_datetimes def datetime_to_ghdate(datetime_): - """Convert Python datetime to GitHub date string + """Convert Python datetime to Github date string. :param datetime datetime_: datetime object to convert @@ -71,7 +71,7 @@ def datetime_to_ghdate(datetime_): @_handle_naive_datetimes def datetime_to_commitdate(datetime_): - """Convert Python datetime to GitHub date string + """Convert Python datetime to Github date string. :param datetime datetime_: datetime object to convert @@ -84,12 +84,11 @@ def datetime_to_commitdate(datetime_): def datetime_to_isodate(datetime_): - """Convert Python datetime to GitHub date string - - .. note:: Supports naive and timezone-aware datetimes + """Convert Python datetime to Github date string. :param str datetime_: datetime object to convert + .. note:: Supports naive and timezone-aware datetimes """ if not datetime_.tzinfo: datetime_ = datetime_.replace(tzinfo=tz.tzutc()) @@ -104,7 +103,7 @@ class AuthError(Exception): def requires_auth(f): - """Decorate to check a function call for authentication + """Decorate to check a function call for authentication. Sets a ``requires_auth`` attribute on functions, for use in introspection. @@ -129,7 +128,7 @@ def wrapper(self, *args, **kwargs): def enhanced_by_auth(f): - """Decorator to mark a function as enhanced by authentication + """Decorator to mark a function as enhanced by authentication. Sets a ``enhanced_by_auth`` attribute on functions, for use in introspection. @@ -145,7 +144,7 @@ def enhanced_by_auth(f): class GithubCommand(object): def __init__(self, request): - """Main API binding interface + """Main API binding interface. :param github2.request.GithubRequest request: HTTP request handler @@ -153,7 +152,7 @@ def __init__(self, request): self.request = request def make_request(self, command, *args, **kwargs): - """Make an API request + """Make an API request. Various options are supported if they exist in ``kwargs``: @@ -187,7 +186,7 @@ def make_request(self, command, *args, **kwargs): return response def get_value(self, *args, **kwargs): - """Process a single-value response from the API + """Process a single-value response from the API. If a ``datatype`` parameter is given it defines the :class:`BaseData`-derived class we should build from the provided data @@ -207,7 +206,7 @@ def get_value(self, *args, **kwargs): return value def get_values(self, *args, **kwargs): - """Process a multi-value response from the API + """Process a multi-value response from the API. :see: :meth:`get_value` @@ -228,7 +227,7 @@ def get_values(self, *args, **kwargs): def doc_generator(docstring, attributes): - """Utility function to augment BaseDataType docstring + """Utility function to augment BaseDataType docstring. :param str docstring: docstring to augment :param dict attributes: attributes to add to docstring @@ -246,7 +245,7 @@ def bullet(title, text): class Attribute(object): def __init__(self, help): - """Generic object attribute for use with :class:`BaseData` + """Generic object attribute for use with :class:`BaseData`. :param str help: Attribute description @@ -269,7 +268,7 @@ class DateAttribute(Attribute): } def __init__(self, *args, **kwargs): - """Date handling attribute for use with :class:`BaseData` + """Date handling attribute for use with :class:`BaseData`. :param str format: The date format to support, see :data:`convertor_for_format` for supported options @@ -327,7 +326,8 @@ def iterate(self): # Ugly base class definition for Python 2 and 3 compatibility, where metaclass # syntax is incompatible class BaseData(BaseDataType('BaseData', (object, ), {})): - """Wrapper for API responses + + """Wrapper for API responses. .. warning:: Supports subscript attribute access purely for backwards compatibility, @@ -336,7 +336,7 @@ class BaseData(BaseDataType('BaseData', (object, ), {})): """ def __getitem__(self, key): - """Access objects's attribute using subscript notation + """Access objects's attribute using subscript notation. This is here purely to maintain compatibility when switching ``dict`` responses to ``BaseData`` derived objects. @@ -350,7 +350,7 @@ def __getitem__(self, key): return getattr(self, key) def __setitem__(self, key, value): - """Update object's attribute using subscript notation + """Update object's attribute using subscript notation. :see: :meth:`BaseData.__getitem__` @@ -364,7 +364,7 @@ def __setitem__(self, key, value): def repr_string(string): - """Shorten string for use in repr() output + """Shorten string for use in repr() output. :param str string: string to operate on :return: string, with maximum length of 20 characters diff --git a/github2/issues.py b/github2/issues.py index ad7aa35..0f72908 100644 --- a/github2/issues.py +++ b/github2/issues.py @@ -48,7 +48,7 @@ def search(self, project, term, state="open"): :param str project: GitHub project :param str term: term to search issues for - :param str state: can be either ``open`` or ``closed``. + :param str state: can be either ``open`` or ``closed`` """ return self.get_values("search", project, state, quote_plus(term), @@ -58,7 +58,7 @@ def list(self, project, state="open"): """Get all issues for project with given state. :param str project: GitHub project - :param str state: can be either ``open`` or ``closed``. + :param str state: can be either ``open`` or ``closed`` """ return self.get_values("list", project, state, filter="issues", @@ -70,7 +70,7 @@ def list_by_label(self, project, label): .. versionadded:: 0.3.0 :param str project: GitHub project - :param str label: a string representing a label (e.g., ``bug``). + :param str label: a string representing a label (e.g., ``bug``) """ return self.get_values("list", project, "label", label, @@ -111,7 +111,7 @@ def open(self, project, title, body): @requires_auth def close(self, project, number): - """Close an issue + """Close an issue. :param str project: GitHub project :param int number: issue number in the Github database @@ -122,7 +122,7 @@ def close(self, project, number): @requires_auth def reopen(self, project, number): - """Reopen a closed issue + """Reopen a closed issue. .. versionadded:: 0.3.0 @@ -135,7 +135,7 @@ def reopen(self, project, number): @requires_auth def edit(self, project, number, title, body): - """Edit an existing issue + """Edit an existing issue. .. versionadded:: 0.3.0 @@ -152,7 +152,7 @@ def edit(self, project, number, title, body): @requires_auth def add_label(self, project, number, label): - """Add a label to an issue + """Add a label to an issue. :param str project: GitHub project :param int number: issue number in the GitHub database @@ -164,7 +164,7 @@ def add_label(self, project, number, label): @requires_auth def remove_label(self, project, number, label): - """Remove an existing label from an issue + """Remove an existing label from an issue. :param str project: GitHub project :param int number: issue number in the GitHub database diff --git a/github2/organizations.py b/github2/organizations.py index 8baa328..263990b 100644 --- a/github2/organizations.py +++ b/github2/organizations.py @@ -39,7 +39,7 @@ class Organizations(GithubCommand): domain = "organizations" def show(self, organization): - """Get information on organization + """Get information on organization. :param str organization: organization to show @@ -48,12 +48,12 @@ def show(self, organization): datatype=Organization) def list(self): - """Get list of all of your organizations""" + """Get list of all of your organizations.""" return self.get_values('', filter="organizations", datatype=Organization) def repositories(self, organization=''): - """Get list of all repositories in an organization + """Get list of all repositories in an organization. If organization is not given, or is empty, then this will list repositories for all organizations the authenticated user belongs to. @@ -65,7 +65,7 @@ def repositories(self, organization=''): filter="repositories", datatype=Repository) def public_repositories(self, organization): - """Get list of public repositories in an organization + """Get list of public repositories in an organization. :param str organization: organization to list public repositories for @@ -74,7 +74,7 @@ def public_repositories(self, organization): filter="repositories", datatype=Repository) def public_members(self, organization): - """Get list of public members in an organization + """Get list of public members in an organization. :param str organization: organization to list members for @@ -83,7 +83,7 @@ def public_members(self, organization): datatype=User) def teams(self, organization): - """Get list of teams in an organization + """Get list of teams in an organization. :param str organization: organization to list teams for @@ -93,7 +93,7 @@ def teams(self, organization): @requires_auth def add_team(self, organization, name, permission='pull', projects=None): - """Add a team to an organization + """Add a team to an organization. :param str organization: organization to add team to :param str team: name of team to add diff --git a/github2/pull_requests.py b/github2/pull_requests.py index 9a0ba58..bc82814 100644 --- a/github2/pull_requests.py +++ b/github2/pull_requests.py @@ -3,7 +3,7 @@ class PullRequest(BaseData): - """Pull request encapsulation + """Pull request encapsulation. .. versionadded:: 0.5.0 @@ -42,7 +42,7 @@ def __repr__(self): class PullRequests(GithubCommand): - """Operations on pull requests + """Operations on pull requests. .. versionadded:: 0.5.0 @@ -51,7 +51,7 @@ class PullRequests(GithubCommand): domain = "pulls" def create(self, project, base, head, title=None, body=None, issue=None): - """Create a new pull request + """Create a new pull request. Pull requests can be created from scratch, or attached to an existing issue. If an ``issue`` parameter is supplied the pull request is @@ -81,7 +81,7 @@ def create(self, project, base, head, title=None, body=None, issue=None): filter="pull", datatype=PullRequest) def show(self, project, number): - """Show a single pull request + """Show a single pull request. :param str project: Github project :param int number: pull request number in the Github database @@ -91,7 +91,7 @@ def show(self, project, number): datatype=PullRequest) def list(self, project, state="open", page=1): - """List all pull requests for a project + """List all pull requests for a project. :param str project: GitHub project :param str state: can be either ``open`` or ``closed`` diff --git a/github2/repositories.py b/github2/repositories.py index 4f9b0cf..8a2b82e 100644 --- a/github2/repositories.py +++ b/github2/repositories.py @@ -86,7 +86,7 @@ def list(self, user=None, page=1): @requires_auth def watch(self, project): - """Watch a project + """Watch a project. :param str project: GitHub project @@ -96,7 +96,7 @@ def watch(self, project): @requires_auth def unwatch(self, project): - """Unwatch a project + """Unwatch a project. :param str project: GitHub project @@ -106,7 +106,7 @@ def unwatch(self, project): @requires_auth def fork(self, project): - """Fork a project + """Fork a project. :param str project: GitHub project @@ -116,7 +116,7 @@ def fork(self, project): @requires_auth def create(self, project, description=None, homepage=None, public=True): - """Create a repository + """Create a repository. :param str project: new project name :param str description: optional project description @@ -131,7 +131,7 @@ def create(self, project, description=None, homepage=None, public=True): @requires_auth def delete(self, project): - """Delete a repository + """Delete a repository. :param str project: project name to delete @@ -143,7 +143,7 @@ def delete(self, project): @requires_auth def set_private(self, project): - """Mark repository as private + """Mark repository as private. :param str project: project name to set as private @@ -152,7 +152,7 @@ def set_private(self, project): @requires_auth def set_public(self, project): - """Mark repository as public + """Mark repository as public. :param str project: project name to set as public @@ -160,7 +160,7 @@ def set_public(self, project): return self.make_request("set/public", project) def list_collaborators(self, project): - """Lists all the collaborators in a project + """Lists all the collaborators in a project. :param str project: GitHub project @@ -170,7 +170,7 @@ def list_collaborators(self, project): @requires_auth def add_collaborator(self, project, username): - """Adds an add_collaborator to a repo + """Adds an add_collaborator to a repo. :param str project: Github project :param str username: Github user to add as collaborator @@ -181,7 +181,7 @@ def add_collaborator(self, project, username): @requires_auth def remove_collaborator(self, project, username): - """Removes an add_collaborator from a repo + """Removes an add_collaborator from a repo. :param str project: Github project :param str username: Github user to add as collaborator @@ -191,7 +191,7 @@ def remove_collaborator(self, project, username): username, method="POST") def network(self, project): - """Get network data for project + """Get network data for project. :param str project: Github project @@ -200,7 +200,7 @@ def network(self, project): datatype=Repository) def languages(self, project): - """Get programming language data for project + """Get programming language data for project. :param str project: Github project @@ -209,7 +209,7 @@ def languages(self, project): filter="languages") def tags(self, project): - """Get tags for project + """Get tags for project. :param str project: Github project @@ -217,7 +217,7 @@ def tags(self, project): return self.get_values("show", project, "tags", filter="tags") def branches(self, project): - """Get branch names for project + """Get branch names for project. :param str project: Github project @@ -225,7 +225,7 @@ def branches(self, project): return self.get_values("show", project, "branches", filter="branches") def watchers(self, project): - """Get list of watchers for project + """Get list of watchers for project. :param str project: Github project @@ -233,7 +233,7 @@ def watchers(self, project): return self.get_values("show", project, "watchers", filter="watchers") def watching(self, for_user=None, page=None): - """Lists all the repos a user is watching + """Lists all the repos a user is watching. :param str for_user: optional GitHub user name to list repositories for :param int page: optional page number @@ -244,7 +244,7 @@ def watching(self, for_user=None, page=None): datatype=Repository, page=page) def list_contributors(self, project): - """Lists all the contributors in a project + """Lists all the contributors in a project. :param str project: Github project diff --git a/github2/request.py b/github2/request.py index 12a9363..8ccfe39 100644 --- a/github2/request.py +++ b/github2/request.py @@ -67,7 +67,7 @@ def charset_from_headers(headers): - """Parse charset from headers + """Parse charset from headers. :param httplib2.Response headers: Request headers :return: Defined encoding, or default to ASCII @@ -91,7 +91,7 @@ class HttpError(RuntimeError): """A HTTP error occured when making a request to the Github API.""" def __init__(self, message, content, code): - """Create a HttpError exception + """Create a HttpError exception. :param str message: Exception string :param str content: Full content of HTTP request diff --git a/github2/teams.py b/github2/teams.py index c2c7945..0feb720 100644 --- a/github2/teams.py +++ b/github2/teams.py @@ -22,7 +22,7 @@ class Teams(GithubCommand): domain = "teams" def show(self, team_id): - """Get information on team_id + """Get information on team_id. :param int team_id: team to get information for @@ -30,7 +30,7 @@ def show(self, team_id): return self.get_value(str(team_id), filter="team", datatype=Team) def members(self, team_id): - """Get list of all team members + """Get list of all team members. :param int team_id: team to get information for @@ -40,7 +40,7 @@ def members(self, team_id): @requires_auth def add_member(self, team_id, username): - """Add a new member to a team + """Add a new member to a team. :param int team_id: team to add new member to :param str username: GitHub username to add to team @@ -51,7 +51,7 @@ def add_member(self, team_id, username): datatype=User) def repositories(self, team_id): - """Get list of all team repositories + """Get list of all team repositories. :param int team_id: team to get information for @@ -61,7 +61,7 @@ def repositories(self, team_id): @requires_auth def add_project(self, team_id, project): - """Add a project to a team + """Add a project to a team. :param int team_id: team to add repository to :param str project: GitHub project @@ -75,7 +75,7 @@ def add_project(self, team_id, project): @requires_auth def remove_project(self, team_id, project): - """Remove a project to a team + """Remove a project to a team. :param int team_id: team to remove project from :param str project: GitHub project diff --git a/github2/users.py b/github2/users.py index 50b761e..65d7702 100644 --- a/github2/users.py +++ b/github2/users.py @@ -41,7 +41,7 @@ class User(BaseData): format="user") def is_authenticated(self): - """Test for user authentication + """Test for user authentication. :return bool: ``True`` if user is authenticated @@ -56,7 +56,7 @@ class Users(GithubCommand): domain = "user" def search(self, query): - """Search for users + """Search for users. .. warning: Returns at most 100 users @@ -68,7 +68,7 @@ def search(self, query): datatype=User) def search_by_email(self, query): - """Search for users by email address + """Search for users by email address. :param str query: email to search for @@ -77,7 +77,7 @@ def search_by_email(self, query): @enhanced_by_auth def show(self, username): - """Get information on GitHub user + """Get information on Github user. if ``username`` is ``None`` or an empty string information for the currently authenticated user is returned. @@ -87,7 +87,7 @@ def show(self, username): return self.get_value("show", username, filter="user", datatype=User) def followers(self, username): - """Get list of GitHub user's followers + """Get list of Github user's followers. :param str username: Github user name @@ -95,7 +95,7 @@ def followers(self, username): return self.get_values("show", username, "followers", filter="users") def following(self, username): - """Get list of users a GitHub user is following + """Get list of users a Github user is following. :param str username: Github user name @@ -104,7 +104,7 @@ def following(self, username): @requires_auth def follow(self, other_user): - """Follow a GitHub user + """Follow a Github user. :param str other_user: Github user name @@ -113,7 +113,7 @@ def follow(self, other_user): @requires_auth def unfollow(self, other_user): - """Unfollow a GitHub user + """Unfollow a Github user. :param str other_user: Github user name @@ -122,12 +122,12 @@ def unfollow(self, other_user): @requires_auth def list_keys(self): - """Get list of SSH keys for the authenticated user""" + """Get list of SSH keys for the authenticated user.""" return self.get_values('keys', filter='public_keys', datatype=Key) @requires_auth def add_key(self, key, title=''): - """Add a SSH key for the authenticated user + """Add a SSH key for the authenticated user. :param str key: SSH key identifier :param str title: Optional title for the SSH key @@ -140,7 +140,7 @@ def add_key(self, key, title=''): @requires_auth def remove_key(self, key_id): - """Remove a SSH key for the authenticated user + """Remove a SSH key for the authenticated user. :param int key_id: SSH key's GitHub identifier From 4902ffc5f29675e138e055f6beef8d28bd625430 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 15:30:24 +0100 Subject: [PATCH 09/32] [QA] Use imperative form as per PEP 257. --- github2/repositories.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/github2/repositories.py b/github2/repositories.py index 8a2b82e..c515955 100644 --- a/github2/repositories.py +++ b/github2/repositories.py @@ -160,7 +160,7 @@ def set_public(self, project): return self.make_request("set/public", project) def list_collaborators(self, project): - """Lists all the collaborators in a project. + """List all the collaborators in a project. :param str project: GitHub project @@ -170,7 +170,7 @@ def list_collaborators(self, project): @requires_auth def add_collaborator(self, project, username): - """Adds an add_collaborator to a repo. + """Add an add_collaborator to a repo. :param str project: Github project :param str username: Github user to add as collaborator @@ -181,7 +181,7 @@ def add_collaborator(self, project, username): @requires_auth def remove_collaborator(self, project, username): - """Removes an add_collaborator from a repo. + """Remove a collaborator from a repo. :param str project: Github project :param str username: Github user to add as collaborator @@ -233,7 +233,7 @@ def watchers(self, project): return self.get_values("show", project, "watchers", filter="watchers") def watching(self, for_user=None, page=None): - """Lists all the repos a user is watching. + """List all the repos a user is watching. :param str for_user: optional GitHub user name to list repositories for :param int page: optional page number @@ -244,7 +244,7 @@ def watching(self, for_user=None, page=None): datatype=Repository, page=page) def list_contributors(self, project): - """Lists all the contributors in a project. + """List all the contributors in a project. :param str project: Github project From e3ef6bc59d77adaaa358aa78d3c9b891852e1bb9 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 15:31:49 +0100 Subject: [PATCH 10/32] Added some more missing docstrings. --- github2/client.py | 5 +++-- github2/commits.py | 6 ++++++ github2/core.py | 14 +++++++++++--- github2/issues.py | 9 +++++++++ github2/organizations.py | 16 ++++++++++++++-- github2/pull_requests.py | 6 ++++-- github2/repositories.py | 5 +++++ github2/request.py | 11 +++++++---- github2/teams.py | 12 ++++++++++-- github2/users.py | 9 +++++++++ 10 files changed, 78 insertions(+), 15 deletions(-) diff --git a/github2/client.py b/github2/client.py index 0296be4..5cf8d7e 100644 --- a/github2/client.py +++ b/github2/client.py @@ -10,11 +10,12 @@ class Github(object): + """Interface to GitHub's API v2.""" + def __init__(self, username=None, api_token=None, requests_per_second=None, access_token=None, cache=None, proxy_host=None, proxy_port=8080, github_url=None): - """An interface to GitHub's API: - http://develop.github.com/ + """Setup GitHub API object. .. versionadded:: 0.2.0 The ``requests_per_second`` parameter diff --git a/github2/commits.py b/github2/commits.py index 2bfd152..a04892f 100644 --- a/github2/commits.py +++ b/github2/commits.py @@ -3,6 +3,9 @@ class Commit(BaseData): + + """Commit container.""" + message = Attribute("Commit message.") parents = Attribute("List of parents for this commit.") url = Attribute("Canonical URL for this commit.") @@ -25,6 +28,9 @@ def __repr__(self): class Commits(GithubCommand): + + """GitHub API commits functionality.""" + domain = "commits" def list(self, project, branch="master", file=None, page=1): diff --git a/github2/core.py b/github2/core.py index 9329e5e..807aa93 100644 --- a/github2/core.py +++ b/github2/core.py @@ -143,8 +143,10 @@ def enhanced_by_auth(f): class GithubCommand(object): + """Main API binding interface.""" + def __init__(self, request): - """Main API binding interface. + """Setup command object. :param github2.request.GithubRequest request: HTTP request handler @@ -244,8 +246,11 @@ def bullet(title, text): class Attribute(object): + + """Generic object attribute for use with :class:`BaseData`.""" + def __init__(self, help): - """Generic object attribute for use with :class:`BaseData`. + """Setup Attribute object. :param str help: Attribute description @@ -259,6 +264,9 @@ def to_python(self, value): class DateAttribute(Attribute): + + """Date handling attribute for use with :class:`BaseData`.""" + format = "github" converter_for_format = { "github": datetime_to_ghdate, @@ -268,7 +276,7 @@ class DateAttribute(Attribute): } def __init__(self, *args, **kwargs): - """Date handling attribute for use with :class:`BaseData`. + """Setup DateAttribute object. :param str format: The date format to support, see :data:`convertor_for_format` for supported options diff --git a/github2/issues.py b/github2/issues.py index 0f72908..89dcf17 100644 --- a/github2/issues.py +++ b/github2/issues.py @@ -8,6 +8,9 @@ class Issue(BaseData): + + """Issue container.""" + position = Attribute("The position of this issue in a list.") number = Attribute("The issue number (unique for project).") votes = Attribute("Number of votes for this issue.") @@ -28,6 +31,9 @@ def __repr__(self): class Comment(BaseData): + + """Comment container.""" + created_at = DateAttribute("The date this comment was created.") updated_at = DateAttribute("The date when this comment was last updated.") body = Attribute("The full text of this comment.") @@ -39,6 +45,9 @@ def __repr__(self): class Issues(GithubCommand): + + """GitHub API issues functionality.""" + domain = "issues" def search(self, project, term, state="open"): diff --git a/github2/organizations.py b/github2/organizations.py index 263990b..3ac66c1 100644 --- a/github2/organizations.py +++ b/github2/organizations.py @@ -6,7 +6,13 @@ class Organization(BaseData): - """.. versionadded:: 0.4.0""" + + """Organization container. + + .. versionadded:: 0.4.0 + + """ + id = Attribute("The organization id.") name = Attribute("The full name of the organization.") blog = Attribute("The organization's blog.") @@ -35,7 +41,13 @@ def __repr__(self): class Organizations(GithubCommand): - """.. versionadded:: 0.4.0""" + + """GitHub API organizations functionality. + + .. versionadded:: 0.4.0 + + """ + domain = "organizations" def show(self, organization): diff --git a/github2/pull_requests.py b/github2/pull_requests.py index bc82814..b168b66 100644 --- a/github2/pull_requests.py +++ b/github2/pull_requests.py @@ -3,7 +3,8 @@ class PullRequest(BaseData): - """Pull request encapsulation. + + """Pull request container. .. versionadded:: 0.5.0 @@ -42,7 +43,8 @@ def __repr__(self): class PullRequests(GithubCommand): - """Operations on pull requests. + + """GitHub API pull request functionality. .. versionadded:: 0.5.0 diff --git a/github2/repositories.py b/github2/repositories.py index c515955..10f07a0 100644 --- a/github2/repositories.py +++ b/github2/repositories.py @@ -5,6 +5,9 @@ class Repository(BaseData): + + """Repository container.""" + name = Attribute("Name of repository.") description = Attribute("Repository description.") forks = Attribute("Number of forks of this repository.") @@ -35,6 +38,8 @@ def __repr__(self): class Repositories(GithubCommand): + """GitHub API repository functionality.""" + domain = "repos" def search(self, query): diff --git a/github2/request.py b/github2/request.py index 8ccfe39..6dcb371 100644 --- a/github2/request.py +++ b/github2/request.py @@ -111,6 +111,13 @@ def __init__(self, message, content, code): class GithubRequest(object): + + """Make an API request. + + :see: :class:`github2.client.Github` + + """ + url_format = "%(github_url)s/api/%(api_version)s/%(api_format)s" api_version = "v2" api_format = "json" @@ -120,10 +127,6 @@ def __init__(self, username=None, api_token=None, url_prefix=None, requests_per_second=None, access_token=None, cache=None, proxy_host=None, proxy_port=None, github_url=None): - """Make an API request. - - :see: :class:`github2.client.Github` - """ self.username = username self.api_token = api_token self.access_token = access_token diff --git a/github2/teams.py b/github2/teams.py index 0feb720..7c44e86 100644 --- a/github2/teams.py +++ b/github2/teams.py @@ -5,7 +5,11 @@ class Team(BaseData): - """.. versionadded:: 0.4.0""" + """Team container. + + .. versionadded:: 0.4.0 + + """ id = Attribute("The team id") name = Attribute("Name of the team") @@ -17,7 +21,11 @@ def __repr__(self): class Teams(GithubCommand): - """.. versionadded:: 0.4.0""" + """GitHub API teams functionality. + + .. versionadded:: 0.4.0 + + """ domain = "teams" diff --git a/github2/users.py b/github2/users.py index 65d7702..4ea8c2d 100644 --- a/github2/users.py +++ b/github2/users.py @@ -8,6 +8,9 @@ class Key(BaseData): + + """SSH key container.""" + id = Attribute('The key id') key = Attribute('The SSH key data') title = Attribute('The title for the SSH key') @@ -17,6 +20,9 @@ def __repr__(self): class User(BaseData): + + """GitHub user container.""" + id = Attribute("The user id") login = Attribute("The login username") name = Attribute("The users full name") @@ -53,6 +59,9 @@ def __repr__(self): class Users(GithubCommand): + + """GitHub API user functionality.""" + domain = "user" def search(self, query): From 031018edaccd4dcee233f2dcebf7fb6d7e5261ad Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 15:32:46 +0100 Subject: [PATCH 11/32] Use class docstring with autodoc. --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index ea950db..d74babe 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -229,7 +229,7 @@ [u'Ask Solem'], 1) ] -autoclass_content = "init" +autoclass_content = "class" autodoc_default_flags = ['members', ] intersphinx_mapping = { From 862d52238f34d614aca939b8d042b8eddd65f321 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 20:39:28 +0100 Subject: [PATCH 12/32] Added pip requirements files. --- extra/requirements-doc.txt | 4 ++++ extra/requirements-py25.txt | 2 ++ extra/requirements-py3.txt | 2 ++ extra/requirements-test.txt | 3 +++ extra/requirements.txt | 2 ++ 5 files changed, 13 insertions(+) create mode 100644 extra/requirements-doc.txt create mode 100644 extra/requirements-py25.txt create mode 100644 extra/requirements-py3.txt create mode 100644 extra/requirements-test.txt create mode 100644 extra/requirements.txt diff --git a/extra/requirements-doc.txt b/extra/requirements-doc.txt new file mode 100644 index 0000000..709ee46 --- /dev/null +++ b/extra/requirements-doc.txt @@ -0,0 +1,4 @@ +-r requirements.txt +cloud_sptheme>=1.2 +sphinx>=1.1 +sphinxcontrib-cheeseshop diff --git a/extra/requirements-py25.txt b/extra/requirements-py25.txt new file mode 100644 index 0000000..33f97ee --- /dev/null +++ b/extra/requirements-py25.txt @@ -0,0 +1,2 @@ +-r requirements.txt +simplejson>=2.0.9 diff --git a/extra/requirements-py3.txt b/extra/requirements-py3.txt new file mode 100644 index 0000000..457b3fb --- /dev/null +++ b/extra/requirements-py3.txt @@ -0,0 +1,2 @@ +httplib2>=0.7.0 +python-dateutil>=2.0 diff --git a/extra/requirements-test.txt b/extra/requirements-test.txt new file mode 100644 index 0000000..c8d6b88 --- /dev/null +++ b/extra/requirements-test.txt @@ -0,0 +1,3 @@ +-r requirements.txt +coverage>=3.5 +nose>=1.1.2 diff --git a/extra/requirements.txt b/extra/requirements.txt new file mode 100644 index 0000000..57c76c4 --- /dev/null +++ b/extra/requirements.txt @@ -0,0 +1,2 @@ +httplib2>=0.7.0 +python-dateutil<2.0 From 3f60faf6f6969b23206b9ee19a46986d1fbd823b Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 19:34:48 +0100 Subject: [PATCH 13/32] Use nose.tools.eq_ instead of assert_equals. --- tests/test_charset_header.py | 6 +- tests/test_commits.py | 62 +++---- tests/test_date_handling.py | 258 ++++++++++++-------------- tests/test_issues.py | 72 ++++---- tests/test_organizations.py | 52 +++--- tests/test_pull_requests.py | 69 ++++--- tests/test_regression.py | 8 +- tests/test_repositories.py | 103 +++++------ tests/test_teams.py | 4 +- tests/test_tz_aware_date_handling.py | 266 +++++++++++++-------------- tests/test_unit.py | 30 +-- tests/test_user.py | 59 +++--- 12 files changed, 473 insertions(+), 516 deletions(-) diff --git a/tests/test_charset_header.py b/tests/test_charset_header.py index 3b29635..2786673 100644 --- a/tests/test_charset_header.py +++ b/tests/test_charset_header.py @@ -3,16 +3,16 @@ # This file is part of python-github2, and is made available under the 3-clause # BSD license. See LICENSE for the full details. -from nose.tools import assert_equals +from nose.tools import eq_ from github2.request import charset_from_headers def no_match_test(): d = {} - assert_equals("ascii", charset_from_headers(d)) + eq_("ascii", charset_from_headers(d)) def utf_test(): d = {'content-type': 'application/json; charset=utf-8'} - assert_equals("utf-8", charset_from_headers(d)) + eq_("utf-8", charset_from_headers(d)) diff --git a/tests/test_commits.py b/tests/test_commits.py index 20ed487..33f037c 100644 --- a/tests/test_commits.py +++ b/tests/test_commits.py @@ -5,7 +5,7 @@ from datetime import datetime -from nose.tools import assert_equals +from nose.tools import eq_ import utils @@ -16,28 +16,25 @@ class CommitProperties(utils.HttpMockTestCase): def test_commit(self): commit = self.client.commits.show('ask/python-github2', self.commit_id) - assert_equals(commit.message, - 'Added cache support to manage_collaborators.') - assert_equals(commit.parents, - [{"id": '7d1c855d2f44a55e4b90b40017be697cf70cb4a0'}]) - assert_equals(commit.url, - '/ask/python-github2/commit/%s' % self.commit_id) - assert_equals(commit.author['login'], 'JNRowe') - assert_equals(commit.id, self.commit_id) - assert_equals(commit.committed_date, - datetime(2011, 6, 6, 16, 13, 50)) - assert_equals(commit.authored_date, datetime(2011, 6, 6, 16, 13, 50)) - assert_equals(commit.tree, 'f48fcc1a0b8ea97f3147dc42cf7cdb6683493e94') - assert_equals(commit.committer['login'], 'JNRowe') - assert_equals(commit.added, None) - assert_equals(commit.removed, None) - assert_equals(commit.modified[0]['filename'], - 'github2/bin/manage_collaborators.py') + eq_(commit.message, 'Added cache support to manage_collaborators.') + eq_(commit.parents, + [{"id": '7d1c855d2f44a55e4b90b40017be697cf70cb4a0'}]) + eq_(commit.url, '/ask/python-github2/commit/%s' % self.commit_id) + eq_(commit.author['login'], 'JNRowe') + eq_(commit.id, self.commit_id) + eq_(commit.committed_date, datetime(2011, 6, 6, 16, 13, 50)) + eq_(commit.authored_date, datetime(2011, 6, 6, 16, 13, 50)) + eq_(commit.tree, 'f48fcc1a0b8ea97f3147dc42cf7cdb6683493e94') + eq_(commit.committer['login'], 'JNRowe') + eq_(commit.added, None) + eq_(commit.removed, None) + eq_(commit.modified[0]['filename'], + 'github2/bin/manage_collaborators.py') def test_repr(self): commit = self.client.commits.show('ask/python-github2', self.commit_id) - assert_equals(repr(commit), - '' % self.commit_id[:8]) + eq_(repr(commit), + '' % self.commit_id[:8]) class CommitsQueries(utils.HttpMockTestCase): @@ -45,32 +42,27 @@ class CommitsQueries(utils.HttpMockTestCase): def test_list(self): commits = self.client.commits.list('JNRowe/misc-overlay') - assert_equals(len(commits), 35) - assert_equals(commits[0].id, - '4de0834d58b37ef3020c49df43c95649217a2def') + eq_(len(commits), 35) + eq_(commits[0].id, '4de0834d58b37ef3020c49df43c95649217a2def') def test_list_with_page(self): commits = self.client.commits.list('JNRowe/jnrowe-misc', page=2) - assert_equals(len(commits), 35) - assert_equals(commits[0].id, - '1f5ad2c3206bafc4aca9e6ce50f5c605befdb3d6') + eq_(len(commits), 35) + eq_(commits[0].id, '1f5ad2c3206bafc4aca9e6ce50f5c605befdb3d6') def test_list_with_branch(self): commits = self.client.commits.list('JNRowe/misc-overlay', 'gh-pages') - assert_equals(len(commits), 35) - assert_equals(commits[0].id, - '025148bdaa6fb6bdac9c3522d481fadf1c0a456f') + eq_(len(commits), 35) + eq_(commits[0].id, '025148bdaa6fb6bdac9c3522d481fadf1c0a456f') def test_list_with_file(self): commits = self.client.commits.list('JNRowe/misc-overlay', file='Makefile') - assert_equals(len(commits), 35) - assert_equals(commits[0].id, - 'fc12b924d34dc38c8ce76d27a866221faa88cb72') + eq_(len(commits), 35) + eq_(commits[0].id, 'fc12b924d34dc38c8ce76d27a866221faa88cb72') def test_list_with_branch_and_file(self): commits = self.client.commits.list('JNRowe/misc-overlay', 'gh-pages', 'packages/dev-python.html') - assert_equals(len(commits), 35) - assert_equals(commits[0].id, - '025148bdaa6fb6bdac9c3522d481fadf1c0a456f') + eq_(len(commits), 35) + eq_(commits[0].id, '025148bdaa6fb6bdac9c3522d481fadf1c0a456f') diff --git a/tests/test_date_handling.py b/tests/test_date_handling.py index 855ccae..b696a74 100644 --- a/tests/test_date_handling.py +++ b/tests/test_date_handling.py @@ -6,7 +6,7 @@ from datetime import datetime as dt -from nose.tools import assert_equals +from nose.tools import eq_ from github2.core import (datetime_to_ghdate, datetime_to_commitdate, datetime_to_isodate, string_to_datetime) @@ -16,154 +16,138 @@ # naïve datetime objects used in the current code base def test_ghdate_to_datetime(): - assert_equals(string_to_datetime('2011/05/22 00:24:15 -0700'), - dt(2011, 5, 22, 0, 24, 15)) - - assert_equals(string_to_datetime('2009/04/18 13:04:09 -0700'), - dt(2009, 4, 18, 13, 4, 9)) - #assert_equals(string_to_datetime('2009/11/12 21:15:17 -0800'), - # dt(2009, 11, 12, 21, 15, 17)) - #assert_equals(string_to_datetime('2009/11/12 21:16:20 -0800'), - # dt(2009, 11, 12, 21, 16, 20)) - assert_equals(string_to_datetime('2010/04/17 17:24:29 -0700'), - dt(2010, 4, 17, 17, 24, 29)) - assert_equals(string_to_datetime('2010/05/18 06:10:36 -0700'), - dt(2010, 5, 18, 6, 10, 36)) - assert_equals(string_to_datetime('2010/05/25 21:59:37 -0700'), - dt(2010, 5, 25, 21, 59, 37)) - assert_equals(string_to_datetime('2010/05/26 17:08:41 -0700'), - dt(2010, 5, 26, 17, 8, 41)) - assert_equals(string_to_datetime('2010/06/20 06:13:37 -0700'), - dt(2010, 6, 20, 6, 13, 37)) - assert_equals(string_to_datetime('2010/07/28 12:56:51 -0700'), - dt(2010, 7, 28, 12, 56, 51)) - assert_equals(string_to_datetime('2010/09/20 21:32:49 -0700'), - dt(2010, 9, 20, 21, 32, 49)) + eq_(string_to_datetime('2011/05/22 00:24:15 -0700'), + dt(2011, 5, 22, 0, 24, 15)) + + eq_(string_to_datetime('2009/04/18 13:04:09 -0700'), + dt(2009, 4, 18, 13, 4, 9)) + #eq_(string_to_datetime('2009/11/12 21:15:17 -0800'), + # dt(2009, 11, 12, 21, 15, 17)) + #eq_(string_to_datetime('2009/11/12 21:16:20 -0800'), + # dt(2009, 11, 12, 21, 16, 20)) + eq_(string_to_datetime('2010/04/17 17:24:29 -0700'), + dt(2010, 4, 17, 17, 24, 29)) + eq_(string_to_datetime('2010/05/18 06:10:36 -0700'), + dt(2010, 5, 18, 6, 10, 36)) + eq_(string_to_datetime('2010/05/25 21:59:37 -0700'), + dt(2010, 5, 25, 21, 59, 37)) + eq_(string_to_datetime('2010/05/26 17:08:41 -0700'), + dt(2010, 5, 26, 17, 8, 41)) + eq_(string_to_datetime('2010/06/20 06:13:37 -0700'), + dt(2010, 6, 20, 6, 13, 37)) + eq_(string_to_datetime('2010/07/28 12:56:51 -0700'), + dt(2010, 7, 28, 12, 56, 51)) + eq_(string_to_datetime('2010/09/20 21:32:49 -0700'), + dt(2010, 9, 20, 21, 32, 49)) def test_datetime_to_ghdate(): - assert_equals(datetime_to_ghdate(dt(2011, 5, 22, 0, 24, 15)), - '2011/05/22 00:24:15 -0700') - - assert_equals(datetime_to_ghdate(dt(2009, 4, 18, 20, 4, 9)), - '2009/04/18 20:04:09 -0700') - #assert_equals(datetime_to_ghdate(dt(2009, 11, 13, 4, 15, 17)), - # '2009/11/13 04:15:17 -0800') - #assert_equals(datetime_to_ghdate(dt(2009, 11, 13, 4, 16, 20)), - # '2009/11/13 04:16:20 -0800') - assert_equals(datetime_to_ghdate(dt(2010, 4, 18, 0, 24, 29)), - '2010/04/18 00:24:29 -0700') - assert_equals(datetime_to_ghdate(dt(2010, 5, 18, 13, 10, 36)), - '2010/05/18 13:10:36 -0700') - assert_equals(datetime_to_ghdate(dt(2010, 5, 26, 5, 59, 37)), - '2010/05/26 05:59:37 -0700') - assert_equals(datetime_to_ghdate(dt(2010, 5, 27, 0, 8, 41)), - '2010/05/27 00:08:41 -0700') - assert_equals(datetime_to_ghdate(dt(2010, 6, 20, 13, 13, 37)), - '2010/06/20 13:13:37 -0700') - assert_equals(datetime_to_ghdate(dt(2010, 7, 28, 19, 56, 51)), - '2010/07/28 19:56:51 -0700') - assert_equals(datetime_to_ghdate(dt(2010, 9, 21, 4, 32, 49)), - '2010/09/21 04:32:49 -0700') + eq_(datetime_to_ghdate(dt(2011, 5, 22, 0, 24, 15)), + '2011/05/22 00:24:15 -0700') + + eq_(datetime_to_ghdate(dt(2009, 4, 18, 20, 4, 9)), + '2009/04/18 20:04:09 -0700') + #eq_(datetime_to_ghdate(dt(2009, 11, 13, 4, 15, 17)), + # '2009/11/13 04:15:17 -0800') + #eq_(datetime_to_ghdate(dt(2009, 11, 13, 4, 16, 20)), + # '2009/11/13 04:16:20 -0800') + eq_(datetime_to_ghdate(dt(2010, 4, 18, 0, 24, 29)), + '2010/04/18 00:24:29 -0700') + eq_(datetime_to_ghdate(dt(2010, 5, 18, 13, 10, 36)), + '2010/05/18 13:10:36 -0700') + eq_(datetime_to_ghdate(dt(2010, 5, 26, 5, 59, 37)), + '2010/05/26 05:59:37 -0700') + eq_(datetime_to_ghdate(dt(2010, 5, 27, 0, 8, 41)), + '2010/05/27 00:08:41 -0700') + eq_(datetime_to_ghdate(dt(2010, 6, 20, 13, 13, 37)), + '2010/06/20 13:13:37 -0700') + eq_(datetime_to_ghdate(dt(2010, 7, 28, 19, 56, 51)), + '2010/07/28 19:56:51 -0700') + eq_(datetime_to_ghdate(dt(2010, 9, 21, 4, 32, 49)), + '2010/09/21 04:32:49 -0700') def test_commitdate_to_datetime(): - assert_equals(string_to_datetime('2011-05-22T00:24:15-07:00'), - dt(2011, 5, 22, 0, 24, 15)) - - assert_equals(string_to_datetime('2011-04-09T10:07:30-07:00'), - dt(2011, 4, 9, 10, 7, 30)) - #assert_equals(string_to_datetime('2011-02-19T07:16:11-08:00'), - # dt(2011, 2, 19, 7, 16, 11)) - #assert_equals(string_to_datetime('2010-12-21T12:34:27-08:00'), - # dt(2010, 12, 21, 12, 34, 27)) - assert_equals(string_to_datetime('2011-04-09T10:20:05-07:00'), - dt(2011, 4, 9, 10, 20, 5)) - assert_equals(string_to_datetime('2011-04-09T10:05:58-07:00'), - dt(2011, 4, 9, 10, 5, 58)) - assert_equals(string_to_datetime('2011-04-09T09:53:00-07:00'), - dt(2011, 4, 9, 9, 53, 0)) - assert_equals(string_to_datetime('2011-04-09T10:00:21-07:00'), - dt(2011, 4, 9, 10, 0, 21)) - #assert_equals(string_to_datetime('2010-12-16T15:10:59-08:00'), - # dt(2010, 12, 16, 15, 10, 59)) - assert_equals(string_to_datetime('2011-04-09T09:53:00-07:00'), - dt(2011, 4, 9, 9, 53, 0)) - assert_equals(string_to_datetime('2011-04-09T09:53:00-07:00'), - dt(2011, 4, 9, 9, 53, 0)) + eq_(string_to_datetime('2011-05-22T00:24:15-07:00'), + dt(2011, 5, 22, 0, 24, 15)) + + eq_(string_to_datetime('2011-04-09T10:07:30-07:00'), + dt(2011, 4, 9, 10, 7, 30)) + #eq_(string_to_datetime('2011-02-19T07:16:11-08:00'), + # dt(2011, 2, 19, 7, 16, 11)) + #eq_(string_to_datetime('2010-12-21T12:34:27-08:00'), + # dt(2010, 12, 21, 12, 34, 27)) + eq_(string_to_datetime('2011-04-09T10:20:05-07:00'), + dt(2011, 4, 9, 10, 20, 5)) + eq_(string_to_datetime('2011-04-09T10:05:58-07:00'), + dt(2011, 4, 9, 10, 5, 58)) + eq_(string_to_datetime('2011-04-09T09:53:00-07:00'), + dt(2011, 4, 9, 9, 53, 0)) + eq_(string_to_datetime('2011-04-09T10:00:21-07:00'), + dt(2011, 4, 9, 10, 0, 21)) + #eq_(string_to_datetime('2010-12-16T15:10:59-08:00'), + # dt(2010, 12, 16, 15, 10, 59)) + eq_(string_to_datetime('2011-04-09T09:53:00-07:00'), + dt(2011, 4, 9, 9, 53, 0)) + eq_(string_to_datetime('2011-04-09T09:53:00-07:00'), + dt(2011, 4, 9, 9, 53, 0)) def test_datetime_to_commitdate(): - assert_equals(datetime_to_commitdate(dt(2011, 5, 22, 0, 24, 15)), - '2011-05-22T00:24:15-07:00') - - assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 10, 7, 30)), - '2011-04-09T10:07:30-07:00') - #assert_equals(datetime_to_commitdate(dt(2011, 2, 19, 7, 16, 11)), - # '2011-02-19T07:16:11-08:00') - #assert_equals(datetime_to_commitdate(dt(2010, 12, 21, 12, 34, 27)), - # '2010-12-21T12:34:27-08:00') - assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 10, 20, 5)), - '2011-04-09T10:20:05-07:00') - assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 10, 5, 58)), - '2011-04-09T10:05:58-07:00') - assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)), - '2011-04-09T09:53:00-07:00') - assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 10, 0, 21)), - '2011-04-09T10:00:21-07:00') - #assert_equals(datetime_to_commitdate(dt(2010, 12, 16, 15, 10, 59)), - # '2010-12-16T15:10:59-08:00') - assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)), - '2011-04-09T09:53:00-07:00') - assert_equals(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)), - '2011-04-09T09:53:00-07:00') + eq_(datetime_to_commitdate(dt(2011, 5, 22, 0, 24, 15)), + '2011-05-22T00:24:15-07:00') + + eq_(datetime_to_commitdate(dt(2011, 4, 9, 10, 7, 30)), + '2011-04-09T10:07:30-07:00') + #eq_(datetime_to_commitdate(dt(2011, 2, 19, 7, 16, 11)), + # '2011-02-19T07:16:11-08:00') + #eq_(datetime_to_commitdate(dt(2010, 12, 21, 12, 34, 27)), + # '2010-12-21T12:34:27-08:00') + eq_(datetime_to_commitdate(dt(2011, 4, 9, 10, 20, 5)), + '2011-04-09T10:20:05-07:00') + eq_(datetime_to_commitdate(dt(2011, 4, 9, 10, 5, 58)), + '2011-04-09T10:05:58-07:00') + eq_(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)), + '2011-04-09T09:53:00-07:00') + eq_(datetime_to_commitdate(dt(2011, 4, 9, 10, 0, 21)), + '2011-04-09T10:00:21-07:00') + #eq_(datetime_to_commitdate(dt(2010, 12, 16, 15, 10, 59)), + # '2010-12-16T15:10:59-08:00') + eq_(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)), + '2011-04-09T09:53:00-07:00') + eq_(datetime_to_commitdate(dt(2011, 4, 9, 9, 53, 0)), + '2011-04-09T09:53:00-07:00') def test_isodate_to_datetime(): - assert_equals(string_to_datetime('2011-05-22T00:24:15Z'), - dt(2011, 5, 22, 0, 24, 15)) - assert_equals(string_to_datetime('2011-04-09T10:07:30Z'), - dt(2011, 4, 9, 10, 7, 30)) - assert_equals(string_to_datetime('2011-02-19T07:16:11Z'), - dt(2011, 2, 19, 7, 16, 11)) - assert_equals(string_to_datetime('2010-12-21T12:34:27Z'), - dt(2010, 12, 21, 12, 34, 27)) - assert_equals(string_to_datetime('2011-04-09T10:20:05Z'), - dt(2011, 4, 9, 10, 20, 5)) - assert_equals(string_to_datetime('2011-04-09T10:05:58Z'), - dt(2011, 4, 9, 10, 5, 58)) - assert_equals(string_to_datetime('2011-04-09T09:53:00Z'), - dt(2011, 4, 9, 9, 53, 0)) - assert_equals(string_to_datetime('2011-04-09T10:00:21Z'), - dt(2011, 4, 9, 10, 0, 21)) - assert_equals(string_to_datetime('2010-12-16T15:10:59Z'), - dt(2010, 12, 16, 15, 10, 59)) - assert_equals(string_to_datetime('2011-04-09T09:53:00Z'), - dt(2011, 4, 9, 9, 53, 0)) - assert_equals(string_to_datetime('2011-04-09T09:53:00Z'), - dt(2011, 4, 9, 9, 53, 0)) + eq_(string_to_datetime('2011-05-22T00:24:15Z'), dt(2011, 5, 22, 0, 24, 15)) + eq_(string_to_datetime('2011-04-09T10:07:30Z'), dt(2011, 4, 9, 10, 7, 30)) + eq_(string_to_datetime('2011-02-19T07:16:11Z'), dt(2011, 2, 19, 7, 16, 11)) + eq_(string_to_datetime('2010-12-21T12:34:27Z'), + dt(2010, 12, 21, 12, 34, 27)) + eq_(string_to_datetime('2011-04-09T10:20:05Z'), dt(2011, 4, 9, 10, 20, 5)) + eq_(string_to_datetime('2011-04-09T10:05:58Z'), dt(2011, 4, 9, 10, 5, 58)) + eq_(string_to_datetime('2011-04-09T09:53:00Z'), dt(2011, 4, 9, 9, 53, 0)) + eq_(string_to_datetime('2011-04-09T10:00:21Z'), dt(2011, 4, 9, 10, 0, 21)) + eq_(string_to_datetime('2010-12-16T15:10:59Z'), + dt(2010, 12, 16, 15, 10, 59)) + eq_(string_to_datetime('2011-04-09T09:53:00Z'), dt(2011, 4, 9, 9, 53, 0)) + eq_(string_to_datetime('2011-04-09T09:53:00Z'), dt(2011, 4, 9, 9, 53, 0)) def test_datetime_to_isodate(): - assert_equals(datetime_to_isodate(dt(2011, 5, 22, 0, 24, 15)), - '2011-05-22T00:24:15Z') - assert_equals(datetime_to_isodate(dt(2011, 4, 9, 10, 7, 30)), - '2011-04-09T10:07:30Z') - assert_equals(datetime_to_isodate(dt(2011, 2, 19, 7, 16, 11)), - '2011-02-19T07:16:11Z') - assert_equals(datetime_to_isodate(dt(2010, 12, 21, 12, 34, 27)), - '2010-12-21T12:34:27Z') - assert_equals(datetime_to_isodate(dt(2011, 4, 9, 10, 20, 5)), - '2011-04-09T10:20:05Z') - assert_equals(datetime_to_isodate(dt(2011, 4, 9, 10, 5, 58)), - '2011-04-09T10:05:58Z') - assert_equals(datetime_to_isodate(dt(2011, 4, 9, 9, 53, 0)), - '2011-04-09T09:53:00Z') - assert_equals(datetime_to_isodate(dt(2011, 4, 9, 10, 0, 21)), - '2011-04-09T10:00:21Z') - assert_equals(datetime_to_isodate(dt(2010, 12, 16, 15, 10, 59)), - '2010-12-16T15:10:59Z') - assert_equals(datetime_to_isodate(dt(2011, 4, 9, 9, 53, 0)), - '2011-04-09T09:53:00Z') - assert_equals(datetime_to_isodate(dt(2011, 4, 9, 9, 53, 0)), - '2011-04-09T09:53:00Z') + eq_(datetime_to_isodate(dt(2011, 5, 22, 0, 24, 15)), + '2011-05-22T00:24:15Z') + eq_(datetime_to_isodate(dt(2011, 4, 9, 10, 7, 30)), '2011-04-09T10:07:30Z') + eq_(datetime_to_isodate(dt(2011, 2, 19, 7, 16, 11)), + '2011-02-19T07:16:11Z') + eq_(datetime_to_isodate(dt(2010, 12, 21, 12, 34, 27)), + '2010-12-21T12:34:27Z') + eq_(datetime_to_isodate(dt(2011, 4, 9, 10, 20, 5)), '2011-04-09T10:20:05Z') + eq_(datetime_to_isodate(dt(2011, 4, 9, 10, 5, 58)), '2011-04-09T10:05:58Z') + eq_(datetime_to_isodate(dt(2011, 4, 9, 9, 53, 0)), '2011-04-09T09:53:00Z') + eq_(datetime_to_isodate(dt(2011, 4, 9, 10, 0, 21)), '2011-04-09T10:00:21Z') + eq_(datetime_to_isodate(dt(2010, 12, 16, 15, 10, 59)), + '2010-12-16T15:10:59Z') + eq_(datetime_to_isodate(dt(2011, 4, 9, 9, 53, 0)), '2011-04-09T09:53:00Z') + eq_(datetime_to_isodate(dt(2011, 4, 9, 9, 53, 0)), '2011-04-09T09:53:00Z') diff --git a/tests/test_issues.py b/tests/test_issues.py index f82302b..2abf495 100644 --- a/tests/test_issues.py +++ b/tests/test_issues.py @@ -5,7 +5,7 @@ from datetime import datetime -from nose.tools import assert_equals +from nose.tools import eq_ import utils @@ -13,44 +13,42 @@ class Issue(utils.HttpMockTestCase): def test_properties(self): issue = self.client.issues.show('ask/python-github2', 24) - assert_equals(issue.position, 24.0) - assert_equals(issue.number, 24) - assert_equals(issue.votes, 0) - assert_equals(len(issue.body), 164) - assert_equals(issue.title, 'Pagination support for commits.') - assert_equals(issue.user, 'svetlyak40wt') - assert_equals(issue.state, 'open') - assert_equals(issue.labels, []) - assert_equals(issue.created_at, datetime(2010, 12, 8, 23, 50, 26)) - assert_equals(issue.closed_at, None) - assert_equals(issue.updated_at, datetime(2011, 1, 4, 16, 26, 7)) - assert_equals(issue.diff_url, - 'https://github.com/ask/python-github2/pull/24.diff') - assert_equals(issue.patch_url, - 'https://github.com/ask/python-github2/pull/24.patch') - assert_equals(issue.pull_request_url, - 'https://github.com/ask/python-github2/pull/24') + eq_(issue.position, 24.0) + eq_(issue.number, 24) + eq_(issue.votes, 0) + eq_(len(issue.body), 164) + eq_(issue.title, 'Pagination support for commits.') + eq_(issue.user, 'svetlyak40wt') + eq_(issue.state, 'open') + eq_(issue.labels, []) + eq_(issue.created_at, datetime(2010, 12, 8, 23, 50, 26)) + eq_(issue.closed_at, None) + eq_(issue.updated_at, datetime(2011, 1, 4, 16, 26, 7)) + eq_(issue.diff_url, + 'https://github.com/ask/python-github2/pull/24.diff') + eq_(issue.patch_url, + 'https://github.com/ask/python-github2/pull/24.patch') + eq_(issue.pull_request_url, + 'https://github.com/ask/python-github2/pull/24') def test_issue_repr(self): issue = self.client.issues.show('ask/python-github2', 24) - assert_equals(repr(issue), - '') + eq_(repr(issue), '') class Comment(utils.HttpMockTestCase): def test_properties(self): comments = self.client.issues.comments('ask/python-github2', 24) comment = comments[0] - assert_equals(comment.created_at, datetime(2010, 12, 9, 22, 37, 26)) - assert_equals(comment.updated_at, datetime(2010, 12, 9, 22, 37, 26)) - assert_equals(len(comment.body), 267) - assert_equals(comment.id, 601871) - assert_equals(comment.user, 'nvie') + eq_(comment.created_at, datetime(2010, 12, 9, 22, 37, 26)) + eq_(comment.updated_at, datetime(2010, 12, 9, 22, 37, 26)) + eq_(len(comment.body), 267) + eq_(comment.id, 601871) + eq_(comment.user, 'nvie') def test_comment_repr(self): comments = self.client.issues.comments('ask/python-github2', 24) - assert_equals(repr(comments[1]), - '') + eq_(repr(comments[1]), '') class IssueQueries(utils.HttpMockTestCase): @@ -58,25 +56,25 @@ class IssueQueries(utils.HttpMockTestCase): def test_search(self): issues = self.client.issues.search('ask/python-github2', 'timezone', 'closed') - assert_equals(len(issues), 2) - assert_equals(issues[1].number, 39) + eq_(len(issues), 2) + eq_(issues[1].number, 39) def test_list(self): issues = self.client.issues.list('ask/python-github2') - assert_equals(len(issues), 4) - assert_equals(issues[-1].number, 58) + eq_(len(issues), 4) + eq_(issues[-1].number, 58) def test_list_with_state(self): issues = self.client.issues.list('ask/python-github2', "closed") - assert_equals(len(issues), 55) - assert_equals(issues[0].number, 59) + eq_(len(issues), 55) + eq_(issues[0].number, 59) def test_issue_labels(self): labels = self.client.issues.list_labels('JNRowe/misc-overlay') - assert_equals(len(labels), 4) - assert_equals(labels[0], 'feature') + eq_(len(labels), 4) + eq_(labels[0], 'feature') def test_list_by_label(self): issues = self.client.issues.list_by_label('JNRowe/misc-overlay', 'bug') - assert_equals(len(issues), 30) - assert_equals(issues[-1].number, 328) + eq_(len(issues), 30) + eq_(issues[-1].number, 328) diff --git a/tests/test_organizations.py b/tests/test_organizations.py index 8571e23..399d450 100644 --- a/tests/test_organizations.py +++ b/tests/test_organizations.py @@ -5,7 +5,7 @@ from datetime import datetime -from nose.tools import (assert_equals, assert_true) +from nose.tools import (eq_, assert_true) import utils @@ -13,23 +13,21 @@ class OrganizationProperties(utils.HttpMockTestCase): def test_properties(self): organization = self.client.organizations.show('github') - assert_equals(organization.id, 9919) - assert_equals(organization.name, 'GitHub') - assert_equals(organization.blog, 'https://github.com/about') - assert_equals(organization.location, 'San Francisco, CA') - assert_equals(organization.gravatar_id, - '61024896f291303615bcd4f7a0dcfb74') - assert_equals(organization.login, 'github') - assert_equals(organization.email, 'support@github.com') - assert_equals(organization.company, None) - assert_equals(organization.created_at, - datetime(2008, 5, 10, 21, 37, 31)) - assert_equals(organization.following_count, 0) - assert_equals(organization.followers_count, 591) - assert_equals(organization.public_gist_count, 0) - assert_equals(organization.public_repo_count, 31) - assert_equals(organization.permission, None) - assert_equals(organization.plan, None) + eq_(organization.id, 9919) + eq_(organization.name, 'GitHub') + eq_(organization.blog, 'https://github.com/about') + eq_(organization.location, 'San Francisco, CA') + eq_(organization.gravatar_id, '61024896f291303615bcd4f7a0dcfb74') + eq_(organization.login, 'github') + eq_(organization.email, 'support@github.com') + eq_(organization.company, None) + eq_(organization.created_at, datetime(2008, 5, 10, 21, 37, 31)) + eq_(organization.following_count, 0) + eq_(organization.followers_count, 591) + eq_(organization.public_gist_count, 0) + eq_(organization.public_repo_count, 31) + eq_(organization.permission, None) + eq_(organization.plan, None) def test_is_authenticated(self): organization = self.client.organizations.show('github') @@ -41,29 +39,28 @@ def test_is_authenticated(self): class Organization(utils.HttpMockTestCase): def test_repr(self): organization = self.client.organizations.show('github') - assert_equals(repr(organization), - '') + eq_(repr(organization), '') class OrganizationQueries(utils.HttpMockTestCase): """Test organisation querying""" def test_public_repositories(self): repos = self.client.organizations.public_repositories('github') - assert_equals(len(repos), 31) - assert_equals(repos[2].name, 'hubahuba') + eq_(len(repos), 31) + eq_(repos[2].name, 'hubahuba') def test_public_members(self): members = self.client.organizations.public_members('github') - assert_equals(len(members), 35) - assert_equals(members[2].name, 'Ben Burkert') + eq_(len(members), 35) + eq_(members[2].name, 'Ben Burkert') class OrganizationsEdits(utils.HttpMockAuthenticatedTestCase): def test_add_team(self): team = self.client.organizations.add_team('JNRowe-test-org', 'test_pull', 'pull') - assert_equals(team.name, 'team_pull') - assert_equals(team.permission, 'pull') + eq_(team.name, 'team_pull') + eq_(team.permission, 'pull') def test_add_team_with_repos(self): projects = ['JNRowe-test-org/test1', 'JNRowe-test-org/test2'] @@ -72,5 +69,4 @@ def test_add_team_with_repos(self): projects) team_repos = self.client.teams.repositories(team.id) - assert_equals(['/'.join([x.organization, x.name]) for x in team_repos], - projects) + eq_(['/'.join([x.organization, x.name]) for x in team_repos], projects) diff --git a/tests/test_pull_requests.py b/tests/test_pull_requests.py index 9c2d35e..efe486c 100644 --- a/tests/test_pull_requests.py +++ b/tests/test_pull_requests.py @@ -5,7 +5,7 @@ from datetime import datetime -from nose.tools import assert_equals +from nose.tools import eq_ import utils @@ -13,55 +13,48 @@ class PullRequest(utils.HttpMockTestCase): def test_properties(self): pull_request = self.client.pull_requests.show('ask/python-github2', 39) - assert_equals(pull_request.state, 'closed') - assert_equals(pull_request.base['sha'], + eq_(pull_request.state, 'closed') + eq_(pull_request.base['sha'], '0786a96c80afad7bbd0747df590f649eaa46ca04') - assert_equals(pull_request.head['sha'], + eq_(pull_request.head['sha'], '5438e41d9c390f53089ed3fa0842831fafc73d8e') - assert_equals(pull_request.issue_user['login'], 'JNRowe') - assert_equals(pull_request.user['login'], 'JNRowe') - assert_equals(pull_request.title, 'Datetime timezone handling.') - assert_equals(len(pull_request.body), 1442) - assert_equals(pull_request.position, 39.0) - assert_equals(pull_request.number, 39.0) - assert_equals(pull_request.votes, 0) - assert_equals(pull_request.comments, 4) - assert_equals(pull_request.diff_url, - 'https://github.com/ask/python-github2/pull/39.diff') - assert_equals(pull_request.patch_url, - 'https://github.com/ask/python-github2/pull/39.patch') - assert_equals(pull_request.labels, []) - assert_equals(pull_request.html_url, - 'https://github.com/ask/python-github2/pull/39') - assert_equals(pull_request.issue_created_at, - datetime(2011, 4, 18, 15, 25, 47)) - assert_equals(pull_request.issue_updated_at, - datetime(2011, 6, 23, 9, 33, 57)) - assert_equals(pull_request.created_at, - datetime(2011, 6, 20, 16, 51, 24)) - assert_equals(pull_request.updated_at, - datetime(2011, 6, 23, 9, 28, 42)) - assert_equals(pull_request.closed_at, - datetime(2011, 6, 23, 9, 33, 57)) - assert_equals(len(pull_request.discussion), 13) - assert_equals(pull_request.mergeable, True) + eq_(pull_request.issue_user['login'], 'JNRowe') + eq_(pull_request.user['login'], 'JNRowe') + eq_(pull_request.title, 'Datetime timezone handling.') + eq_(len(pull_request.body), 1442) + eq_(pull_request.position, 39.0) + eq_(pull_request.number, 39.0) + eq_(pull_request.votes, 0) + eq_(pull_request.comments, 4) + eq_(pull_request.diff_url, + 'https://github.com/ask/python-github2/pull/39.diff') + eq_(pull_request.patch_url, + 'https://github.com/ask/python-github2/pull/39.patch') + eq_(pull_request.labels, []) + eq_(pull_request.html_url, + 'https://github.com/ask/python-github2/pull/39') + eq_(pull_request.issue_created_at, datetime(2011, 4, 18, 15, 25, 47)) + eq_(pull_request.issue_updated_at, datetime(2011, 6, 23, 9, 33, 57)) + eq_(pull_request.created_at, datetime(2011, 6, 20, 16, 51, 24)) + eq_(pull_request.updated_at, datetime(2011, 6, 23, 9, 28, 42)) + eq_(pull_request.closed_at, datetime(2011, 6, 23, 9, 33, 57)) + eq_(len(pull_request.discussion), 13) + eq_(pull_request.mergeable, True) def test_repr(self): pull_request = self.client.pull_requests.show('ask/python-github2', 39) - assert_equals(repr(pull_request), - '') + eq_(repr(pull_request), '') class PullRequestQueries(utils.HttpMockTestCase): """Test pull request querying""" def test_list(self): pull_requests = self.client.pull_requests.list('ask/python-github2') - assert_equals(len(pull_requests), 1) - assert_equals(pull_requests[0].title, - 'Pagination support for commits.') + eq_(len(pull_requests), 1) + eq_(pull_requests[0].title, 'Pagination support for commits.') def test_list_with_page(self): pull_requests = self.client.pull_requests.list('robbyrussell/oh-my-zsh', page=2) - assert_equals(len(pull_requests), 52) - assert_equals(pull_requests[1].title, 'Added my own custom theme') + eq_(len(pull_requests), 52) + eq_(pull_requests[1].title, 'Added my own custom theme') diff --git a/tests/test_regression.py b/tests/test_regression.py index cad7dc2..d5ff091 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -5,7 +5,7 @@ import httplib2 -from nose.tools import assert_equals +from nose.tools import eq_ from github2.client import Github @@ -21,8 +21,8 @@ def test_issue_50(): client = Github(proxy_host="my.proxy.com", proxy_port=9000) setup_args = client.request._http.called_with - assert_equals(type(setup_args['proxy_info']), httplib2.ProxyInfo) - assert_equals(setup_args['proxy_info'].proxy_host, 'my.proxy.com') - assert_equals(setup_args['proxy_info'].proxy_port, 9000) + eq_(type(setup_args['proxy_info']), httplib2.ProxyInfo) + eq_(setup_args['proxy_info'].proxy_host, 'my.proxy.com') + eq_(setup_args['proxy_info'].proxy_port, 9000) utils.unset_http_mock() diff --git a/tests/test_repositories.py b/tests/test_repositories.py index 1cdaab9..39017df 100644 --- a/tests/test_repositories.py +++ b/tests/test_repositories.py @@ -7,7 +7,7 @@ import datetime -from nose.tools import assert_equals +from nose.tools import eq_ import utils @@ -15,7 +15,7 @@ class Repo(utils.HttpMockTestCase): def test_repr(self): repo = self.client.repos.show('JNRowe/misc-overlay') - assert_equals(repr(repo), '') + eq_(repr(repo), '') class RepoProperties(utils.HttpMockTestCase): @@ -23,103 +23,98 @@ class RepoProperties(utils.HttpMockTestCase): def test_repo(self): repo = self.client.repos.show('JNRowe/misc-overlay') - assert_equals(repo.name, 'misc-overlay') - assert_equals(repo.description, - 'Gentoo overlay -- miscellaneous packages') - assert_equals(repo.url, 'https://github.com/JNRowe/misc-overlay') - assert_equals(repo.owner, 'JNRowe') - assert_equals(repo.homepage, 'http://jnrowe.github.com/misc-overlay/') + eq_(repo.name, 'misc-overlay') + eq_(repo.description, 'Gentoo overlay -- miscellaneous packages') + eq_(repo.url, 'https://github.com/JNRowe/misc-overlay') + eq_(repo.owner, 'JNRowe') + eq_(repo.homepage, 'http://jnrowe.github.com/misc-overlay/') - assert_equals(repo.project, 'JNRowe/misc-overlay') + eq_(repo.project, 'JNRowe/misc-overlay') def test_meta(self): repo = self.client.repos.show('JNRowe/misc-overlay') - assert_equals(repo.forks, 0) - assert_equals(repo.watchers, 5) - assert_equals(repo.private, False) - assert_equals(repo.fork, False) - assert_equals(repo.master_branch, None) - assert_equals(repo.integration_branch, None) - assert_equals(repo.open_issues, 13) - assert_equals(repo.created_at, - datetime.datetime(2009, 5, 2, 7, 32, 50)) - assert_equals(repo.pushed_at, - datetime.datetime(2011, 8, 11, 11, 46, 23)) - assert_equals(repo.has_downloads, True) - assert_equals(repo.has_wiki, True) - assert_equals(repo.has_issues, True) - assert_equals(repo.language, 'Python') + eq_(repo.forks, 0) + eq_(repo.watchers, 5) + eq_(repo.private, False) + eq_(repo.fork, False) + eq_(repo.master_branch, None) + eq_(repo.integration_branch, None) + eq_(repo.open_issues, 13) + eq_(repo.created_at, datetime.datetime(2009, 5, 2, 7, 32, 50)) + eq_(repo.pushed_at, datetime.datetime(2011, 8, 11, 11, 46, 23)) + eq_(repo.has_downloads, True) + eq_(repo.has_wiki, True) + eq_(repo.has_issues, True) + eq_(repo.language, 'Python') def test_fork_properties(self): repo = self.client.repos.show('JNRowe/python-github2') - assert_equals(repo.forks, 0) - assert_equals(repo.fork, True) - assert_equals(repo.parent, 'ask/python-github2') - assert_equals(repo.source, 'ask/python-github2') + eq_(repo.forks, 0) + eq_(repo.fork, True) + eq_(repo.parent, 'ask/python-github2') + eq_(repo.source, 'ask/python-github2') class RepoQueries(utils.HttpMockTestCase): """Test repository querying""" def test_search(self): repos = self.client.repos.search('surfraw') - assert_equals(len(repos), 8) - assert_equals(repos[0].owner, 'JNRowe') + eq_(len(repos), 8) + eq_(repos[0].owner, 'JNRowe') def test_list(self): repos = self.client.repos.list('JNRowe') - assert_equals(len(repos), 48) - assert_equals(repos[0].name, 'bfm') + eq_(len(repos), 48) + eq_(repos[0].name, 'bfm') def test_list_with_page(self): repos = self.client.repos.list('tekkub', page=2) - assert_equals(len(repos), 37) - assert_equals(repos[0].name, 'OhSnap') + eq_(len(repos), 37) + eq_(repos[0].name, 'OhSnap') def test_watching(self): repos = self.client.repos.watching('JNRowe') - assert_equals(len(repos), 90) - assert_equals(repos[0].name, 'nerdtree') + eq_(len(repos), 90) + eq_(repos[0].name, 'nerdtree') def test_watching_with_page(self): repos = self.client.repos.watching('tekkub', page=2) - assert_equals(len(repos), 39) - assert_equals(repos[0].name, 'Buffoon') + eq_(len(repos), 39) + eq_(repos[0].name, 'Buffoon') def test_contributors(self): contributors = self.client.repos.list_contributors('ask/python-github2') - assert_equals(len(contributors), 29) - assert_equals(contributors[1].name, 'Ask Solem Hoel') + eq_(len(contributors), 29) + eq_(contributors[1].name, 'Ask Solem Hoel') def test_list_collaborators(self): collaborators = self.client.repos.list_collaborators('ask/python-github2') - assert_equals(len(collaborators), 4) - assert_equals(collaborators[2], 'JNRowe') + eq_(len(collaborators), 4) + eq_(collaborators[2], 'JNRowe') def test_languages(self): languages = self.client.repos.languages('JNRowe/misc-overlay') - assert_equals(len(languages), 2) - assert_equals(languages['Python'], 11194) + eq_(len(languages), 2) + eq_(languages['Python'], 11194) def test_tags(self): tags = self.client.repos.tags('ask/python-github2') - assert_equals(len(tags), 7) - assert_equals(tags['0.4.1'], - '96b0a41dd249c521323700bc11a0a721a7c9e642') + eq_(len(tags), 7) + eq_(tags['0.4.1'], '96b0a41dd249c521323700bc11a0a721a7c9e642') def test_branches(self): branches = self.client.repos.branches('ask/python-github2') - assert_equals(len(branches), 1) - assert_equals(branches['master'], - '1c83cde9b5a7c396a01af1007fb7b88765b9ae45') + eq_(len(branches), 1) + eq_(branches['master'], '1c83cde9b5a7c396a01af1007fb7b88765b9ae45') def test_watchers(self): watchers = self.client.repos.watchers('ask/python-github2') - assert_equals(len(watchers), 143) - assert_equals(watchers[0], 'ask') + eq_(len(watchers), 143) + eq_(watchers[0], 'ask') class AuthenticatedRepoQueries(utils.HttpMockAuthenticatedTestCase): def test_pushable(self): repos = self.client.repos.pushable() - assert_equals(len(repos), 1) - assert_equals(repos[0].name, 'python-github2') + eq_(len(repos), 1) + eq_(repos[0].name, 'python-github2') diff --git a/tests/test_teams.py b/tests/test_teams.py index 7333edd..cd18166 100644 --- a/tests/test_teams.py +++ b/tests/test_teams.py @@ -3,7 +3,7 @@ # This file is part of python-github2, and is made available under the 3-clause # BSD license. See LICENSE for the full details. -from nose.tools import assert_equals +from nose.tools import eq_ import utils @@ -11,4 +11,4 @@ class TeamEdits(utils.HttpMockAuthenticatedTestCase): def test_add_member(self): users = self.client.teams.add_member(121990, 'JNRowe') - assert_equals(users[0].login, 'JNRowe') + eq_(users[0].login, 'JNRowe') diff --git a/tests/test_tz_aware_date_handling.py b/tests/test_tz_aware_date_handling.py index 6a501f0..77302ba 100644 --- a/tests/test_tz_aware_date_handling.py +++ b/tests/test_tz_aware_date_handling.py @@ -7,7 +7,7 @@ from datetime import datetime as dt from dateutil.tz import tzutc -from nose.tools import assert_equals +from nose.tools import eq_ from github2 import core from github2.core import (datetime_to_ghdate, datetime_to_commitdate, @@ -33,150 +33,150 @@ def dt_utz(year, month, day, hour, minute, second): def test_ghdate_to_datetime(): - assert_equals(string_to_datetime('2011/05/22 00:24:15 -0700'), - dt_utz(2011, 5, 22, 7, 24, 15)) - assert_equals(string_to_datetime('2009/04/18 13:04:09 -0700'), - dt_utz(2009, 4, 18, 20, 4, 9)) - assert_equals(string_to_datetime('2009/11/12 21:15:17 -0800'), - dt_utz(2009, 11, 13, 5, 15, 17)) - assert_equals(string_to_datetime('2009/11/12 21:16:20 -0800'), - dt_utz(2009, 11, 13, 5, 16, 20)) - assert_equals(string_to_datetime('2010/04/17 17:24:29 -0700'), - dt_utz(2010, 4, 18, 0, 24, 29)) - assert_equals(string_to_datetime('2010/05/18 06:10:36 -0700'), - dt_utz(2010, 5, 18, 13, 10, 36)) - assert_equals(string_to_datetime('2010/05/25 21:59:37 -0700'), - dt_utz(2010, 5, 26, 4, 59, 37)) - assert_equals(string_to_datetime('2010/05/26 17:08:41 -0700'), - dt_utz(2010, 5, 27, 0, 8, 41)) - assert_equals(string_to_datetime('2010/06/20 06:13:37 -0700'), - dt_utz(2010, 6, 20, 13, 13, 37)) - assert_equals(string_to_datetime('2010/07/28 12:56:51 -0700'), - dt_utz(2010, 7, 28, 19, 56, 51)) - assert_equals(string_to_datetime('2010/09/20 21:32:49 -0700'), - dt_utz(2010, 9, 21, 4, 32, 49)) + eq_(string_to_datetime('2011/05/22 00:24:15 -0700'), + dt_utz(2011, 5, 22, 7, 24, 15)) + eq_(string_to_datetime('2009/04/18 13:04:09 -0700'), + dt_utz(2009, 4, 18, 20, 4, 9)) + eq_(string_to_datetime('2009/11/12 21:15:17 -0800'), + dt_utz(2009, 11, 13, 5, 15, 17)) + eq_(string_to_datetime('2009/11/12 21:16:20 -0800'), + dt_utz(2009, 11, 13, 5, 16, 20)) + eq_(string_to_datetime('2010/04/17 17:24:29 -0700'), + dt_utz(2010, 4, 18, 0, 24, 29)) + eq_(string_to_datetime('2010/05/18 06:10:36 -0700'), + dt_utz(2010, 5, 18, 13, 10, 36)) + eq_(string_to_datetime('2010/05/25 21:59:37 -0700'), + dt_utz(2010, 5, 26, 4, 59, 37)) + eq_(string_to_datetime('2010/05/26 17:08:41 -0700'), + dt_utz(2010, 5, 27, 0, 8, 41)) + eq_(string_to_datetime('2010/06/20 06:13:37 -0700'), + dt_utz(2010, 6, 20, 13, 13, 37)) + eq_(string_to_datetime('2010/07/28 12:56:51 -0700'), + dt_utz(2010, 7, 28, 19, 56, 51)) + eq_(string_to_datetime('2010/09/20 21:32:49 -0700'), + dt_utz(2010, 9, 21, 4, 32, 49)) def test_datetime_to_ghdate(): - assert_equals(datetime_to_ghdate(dt_utz(2011, 5, 22, 7, 24, 15)), - '2011/05/22 00:24:15 -0700') - assert_equals(datetime_to_ghdate(dt_utz(2009, 4, 18, 20, 4, 9)), - '2009/04/18 13:04:09 -0700') - assert_equals(datetime_to_ghdate(dt_utz(2009, 11, 13, 4, 15, 17)), - '2009/11/12 20:15:17 -0800') - assert_equals(datetime_to_ghdate(dt_utz(2009, 11, 13, 4, 16, 20)), - '2009/11/12 20:16:20 -0800') - assert_equals(datetime_to_ghdate(dt_utz(2010, 4, 18, 0, 24, 29)), - '2010/04/17 17:24:29 -0700') - assert_equals(datetime_to_ghdate(dt_utz(2010, 5, 18, 13, 10, 36)), - '2010/05/18 06:10:36 -0700') - assert_equals(datetime_to_ghdate(dt_utz(2010, 5, 26, 5, 59, 37)), - '2010/05/25 22:59:37 -0700') - assert_equals(datetime_to_ghdate(dt_utz(2010, 5, 27, 0, 8, 41)), - '2010/05/26 17:08:41 -0700') - assert_equals(datetime_to_ghdate(dt_utz(2010, 6, 20, 13, 13, 37)), - '2010/06/20 06:13:37 -0700') - assert_equals(datetime_to_ghdate(dt_utz(2010, 7, 28, 19, 56, 51)), - '2010/07/28 12:56:51 -0700') - assert_equals(datetime_to_ghdate(dt_utz(2010, 9, 21, 4, 32, 49)), - '2010/09/20 21:32:49 -0700') + eq_(datetime_to_ghdate(dt_utz(2011, 5, 22, 7, 24, 15)), + '2011/05/22 00:24:15 -0700') + eq_(datetime_to_ghdate(dt_utz(2009, 4, 18, 20, 4, 9)), + '2009/04/18 13:04:09 -0700') + eq_(datetime_to_ghdate(dt_utz(2009, 11, 13, 4, 15, 17)), + '2009/11/12 20:15:17 -0800') + eq_(datetime_to_ghdate(dt_utz(2009, 11, 13, 4, 16, 20)), + '2009/11/12 20:16:20 -0800') + eq_(datetime_to_ghdate(dt_utz(2010, 4, 18, 0, 24, 29)), + '2010/04/17 17:24:29 -0700') + eq_(datetime_to_ghdate(dt_utz(2010, 5, 18, 13, 10, 36)), + '2010/05/18 06:10:36 -0700') + eq_(datetime_to_ghdate(dt_utz(2010, 5, 26, 5, 59, 37)), + '2010/05/25 22:59:37 -0700') + eq_(datetime_to_ghdate(dt_utz(2010, 5, 27, 0, 8, 41)), + '2010/05/26 17:08:41 -0700') + eq_(datetime_to_ghdate(dt_utz(2010, 6, 20, 13, 13, 37)), + '2010/06/20 06:13:37 -0700') + eq_(datetime_to_ghdate(dt_utz(2010, 7, 28, 19, 56, 51)), + '2010/07/28 12:56:51 -0700') + eq_(datetime_to_ghdate(dt_utz(2010, 9, 21, 4, 32, 49)), + '2010/09/20 21:32:49 -0700') def test_commitdate_to_datetime(): - assert_equals(string_to_datetime('2011-05-22T00:24:15-07:00'), - dt_utz(2011, 5, 22, 7, 24, 15)) - assert_equals(string_to_datetime('2011-04-09T10:07:30-07:00'), - dt_utz(2011, 4, 9, 17, 7, 30)) - assert_equals(string_to_datetime('2011-02-19T07:16:11-08:00'), - dt_utz(2011, 2, 19, 15, 16, 11)) - assert_equals(string_to_datetime('2010-12-21T12:34:27-08:00'), - dt_utz(2010, 12, 21, 20, 34, 27)) - assert_equals(string_to_datetime('2011-04-09T10:20:05-07:00'), - dt_utz(2011, 4, 9, 17, 20, 5)) - assert_equals(string_to_datetime('2011-04-09T10:05:58-07:00'), - dt_utz(2011, 4, 9, 17, 5, 58)) - assert_equals(string_to_datetime('2011-04-09T09:53:00-07:00'), - dt_utz(2011, 4, 9, 16, 53, 0)) - assert_equals(string_to_datetime('2011-04-09T10:00:21-07:00'), - dt_utz(2011, 4, 9, 17, 0, 21)) - assert_equals(string_to_datetime('2010-12-16T15:10:59-08:00'), - dt_utz(2010, 12, 16, 23, 10, 59)) - assert_equals(string_to_datetime('2011-04-09T09:53:00-07:00'), - dt_utz(2011, 4, 9, 16, 53, 0)) - assert_equals(string_to_datetime('2011-04-09T09:53:00-07:00'), - dt_utz(2011, 4, 9, 16, 53, 0)) + eq_(string_to_datetime('2011-05-22T00:24:15-07:00'), + dt_utz(2011, 5, 22, 7, 24, 15)) + eq_(string_to_datetime('2011-04-09T10:07:30-07:00'), + dt_utz(2011, 4, 9, 17, 7, 30)) + eq_(string_to_datetime('2011-02-19T07:16:11-08:00'), + dt_utz(2011, 2, 19, 15, 16, 11)) + eq_(string_to_datetime('2010-12-21T12:34:27-08:00'), + dt_utz(2010, 12, 21, 20, 34, 27)) + eq_(string_to_datetime('2011-04-09T10:20:05-07:00'), + dt_utz(2011, 4, 9, 17, 20, 5)) + eq_(string_to_datetime('2011-04-09T10:05:58-07:00'), + dt_utz(2011, 4, 9, 17, 5, 58)) + eq_(string_to_datetime('2011-04-09T09:53:00-07:00'), + dt_utz(2011, 4, 9, 16, 53, 0)) + eq_(string_to_datetime('2011-04-09T10:00:21-07:00'), + dt_utz(2011, 4, 9, 17, 0, 21)) + eq_(string_to_datetime('2010-12-16T15:10:59-08:00'), + dt_utz(2010, 12, 16, 23, 10, 59)) + eq_(string_to_datetime('2011-04-09T09:53:00-07:00'), + dt_utz(2011, 4, 9, 16, 53, 0)) + eq_(string_to_datetime('2011-04-09T09:53:00-07:00'), + dt_utz(2011, 4, 9, 16, 53, 0)) def test_datetime_to_commitdate(): - assert_equals(datetime_to_commitdate(dt_utz(2011, 5, 22, 7, 24, 15)), - '2011-05-22T00:24:15-07:00') - assert_equals(datetime_to_commitdate(dt_utz(2011, 4, 9, 17, 7, 30)), - '2011-04-09T10:07:30-07:00') - assert_equals(datetime_to_commitdate(dt_utz(2011, 2, 19, 15, 16, 11)), - '2011-02-19T07:16:11-08:00') - assert_equals(datetime_to_commitdate(dt_utz(2010, 12, 21, 20, 34, 27)), - '2010-12-21T12:34:27-08:00') - assert_equals(datetime_to_commitdate(dt_utz(2011, 4, 9, 17, 20, 5)), - '2011-04-09T10:20:05-07:00') - assert_equals(datetime_to_commitdate(dt_utz(2011, 4, 9, 17, 5, 58)), - '2011-04-09T10:05:58-07:00') - assert_equals(datetime_to_commitdate(dt_utz(2011, 4, 9, 16, 53, 0)), - '2011-04-09T09:53:00-07:00') - assert_equals(datetime_to_commitdate(dt_utz(2011, 4, 9, 17, 0, 21)), - '2011-04-09T10:00:21-07:00') - assert_equals(datetime_to_commitdate(dt_utz(2010, 12, 16, 23, 10, 59)), - '2010-12-16T15:10:59-08:00') - assert_equals(datetime_to_commitdate(dt_utz(2011, 4, 9, 16, 53, 0)), - '2011-04-09T09:53:00-07:00') - assert_equals(datetime_to_commitdate(dt_utz(2011, 4, 9, 16, 53, 0)), - '2011-04-09T09:53:00-07:00') + eq_(datetime_to_commitdate(dt_utz(2011, 5, 22, 7, 24, 15)), + '2011-05-22T00:24:15-07:00') + eq_(datetime_to_commitdate(dt_utz(2011, 4, 9, 17, 7, 30)), + '2011-04-09T10:07:30-07:00') + eq_(datetime_to_commitdate(dt_utz(2011, 2, 19, 15, 16, 11)), + '2011-02-19T07:16:11-08:00') + eq_(datetime_to_commitdate(dt_utz(2010, 12, 21, 20, 34, 27)), + '2010-12-21T12:34:27-08:00') + eq_(datetime_to_commitdate(dt_utz(2011, 4, 9, 17, 20, 5)), + '2011-04-09T10:20:05-07:00') + eq_(datetime_to_commitdate(dt_utz(2011, 4, 9, 17, 5, 58)), + '2011-04-09T10:05:58-07:00') + eq_(datetime_to_commitdate(dt_utz(2011, 4, 9, 16, 53, 0)), + '2011-04-09T09:53:00-07:00') + eq_(datetime_to_commitdate(dt_utz(2011, 4, 9, 17, 0, 21)), + '2011-04-09T10:00:21-07:00') + eq_(datetime_to_commitdate(dt_utz(2010, 12, 16, 23, 10, 59)), + '2010-12-16T15:10:59-08:00') + eq_(datetime_to_commitdate(dt_utz(2011, 4, 9, 16, 53, 0)), + '2011-04-09T09:53:00-07:00') + eq_(datetime_to_commitdate(dt_utz(2011, 4, 9, 16, 53, 0)), + '2011-04-09T09:53:00-07:00') def test_isodate_to_datetime(): - assert_equals(string_to_datetime('2011-05-22T00:24:15Z'), - dt_utz(2011, 5, 22, 0, 24, 15)) - assert_equals(string_to_datetime('2011-04-09T10:07:30Z'), - dt_utz(2011, 4, 9, 10, 7, 30)) - assert_equals(string_to_datetime('2011-02-19T07:16:11Z'), - dt_utz(2011, 2, 19, 7, 16, 11)) - assert_equals(string_to_datetime('2010-12-21T12:34:27Z'), - dt_utz(2010, 12, 21, 12, 34, 27)) - assert_equals(string_to_datetime('2011-04-09T10:20:05Z'), - dt_utz(2011, 4, 9, 10, 20, 5)) - assert_equals(string_to_datetime('2011-04-09T10:05:58Z'), - dt_utz(2011, 4, 9, 10, 5, 58)) - assert_equals(string_to_datetime('2011-04-09T09:53:00Z'), - dt_utz(2011, 4, 9, 9, 53, 0)) - assert_equals(string_to_datetime('2011-04-09T10:00:21Z'), - dt_utz(2011, 4, 9, 10, 0, 21)) - assert_equals(string_to_datetime('2010-12-16T15:10:59Z'), - dt_utz(2010, 12, 16, 15, 10, 59)) - assert_equals(string_to_datetime('2011-04-09T09:53:00Z'), - dt_utz(2011, 4, 9, 9, 53, 0)) - assert_equals(string_to_datetime('2011-04-09T09:53:00Z'), - dt_utz(2011, 4, 9, 9, 53, 0)) + eq_(string_to_datetime('2011-05-22T00:24:15Z'), + dt_utz(2011, 5, 22, 0, 24, 15)) + eq_(string_to_datetime('2011-04-09T10:07:30Z'), + dt_utz(2011, 4, 9, 10, 7, 30)) + eq_(string_to_datetime('2011-02-19T07:16:11Z'), + dt_utz(2011, 2, 19, 7, 16, 11)) + eq_(string_to_datetime('2010-12-21T12:34:27Z'), + dt_utz(2010, 12, 21, 12, 34, 27)) + eq_(string_to_datetime('2011-04-09T10:20:05Z'), + dt_utz(2011, 4, 9, 10, 20, 5)) + eq_(string_to_datetime('2011-04-09T10:05:58Z'), + dt_utz(2011, 4, 9, 10, 5, 58)) + eq_(string_to_datetime('2011-04-09T09:53:00Z'), + dt_utz(2011, 4, 9, 9, 53, 0)) + eq_(string_to_datetime('2011-04-09T10:00:21Z'), + dt_utz(2011, 4, 9, 10, 0, 21)) + eq_(string_to_datetime('2010-12-16T15:10:59Z'), + dt_utz(2010, 12, 16, 15, 10, 59)) + eq_(string_to_datetime('2011-04-09T09:53:00Z'), + dt_utz(2011, 4, 9, 9, 53, 0)) + eq_(string_to_datetime('2011-04-09T09:53:00Z'), + dt_utz(2011, 4, 9, 9, 53, 0)) def test_datetime_to_isodate(): - assert_equals(datetime_to_isodate(dt_utz(2011, 5, 22, 0, 24, 15)), - '2011-05-22T00:24:15Z') - assert_equals(datetime_to_isodate(dt_utz(2011, 4, 9, 10, 7, 30)), - '2011-04-09T10:07:30Z') - assert_equals(datetime_to_isodate(dt_utz(2011, 2, 19, 7, 16, 11)), - '2011-02-19T07:16:11Z') - assert_equals(datetime_to_isodate(dt_utz(2010, 12, 21, 12, 34, 27)), - '2010-12-21T12:34:27Z') - assert_equals(datetime_to_isodate(dt_utz(2011, 4, 9, 10, 20, 5)), - '2011-04-09T10:20:05Z') - assert_equals(datetime_to_isodate(dt_utz(2011, 4, 9, 10, 5, 58)), - '2011-04-09T10:05:58Z') - assert_equals(datetime_to_isodate(dt_utz(2011, 4, 9, 9, 53, 0)), - '2011-04-09T09:53:00Z') - assert_equals(datetime_to_isodate(dt_utz(2011, 4, 9, 10, 0, 21)), - '2011-04-09T10:00:21Z') - assert_equals(datetime_to_isodate(dt_utz(2010, 12, 16, 15, 10, 59)), - '2010-12-16T15:10:59Z') - assert_equals(datetime_to_isodate(dt_utz(2011, 4, 9, 9, 53, 0)), - '2011-04-09T09:53:00Z') - assert_equals(datetime_to_isodate(dt_utz(2011, 4, 9, 9, 53, 0)), - '2011-04-09T09:53:00Z') + eq_(datetime_to_isodate(dt_utz(2011, 5, 22, 0, 24, 15)), + '2011-05-22T00:24:15Z') + eq_(datetime_to_isodate(dt_utz(2011, 4, 9, 10, 7, 30)), + '2011-04-09T10:07:30Z') + eq_(datetime_to_isodate(dt_utz(2011, 2, 19, 7, 16, 11)), + '2011-02-19T07:16:11Z') + eq_(datetime_to_isodate(dt_utz(2010, 12, 21, 12, 34, 27)), + '2010-12-21T12:34:27Z') + eq_(datetime_to_isodate(dt_utz(2011, 4, 9, 10, 20, 5)), + '2011-04-09T10:20:05Z') + eq_(datetime_to_isodate(dt_utz(2011, 4, 9, 10, 5, 58)), + '2011-04-09T10:05:58Z') + eq_(datetime_to_isodate(dt_utz(2011, 4, 9, 9, 53, 0)), + '2011-04-09T09:53:00Z') + eq_(datetime_to_isodate(dt_utz(2011, 4, 9, 10, 0, 21)), + '2011-04-09T10:00:21Z') + eq_(datetime_to_isodate(dt_utz(2010, 12, 16, 15, 10, 59)), + '2010-12-16T15:10:59Z') + eq_(datetime_to_isodate(dt_utz(2011, 4, 9, 9, 53, 0)), + '2011-04-09T09:53:00Z') + eq_(datetime_to_isodate(dt_utz(2011, 4, 9, 9, 53, 0)), + '2011-04-09T09:53:00Z') diff --git a/tests/test_unit.py b/tests/test_unit.py index f17f9a0..1769751 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -10,7 +10,7 @@ import datetime import unittest -from nose.tools import (assert_equals, assert_true) +from nose.tools import (eq_, assert_true) from github2.core import repr_string from github2.issues import Issue @@ -26,18 +26,18 @@ def test_issue(self): """Issues can have non-ASCII characters in the title.""" title = 'abcdé' i = Issue(title=title) - assert_equals(str, type(repr(i))) + eq_(str, type(repr(i))) class HostSetting(unittest.TestCase): def test_default_host(self): client = Github() - assert_equals(client.request.github_url, 'https://github.com') + eq_(client.request.github_url, 'https://github.com') def test_non_standard_host(self): client = Github(github_url="http://your-github-enterprise-url.com/") - assert_equals(client.request.github_url, - 'http://your-github-enterprise-url.com/') + eq_(client.request.github_url, + 'http://your-github-enterprise-url.com/') class RateLimits(utils.HttpMockTestCase): @@ -70,21 +70,21 @@ class BaseDataDict(utils.HttpMockTestCase): """Test __getitem__ availability on objects""" def test_getitem(self): user = self.client.users.show('defunkt') - assert_equals(user['blog'], user.blog) - assert_equals(user['company'], user.company) - assert_equals(user['email'], user.email) - assert_equals(user['location'], user.location) - assert_equals(user['login'], user.login) - assert_equals(user['name'], user.name) + eq_(user['blog'], user.blog) + eq_(user['company'], user.company) + eq_(user['email'], user.email) + eq_(user['location'], user.location) + eq_(user['login'], user.login) + eq_(user['name'], user.name) def test_project_for_user_repo(): client = Github() - assert_equals(client.project_for_user_repo('JNRowe', 'misc-overlay'), + eq_(client.project_for_user_repo('JNRowe', 'misc-overlay'), 'JNRowe/misc-overlay') def test_repr_string(): - assert_equals(repr_string('test'), 'test') - assert_equals(repr_string('abcdefghijklmnopqrst'), 'abcdefghijklmnopqrst') - assert_equals(repr_string('abcdefghijklmnopqrstu'), 'abcdefghijklmnopq...') + eq_(repr_string('test'), 'test') + eq_(repr_string('abcdefghijklmnopqrst'), 'abcdefghijklmnopqrst') + eq_(repr_string('abcdefghijklmnopqrstu'), 'abcdefghijklmnopq...') diff --git a/tests/test_user.py b/tests/test_user.py index 33929db..0d80359 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -5,7 +5,7 @@ import datetime -from nose.tools import (assert_equals, assert_false, assert_true) +from nose.tools import (eq_, assert_false, assert_true) import utils @@ -14,29 +14,28 @@ class UserProperties(utils.HttpMockTestCase): """Test user property handling""" def test_user(self): user = self.client.users.show('defunkt') - assert_equals(user.blog, 'http://chriswanstrath.com/') - assert_equals(user.company, 'GitHub') - assert_equals(user.email, 'chris@wanstrath.com') - assert_equals(user.location, 'San Francisco') - assert_equals(user.login, 'defunkt') - assert_equals(user.name, 'Chris Wanstrath') + eq_(user.blog, 'http://chriswanstrath.com/') + eq_(user.company, 'GitHub') + eq_(user.email, 'chris@wanstrath.com') + eq_(user.location, 'San Francisco') + eq_(user.login, 'defunkt') + eq_(user.name, 'Chris Wanstrath') def test_meta(self): user = self.client.users.show('defunkt') - assert_equals(user.created_at, - datetime.datetime(2007, 10, 19, 22, 24, 19)) - assert_equals(user.followers_count, 3402) - assert_equals(user.following_count, 212) - assert_equals(user.gravatar_id, 'b8dbb1987e8e5318584865f880036796') - assert_equals(user.id, 2) - assert_equals(user.public_gist_count, 278) - assert_equals(user.public_repo_count, 93) + eq_(user.created_at, datetime.datetime(2007, 10, 19, 22, 24, 19)) + eq_(user.followers_count, 3402) + eq_(user.following_count, 212) + eq_(user.gravatar_id, 'b8dbb1987e8e5318584865f880036796') + eq_(user.id, 2) + eq_(user.public_gist_count, 278) + eq_(user.public_repo_count, 93) def test_followers(self): - assert_equals(len(self.client.users.followers('defunkt')), 3402) + eq_(len(self.client.users.followers('defunkt')), 3402) def test_following(self): - assert_equals(len(self.client.users.following('defunkt')), 212) + eq_(len(self.client.users.following('defunkt')), 212) def test_is_not_authenticated(self): user = self.client.users.show('defunkt') @@ -46,12 +45,12 @@ def test_is_not_authenticated(self): class UserQueries(utils.HttpMockTestCase): """Test user querying """ def test_search(self): - assert_equals(repr(self.client.users.search('James Rowe')), - '[, ]') + eq_(repr(self.client.users.search('James Rowe')), + '[, ]') def test_search_by_email(self): user = self.client.users.search_by_email('jnrowe@gmail.com') - assert_equals(repr(user), '') + eq_(repr(user), '') class AuthenticatedUserMethods(utils.HttpMockAuthenticatedTestCase): @@ -69,21 +68,21 @@ def test_is_authenticated(self): def test_list_keys(self): keys = self.client.users.list_keys() - assert_equals(keys[0].id, 1337) + eq_(keys[0].id, 1337) class AuthenticatedUserProperties(utils.HttpMockAuthenticatedTestCase): def test_private_data(self): user = self.client.users.show('') - assert_equals(user.total_private_repo_count, 0) - assert_equals(user.collaborators, 0) - assert_equals(user.disk_usage, 66069) - assert_equals(user.owned_private_repo_count, 0) - assert_equals(user.private_gist_count, 7) + eq_(user.total_private_repo_count, 0) + eq_(user.collaborators, 0) + eq_(user.disk_usage, 66069) + eq_(user.owned_private_repo_count, 0) + eq_(user.private_gist_count, 7) def test_plan_data(self): user = self.client.users.show('') - assert_equals(user.plan['name'], "free") - assert_equals(user.plan['collaborators'], 0) - assert_equals(user.plan['space'], 307200) - assert_equals(user.plan['private_repos'], 0) + eq_(user.plan['name'], "free") + eq_(user.plan['collaborators'], 0) + eq_(user.plan['space'], 307200) + eq_(user.plan['private_repos'], 0) From 01fdd82966c044e17b8f786369197203ec8b8b8a Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 19:38:26 +0100 Subject: [PATCH 14/32] Use nose.tools.ok_ instead of assert_true. --- tests/test_organizations.py | 6 +++--- tests/test_unit.py | 10 +++++----- tests/test_user.py | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_organizations.py b/tests/test_organizations.py index 399d450..e2ddc77 100644 --- a/tests/test_organizations.py +++ b/tests/test_organizations.py @@ -5,7 +5,7 @@ from datetime import datetime -from nose.tools import (eq_, assert_true) +from nose.tools import (eq_, ok_) import utils @@ -31,9 +31,9 @@ def test_properties(self): def test_is_authenticated(self): organization = self.client.organizations.show('github') - assert_true(organization.is_authenticated() is False) + ok_(organization.is_authenticated() is False) organization = self.client.organizations.show('fake_org_with_auth') - assert_true(organization.is_authenticated() is True) + ok_(organization.is_authenticated() is True) class Organization(utils.HttpMockTestCase): diff --git a/tests/test_unit.py b/tests/test_unit.py index 1769751..ce93198 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -10,7 +10,7 @@ import datetime import unittest -from nose.tools import (eq_, assert_true) +from nose.tools import (eq_, ok_) from github2.core import repr_string from github2.issues import Issue @@ -53,9 +53,9 @@ def test_delays(self): delta = end - start delta_seconds = delta.days * 24 * 60 * 60 + delta.seconds - assert_true(delta_seconds >= 2, - "Expected .5 reqs per second to require a 2 second delay " - "between calls.") + ok_(delta_seconds >= 2, + "Expected .5 reqs per second to require a 2 second delay between " + "calls.") class BaseDataIter(utils.HttpMockTestCase): @@ -63,7 +63,7 @@ class BaseDataIter(utils.HttpMockTestCase): def test_iter(self): commit_id = '1c83cde9b5a7c396a01af1007fb7b88765b9ae45' commit = self.client.commits.show('ask/python-github2', commit_id) - assert_true('__iter__' in dir(commit)) + ok_('__iter__' in dir(commit)) class BaseDataDict(utils.HttpMockTestCase): diff --git a/tests/test_user.py b/tests/test_user.py index 0d80359..61fbc5c 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -5,7 +5,7 @@ import datetime -from nose.tools import (eq_, assert_false, assert_true) +from nose.tools import (eq_, assert_false, ok_) import utils @@ -39,7 +39,7 @@ def test_following(self): def test_is_not_authenticated(self): user = self.client.users.show('defunkt') - assert_true(user.is_authenticated() is False) + ok_(user.is_authenticated() is False) class UserQueries(utils.HttpMockTestCase): @@ -56,7 +56,7 @@ def test_search_by_email(self): class AuthenticatedUserMethods(utils.HttpMockAuthenticatedTestCase): def test_follow(self): result = self.client.users.follow('defunkt') - assert_true('defunkt' in result['users']) + ok_('defunkt' in result['users']) def test_unfollow(self): result = self.client.users.unfollow('defunkt') @@ -64,7 +64,7 @@ def test_unfollow(self): def test_is_authenticated(self): user = self.client.users.show('') - assert_true(user.is_authenticated() is True) + ok_(user.is_authenticated() is True) def test_list_keys(self): keys = self.client.users.list_keys() From bb968da0cc90dd60cf1709341a4b760d93a8405c Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 19:42:00 +0100 Subject: [PATCH 15/32] [QA] PEP 257 fixes to tests. --- tests/test_commits.py | 5 ++++- tests/test_issues.py | 4 +++- tests/test_regression.py | 2 +- tests/test_repositories.py | 4 +++- tests/test_request.py | 4 +++- tests/test_tz_aware_date_handling.py | 7 ++++--- tests/test_unit.py | 15 +++++++++++---- tests/test_user.py | 8 ++++++-- tests/utils.py | 14 +++++++++----- 9 files changed, 44 insertions(+), 19 deletions(-) diff --git a/tests/test_commits.py b/tests/test_commits.py index 33f037c..b27fbd3 100644 --- a/tests/test_commits.py +++ b/tests/test_commits.py @@ -11,7 +11,9 @@ class CommitProperties(utils.HttpMockTestCase): - """Test commit property handling""" + + """Test commit property handling.""" + commit_id = '1c83cde9b5a7c396a01af1007fb7b88765b9ae45' def test_commit(self): @@ -38,6 +40,7 @@ def test_repr(self): class CommitsQueries(utils.HttpMockTestCase): + """Test commit querying""" def test_list(self): diff --git a/tests/test_issues.py b/tests/test_issues.py index 2abf495..67cbff7 100644 --- a/tests/test_issues.py +++ b/tests/test_issues.py @@ -52,7 +52,9 @@ def test_comment_repr(self): class IssueQueries(utils.HttpMockTestCase): - """Test issue querying""" + + """Test issue querying.""" + def test_search(self): issues = self.client.issues.search('ask/python-github2', 'timezone', 'closed') diff --git a/tests/test_regression.py b/tests/test_regression.py index d5ff091..d9de696 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -13,7 +13,7 @@ def test_issue_50(): - """Erroneous init of ``Http`` with proxy setup + """Erroneous init of ``Http`` with proxy setup. See https://github.com/ask/python-github2/pull/50 """ diff --git a/tests/test_repositories.py b/tests/test_repositories.py index 39017df..8abbc30 100644 --- a/tests/test_repositories.py +++ b/tests/test_repositories.py @@ -19,7 +19,9 @@ def test_repr(self): class RepoProperties(utils.HttpMockTestCase): - """Test repository property handling""" + + """Test repository property handling.""" + def test_repo(self): repo = self.client.repos.show('JNRowe/misc-overlay') diff --git a/tests/test_request.py b/tests/test_request.py index 0833c00..529de26 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -35,7 +35,9 @@ def assert_params_contain(first, second): class TestAuthEncode(unittest.TestCase): - """Test processing of authentication data""" + + """Test processing of authentication data.""" + def setUp(self): self.r = request.GithubRequest() diff --git a/tests/test_tz_aware_date_handling.py b/tests/test_tz_aware_date_handling.py index 77302ba..c2b152f 100644 --- a/tests/test_tz_aware_date_handling.py +++ b/tests/test_tz_aware_date_handling.py @@ -15,19 +15,20 @@ def setup_module(): - """Enable timezone-aware datetime handling for this module's tests""" + """Enable timezone-aware datetime handling for this module's tests.""" core.NAIVE = False def teardown_module(): - """Disable timezone-aware datetime handling when tests have completed""" + """Disable timezone-aware datetime handling when tests have completed.""" core.NAIVE = True def dt_utz(year, month, day, hour, minute, second): - """Produce a UTC-anchored datetime object + """Produce a UTC-anchored datetime object. :see: :class:`datetime.datetime` + """ return dt(year, month, day, hour, minute, second, tzinfo=tzutc()) diff --git a/tests/test_unit.py b/tests/test_unit.py index ce93198..2095952 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -20,6 +20,7 @@ class ReprTests(unittest.TestCase): + """__repr__ must return strings, not unicode objects.""" def test_issue(self): @@ -41,9 +42,11 @@ def test_non_standard_host(self): class RateLimits(utils.HttpMockTestCase): - """Test API rate-limitting""" + + """Test API rate-limitting.""" + def test_delays(self): - """Test call delay is at least one second""" + """Test call delay is at least one second.""" client = Github(requests_per_second=.5) client.users.show('defunkt') start = datetime.datetime.utcnow() @@ -59,7 +62,9 @@ def test_delays(self): class BaseDataIter(utils.HttpMockTestCase): - """Test iter availability of objects""" + + """Test iter availability of objects.""" + def test_iter(self): commit_id = '1c83cde9b5a7c396a01af1007fb7b88765b9ae45' commit = self.client.commits.show('ask/python-github2', commit_id) @@ -67,7 +72,9 @@ def test_iter(self): class BaseDataDict(utils.HttpMockTestCase): - """Test __getitem__ availability on objects""" + + """Test __getitem__ availability on objects.""" + def test_getitem(self): user = self.client.users.show('defunkt') eq_(user['blog'], user.blog) diff --git a/tests/test_user.py b/tests/test_user.py index 61fbc5c..c2fab11 100644 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -11,7 +11,9 @@ class UserProperties(utils.HttpMockTestCase): - """Test user property handling""" + + """Test user property handling.""" + def test_user(self): user = self.client.users.show('defunkt') eq_(user.blog, 'http://chriswanstrath.com/') @@ -43,7 +45,9 @@ def test_is_not_authenticated(self): class UserQueries(utils.HttpMockTestCase): - """Test user querying """ + + """Test user querying.""" + def test_search(self): eq_(repr(self.client.users.search('James Rowe')), '[, ]') diff --git a/tests/utils.py b/tests/utils.py index 598b068..1b38949 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -25,9 +25,10 @@ class HttpMock(object): - """Simple Http mock that returns saved entries + """Simple Http mock that returns saved entries. + + Implementation tests should never span network boundaries. - Implementation tests should never span network boundaries """ def __init__(self, cache=None, timeout=None, proxy_info=None, @@ -55,33 +56,36 @@ def request(self, uri, method='GET', body=None, headers=None, class HttpMockTestCase(unittest.TestCase): def setUp(self): - """Prepare test fixtures + """Prepare test fixtures. `httplib2.Http` is patched to return cached entries via :class:`HttpMock`. :attr:`client` is an unauthenticated :obj:`Github` object for easy use in tests. + """ httplib2.Http = HttpMock self.client = Github() def tearDown(self): - """Remove test fixtures + """Remove test fixtures. `httplib2.Http` is returned to its original state. + """ httplib2.Http = ORIG_HTTP_OBJECT class HttpMockAuthenticatedTestCase(HttpMockTestCase): def setUp(self): - """Prepare test fixtures + """Prepare test fixtures. :see: :class:`HttpMockTestCase` :attr:`client` is an authenticated :obj:`Github` object for easy use in tests. + """ httplib2.Http = HttpMock self.client = Github(access_token='xxx') From 0010b09bb1d4b71ef98b55c67bbe8249557df394 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 19:42:29 +0100 Subject: [PATCH 16/32] Mark rate limit test with 'slow' attribute. --- tests/test_unit.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_unit.py b/tests/test_unit.py index 2095952..5a5b55c 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -11,6 +11,7 @@ import unittest from nose.tools import (eq_, ok_) +from nose.plugins.attrib import attr from github2.core import repr_string from github2.issues import Issue @@ -45,6 +46,7 @@ class RateLimits(utils.HttpMockTestCase): """Test API rate-limitting.""" + @attr('slow') def test_delays(self): """Test call delay is at least one second.""" client = Github(requests_per_second=.5) From e1b7047a1439346c1d5a83cb497b0c1478cfd73d Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 19:43:10 +0100 Subject: [PATCH 17/32] Rewrite issue 50 test without using Http mock. --- tests/test_regression.py | 14 ++++---------- tests/utils.py | 11 ++--------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/tests/test_regression.py b/tests/test_regression.py index d9de696..b5fee60 100644 --- a/tests/test_regression.py +++ b/tests/test_regression.py @@ -9,20 +9,14 @@ from github2.client import Github -import utils - def test_issue_50(): """Erroneous init of ``Http`` with proxy setup. See https://github.com/ask/python-github2/pull/50 """ - utils.set_http_mock() - client = Github(proxy_host="my.proxy.com", proxy_port=9000) - setup_args = client.request._http.called_with - eq_(type(setup_args['proxy_info']), httplib2.ProxyInfo) - eq_(setup_args['proxy_info'].proxy_host, 'my.proxy.com') - eq_(setup_args['proxy_info'].proxy_port, 9000) - - utils.unset_http_mock() + proxy_info = client.request._http.proxy_info + eq_(type(proxy_info), httplib2.ProxyInfo) + eq_(proxy_info.proxy_host, 'my.proxy.com') + eq_(proxy_info.proxy_port, 9000) diff --git a/tests/utils.py b/tests/utils.py index 1b38949..e66284b 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -31,15 +31,8 @@ class HttpMock(object): """ - def __init__(self, cache=None, timeout=None, proxy_info=None, - ca_certs=None): - """Create a mock httplib.Http object - - .. attribute: called_with - - ``locals()`` during ``__init__``, for testing call spec - """ - self.called_with = locals() + def __init__(self, *args, **kwargs): + pass def request(self, uri, method='GET', body=None, headers=None, redirections=5, connection_type=None): From 6035cc3784543650fa8c9a731908c1b49d327cb4 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 19:45:03 +0100 Subject: [PATCH 18/32] Http mocking switched to use mock.Mock object. --- extra/requirements-test.txt | 1 + tests/utils.py | 58 +++++++++++++------------------------ 2 files changed, 21 insertions(+), 38 deletions(-) diff --git a/extra/requirements-test.txt b/extra/requirements-test.txt index c8d6b88..d271169 100644 --- a/extra/requirements-test.txt +++ b/extra/requirements-test.txt @@ -1,3 +1,4 @@ -r requirements.txt coverage>=3.5 +mock>=0.7.1 nose>=1.1.2 diff --git a/tests/utils.py b/tests/utils.py index e66284b..313836e 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -11,6 +11,8 @@ import httplib2 +from mock import Mock + from github2.client import Github from github2.request import charset_from_headers @@ -19,32 +21,26 @@ bytes = lambda x, enc: x -HTTP_DATA_DIR = "tests/data/" - -ORIG_HTTP_OBJECT = httplib2.Http +ORIG_REQUEST_METHOD = httplib2.Http.request -class HttpMock(object): - """Simple Http mock that returns saved entries. +def request_mock(uri, method='GET', body=None, headers=None, + redirections=5, connection_type=None): + """Http mock side effect that returns saved entries. Implementation tests should never span network boundaries. """ - def __init__(self, *args, **kwargs): - pass - - def request(self, uri, method='GET', body=None, headers=None, - redirections=5, connection_type=None): - file = os.path.join(HTTP_DATA_DIR, httplib2.safename(uri)) - if os.path.exists(file): - response = message_from_file(open(file)) - headers = httplib2.Response(response) - body = bytes(response.get_payload(), charset_from_headers(headers)) - return (headers, body) - else: - return (httplib2.Response({"status": "404"}), - "Resource %r unavailable from test data store" % file) + file = os.path.join("tests/data", httplib2.safename(uri)) + if os.path.exists(file): + response = message_from_file(open(file)) + headers = httplib2.Response(response) + body = bytes(response.get_payload(), charset_from_headers(headers)) + return (headers, body) + else: + return (httplib2.Response({"status": "404"}), + "Resource %r unavailable from test data store" % file) class HttpMockTestCase(unittest.TestCase): @@ -58,7 +54,8 @@ def setUp(self): in tests. """ - httplib2.Http = HttpMock + httplib2.Http.request = Mock(spec_set=httplib2.Http.request, + side_effect=request_mock) self.client = Github() def tearDown(self): @@ -67,7 +64,7 @@ def tearDown(self): `httplib2.Http` is returned to its original state. """ - httplib2.Http = ORIG_HTTP_OBJECT + httplib2.Http.request = ORIG_REQUEST_METHOD class HttpMockAuthenticatedTestCase(HttpMockTestCase): @@ -80,21 +77,6 @@ def setUp(self): in tests. """ - httplib2.Http = HttpMock + httplib2.Http.request = Mock(spec_set=httplib2.Http.request, + side_effect=request_mock) self.client = Github(access_token='xxx') - - -def set_http_mock(): - """Function to enable ``Http`` mock - - This is useful in simple `nose`-compliant test functions - """ - httplib2.Http = HttpMock - - -def unset_http_mock(): - """Function to disable ``Http`` mock - - :see: :func:`set_http_mock` - """ - httplib2.Http = ORIG_HTTP_OBJECT From 62472a34b18636219c286e2b9770ed8b4cfae5c6 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 20:48:07 +0100 Subject: [PATCH 19/32] Added test for requires_auth decorator. --- tests/test_unit.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/test_unit.py b/tests/test_unit.py index 5a5b55c..988d8d6 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -10,10 +10,10 @@ import datetime import unittest -from nose.tools import (eq_, ok_) +from nose.tools import (eq_, ok_, raises) from nose.plugins.attrib import attr -from github2.core import repr_string +from github2.core import (AuthError, repr_string, requires_auth) from github2.issues import Issue from github2.client import Github @@ -97,3 +97,12 @@ def test_repr_string(): eq_(repr_string('test'), 'test') eq_(repr_string('abcdefghijklmnopqrst'), 'abcdefghijklmnopqrst') eq_(repr_string('abcdefghijklmnopqrstu'), 'abcdefghijklmnopq...') + + +class RequiresAuth(utils.HttpMockTestCase): + @raises(AuthError) + def test_no_auth(self): + f = lambda: None + f.__doc__ = 'test func' + wrapped = requires_auth(f) + wrapped(self.client) From fd2a2ba8196a7150fa90cb882fd6806265bc8f3e Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 20:59:13 +0100 Subject: [PATCH 20/32] Added BaseData dict key failure test. --- tests/test_unit.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_unit.py b/tests/test_unit.py index 988d8d6..50312d0 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -86,6 +86,11 @@ def test_getitem(self): eq_(user['login'], user.login) eq_(user['name'], user.name) + @raises(KeyError) + def test_getitem_failure(self): + user = self.client.users.show('defunkt') + ok_(user['invalid_key']) + def test_project_for_user_repo(): client = Github() From fbe6e453a5d828c9317642f5647ea47e32da4670 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 21:07:25 +0100 Subject: [PATCH 21/32] Added BaseData dict setting tests. --- tests/test_unit.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_unit.py b/tests/test_unit.py index 50312d0..d49dc38 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -75,7 +75,7 @@ def test_iter(self): class BaseDataDict(utils.HttpMockTestCase): - """Test __getitem__ availability on objects.""" + """Test dict compatibility on objects.""" def test_getitem(self): user = self.client.users.show('defunkt') @@ -91,6 +91,16 @@ def test_getitem_failure(self): user = self.client.users.show('defunkt') ok_(user['invalid_key']) + def test_setitem(self): + user = self.client.users.show('defunkt') + user['blog'] = 'http://example.com' + eq_(user['blog'], 'http://example.com') + + @raises(KeyError) + def test_setitem_failure(self): + user = self.client.users.show('defunkt') + user['invalid_key'] = 'test' + def test_project_for_user_repo(): client = Github() From 5c60b01d58359da94c11c4e8cd016050185a8fa8 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 21:54:45 +0100 Subject: [PATCH 22/32] Use mock for sleep in rate limit tests. --- tests/test_unit.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tests/test_unit.py b/tests/test_unit.py index d49dc38..104256d 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -7,11 +7,10 @@ # This file is part of python-github2, and is made available under the 3-clause # BSD license. See LICENSE for the full details. -import datetime import unittest +from mock import patch from nose.tools import (eq_, ok_, raises) -from nose.plugins.attrib import attr from github2.core import (AuthError, repr_string, requires_auth) from github2.issues import Issue @@ -44,23 +43,17 @@ def test_non_standard_host(self): class RateLimits(utils.HttpMockTestCase): - """Test API rate-limitting.""" + """Test API rate-limiting.""" - @attr('slow') - def test_delays(self): - """Test call delay is at least one second.""" + @patch('github2.request.time.sleep') + def test_delays(self, sleep): + """Test calls in quick succession are delayed.""" client = Github(requests_per_second=.5) client.users.show('defunkt') - start = datetime.datetime.utcnow() client.users.show('mojombo') - end = datetime.datetime.utcnow() - delta = end - start - delta_seconds = delta.days * 24 * 60 * 60 + delta.seconds - - ok_(delta_seconds >= 2, - "Expected .5 reqs per second to require a 2 second delay between " - "calls.") + # 0.5 requests per second, means a two second delay + sleep.assert_called_once_with(2.0) class BaseDataIter(utils.HttpMockTestCase): From 614d8b25f49af6d29ad77aa529a0e7cb09b41bb8 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 21:56:30 +0100 Subject: [PATCH 23/32] Fix BaseData dict compat logging. --- github2/core.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/github2/core.py b/github2/core.py index f1629fd..86d4788 100644 --- a/github2/core.py +++ b/github2/core.py @@ -364,8 +364,7 @@ def __getitem__(self, key): """ LOGGER.warning("Subscript access on %r is deprecated, use object " - "attributes" % self.__class__.__name__, - DeprecationWarning) + "attributes" % self.__class__.__name__) if not key in self._meta.keys(): raise KeyError(key) return getattr(self, key) @@ -377,8 +376,7 @@ def __setitem__(self, key, value): """ LOGGER.warning("Subscript access on %r is deprecated, use object " - "attributes" % self.__class__.__name__, - DeprecationWarning) + "attributes" % self.__class__.__name__) if not key in self._meta.keys(): raise KeyError(key) setattr(self, key, value) From 32a076965d578fb62208939e9b8f5711df1e3e9e Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 16 May 2012 21:57:55 +0100 Subject: [PATCH 24/32] Handle symlinked certificate bundles for httplib2, --- github2/request.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/github2/request.py b/github2/request.py index 31afa78..1314c77 100644 --- a/github2/request.py +++ b/github2/request.py @@ -59,8 +59,12 @@ #: Logger for requests module LOGGER = logging.getLogger('github2.request') +# Fetch actual path for httplib2's default cert bundle, for distributions that +# symlink their system certs +_HTTPLIB2_BUNDLE = path.realpath(path.dirname(httplib2.CA_CERTS)) #: Whether github2 is using the system's certificates for SSL connections -SYSTEM_CERTS = not httplib2.CA_CERTS.startswith(path.dirname(httplib2.__file__)) +SYSTEM_CERTS = not _HTTPLIB2_BUNDLE.startswith(path.dirname(httplib2.__file__)) +CA_CERTS = None #: Whether github2 is using the cert's from the file given in $CURL_CA_BUNDLE CURL_CERTS = False if not SYSTEM_CERTS and sys.platform.startswith('linux'): From 55d92f3268163c3bef902bdb06be706993dd33b5 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 23 May 2012 05:52:51 +0100 Subject: [PATCH 25/32] Updated dependency information for dateutil-2.1 support. This has become quite messy, to the point that I had a little look for a hackable replacement. --- doc/install.rst | 5 +++-- extra/requirements-py25.txt | 5 +++-- extra/requirements-py3.txt | 2 -- extra/requirements.txt | 4 ++-- setup.py | 10 +++++++--- 5 files changed, 15 insertions(+), 11 deletions(-) delete mode 100644 extra/requirements-py3.txt diff --git a/doc/install.rst b/doc/install.rst index 84b57de..7eb1aa6 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -33,5 +33,6 @@ handling [#]_. :pypi:`simplejson` is also required when using :mod:`github2` with Python 2.4 or 2.5. If you install via :pypi:`pip` or :pypi:`easy_install ` the dependencies should be installed automatically for you. -.. [#] You must use :pypi:`python-dateutil` 1.x when working with Python 2.x, - the latest 2.x releases are for Python 3.x installations only. +.. [#] You must use :pypi:`python-dateutil` 1.x when working with Python 2.5 or + earlier, the latest 2.x releases are for Python 2.6 and newer + installations only. diff --git a/extra/requirements-py25.txt b/extra/requirements-py25.txt index 33f97ee..45bfac5 100644 --- a/extra/requirements-py25.txt +++ b/extra/requirements-py25.txt @@ -1,2 +1,3 @@ --r requirements.txt -simplejson>=2.0.9 +httplib2 >= 0.7.0 +python-dateutil < 2.0, >= 2.1 +simplejson >= 2.0.9 diff --git a/extra/requirements-py3.txt b/extra/requirements-py3.txt deleted file mode 100644 index 457b3fb..0000000 --- a/extra/requirements-py3.txt +++ /dev/null @@ -1,2 +0,0 @@ -httplib2>=0.7.0 -python-dateutil>=2.0 diff --git a/extra/requirements.txt b/extra/requirements.txt index 57c76c4..5115300 100644 --- a/extra/requirements.txt +++ b/extra/requirements.txt @@ -1,2 +1,2 @@ -httplib2>=0.7.0 -python-dateutil<2.0 +httplib2 >= 0.7.0 +python-dateutil < 2.0 diff --git a/setup.py b/setup.py index 06c56bb..72073f5 100755 --- a/setup.py +++ b/setup.py @@ -23,10 +23,14 @@ if sys.version_info[:2] < (2, 6): install_requires.append('simplejson >= 2.0.9') -if sys.version_info >= (3,): - install_requires.append('python-dateutil >= 2.0') -else: +# dateutil supports python 2.x in dateutil-1, python 3.x in dateutil-2.0 and +# python 2.6+ in dateutil-2.1. Exciting… +if sys.version_info[:2] <= (2, 5): install_requires.append('python-dateutil < 2.0') +elif sys.version_info < (3, ): + install_requires.append('python-dateutil < 2.0, >= 2.1') +else: + install_requires.append('python-dateutil > 2.0') long_description = (codecs.open('README.rst', "r", "utf-8").read() + "\n" + codecs.open('NEWS.rst', "r", "utf-8").read()) From a77c23a85a1f2eacebd0697608bbe510e3ee775c Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 23 May 2012 07:52:17 +0100 Subject: [PATCH 26/32] Fixed simplejson dependency for Python 2.4. Recent versions of simplejson no longer support Python 2.4. --- setup.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 72073f5..b72d775 100755 --- a/setup.py +++ b/setup.py @@ -19,8 +19,12 @@ install_requires = ['httplib2 >= 0.7.0', ] -# simplejson is included in the standard library since Python 2.6 as json. -if sys.version_info[:2] < (2, 6): + +# simplejson is included in the standard library since Python 2.6 as json +if sys.version_info < (2, 5): + # 2.1 drops support for 2.4 + install_requires.append('simplejson >= 2.0.9, < 2.1') +elif sys.version_info[:2] < (2, 6): install_requires.append('simplejson >= 2.0.9') # dateutil supports python 2.x in dateutil-1, python 3.x in dateutil-2.0 and From bad4e74bf58ad3d4c964070a54304a67ff8b4b09 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Wed, 23 May 2012 07:52:46 +0100 Subject: [PATCH 27/32] Re-sync dependencies in tox config. --- tox.ini | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tox.ini b/tox.ini index 531bac9..ffb9775 100644 --- a/tox.ini +++ b/tox.ini @@ -6,8 +6,28 @@ envlist = py24, py25, py26, py27, py31, py32, rst, sphinx deps = nose coverage + mock commands = nosetests {posargs:-vv} tests +# When tox 1.4 is released use substitution to remove all the duplication. +[testenv:py24] +deps = + nose + coverage + mock + unittest2 +[testenv:py25] +deps = + nose + coverage + mock + unittest2 +[testenv:py26] +deps = + nose + coverage + mock + unittest2 [testenv:rst] deps = docutils From 46020575a632f1a4b78c878c84d40e1400ccd42c Mon Sep 17 00:00:00 2001 From: James Rowe Date: Mon, 11 Jun 2012 13:08:14 +0100 Subject: [PATCH 28/32] Rewording of the API v3 migration note. There has been a reprieve for the API v2 switch-off, and the note from 3414c22d25a54624e554be5bdb8a6fb327ff27d7 is no longer as urgent. --- README.rst | 5 ++--- doc/index.rst | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index a266014..b3897ef 100644 --- a/README.rst +++ b/README.rst @@ -8,8 +8,8 @@ github2 - GitHub API v2 library for Python. .. warning:: - GitHub are planning to `switch off API v2`_ on 2012-05-01, you should - be looking to replace ``github2`` as soon as possible. + GitHub have marked API v2 as deprecated, you should be looking to replace + your usage of ``github2`` in the near future. Both remoteobjects_ and micromodels_ provide easy-to-use functionality for creating bindings to remote APIs, and should significantly reduce the amount @@ -21,7 +21,6 @@ of the `GitHub API`_. See the ``doc/`` directory for installation instructions and usage information. If you prefer you can also read the `documentation online`_. -.. _switch off API v2: https://github.com/blog/1090-github-api-moving-on .. _remoteobjects: https://github.com/saymedia/remoteobjects .. _micromodels: https://github.com/j4mie/micromodels .. _GitHub API: http://develop.github.com/ diff --git a/doc/index.rst b/doc/index.rst index d909c02..963e6a2 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -16,14 +16,13 @@ .. warning:: - GitHub are planning to `switch off API v2`_ on 2012-05-01, you should - be looking to replace ``github2`` as soon as possible. + GitHub have marked API v2 as deprecated, you should be looking to replace + your usage of ``github2`` in the near future. Both remoteobjects_ and micromodels_ provide easy-to-use functionality for creating bindings to remote APIs, and should significantly reduce the amount of work needed in moving away from GitHub's API v2. -.. _switch off API v2: https://github.com/blog/1090-github-api-moving-on .. _remoteobjects: https://github.com/saymedia/remoteobjects .. _micromodels: https://github.com/j4mie/micromodels From 8647c559ceb9b0ecd3af68e728e36fb2de4b6ab2 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Mon, 11 Jun 2012 13:09:34 +0100 Subject: [PATCH 29/32] Minor fixes to quickstart doc. This makes the usage far closer to what a user would expect in an interactive session. --- doc/quickstart.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/quickstart.rst b/doc/quickstart.rst index 2d3988f..ff54b29 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -13,6 +13,7 @@ package. Create an unauthenticated client object:: + >>> from github2.client import Github >>> github = Github() .. note:: @@ -28,6 +29,7 @@ Read the description of the ``python-github2`` project:: >>> repo = github.repos.show("ask/python-github2") >>> repo.description + u'github client in python, with issues support.' We can take advantage of Python's :func:`dir` to explore the package a little more:: From 698394fa0d5e03ca43a02dccd4ce6a2f553576f5 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Mon, 11 Jun 2012 13:22:19 +0100 Subject: [PATCH 30/32] Include ChangeLog in sdist generated tarballs. --- MANIFEST.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index ac52cc3..e77f35d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,6 @@ recursive-include examples * + +include ChangeLog include NEWS.rst include README.rst include AUTHORS From 587f415607426a1eb1ab8e13f8ea0031525d3de6 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Mon, 11 Jun 2012 13:46:39 +0100 Subject: [PATCH 31/32] Bumped version to 0.6.2. --- NEWS.rst | 6 ++++++ README.rst | 2 +- github2/_version.py | 14 +++++++------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index e7092fe..eaa874c 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -6,6 +6,12 @@ look at the `git repository`_ for the full project history. .. _git repository: https://github.com/ask/python-github2/ +0.6.2 - 2012-06-11 +------------------ + +* Updated dependencies to handle recent ``python-dateutil`` releases +* Fixed ``simplejson`` dependencies for Python 2.4 + 0.6.1 - 2012-02-28 ------------------ diff --git a/README.rst b/README.rst index b3897ef..a91633f 100644 --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ github2 - GitHub API v2 library for Python. :Authors: Ask Solem (askh@opera.com) -:Version: 0.6.1 +:Version: 0.6.2 .. warning:: diff --git a/github2/_version.py b/github2/_version.py index 0269a27..6e26b1f 100644 --- a/github2/_version.py +++ b/github2/_version.py @@ -1,9 +1,9 @@ -# This is github2 version 0.6.1 (2012-02-28) +# This is github2 version 0.6.2 (2012-06-11) # pylint: disable=C0103, C0111, C0121, W0622 -dotted = "0.6.1" -libtool = "6:21" -hex = 0x000601 -date = "2012-02-28" -tuple = (0, 6, 1) -web = "github2/0.6.1" +dotted = "0.6.2" +libtool = "6:22" +hex = 0x000602 +date = "2012-06-11" +tuple = (0, 6, 2) +web = "github2/0.6.2" From 4287019520643e2fcd46c9c5b3aac439cdc35b88 Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Tue, 20 Jul 2021 07:48:23 +1000 Subject: [PATCH 32/32] docs: Fix a few typos (#82) There are small typos in: - github2/client.py - github2/request.py Fixes: - Should read `specific` rather than `specifc`. - Should read `occurred` rather than `occured`. --- github2/client.py | 2 +- github2/request.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/github2/client.py b/github2/client.py index 56b5dcd..d0a3f2b 100644 --- a/github2/client.py +++ b/github2/client.py @@ -107,7 +107,7 @@ def get_blob_info(self, project, tree_sha, path): return blob.get("blob") def get_tree(self, project, tree_sha): - """Get tree information for a specifc tree. + """Get tree information for a specific tree. :param str project: GitHub project :param str tree_sha: object ID of tree diff --git a/github2/request.py b/github2/request.py index 1314c77..5961471 100644 --- a/github2/request.py +++ b/github2/request.py @@ -113,7 +113,7 @@ class GithubError(Exception): class HttpError(RuntimeError): - """A HTTP error occured when making a request to the GitHub API.""" + """A HTTP error occurred when making a request to the GitHub API.""" def __init__(self, message, content, code): """Create a HttpError exception.