Commit Graph
999 Commits
Author SHA1 Message Date
Steve Kowalik 21e89ff1f8 Deprecate Repository.get_dir_contents() (#1285)
Repository.get_contents() and Repository.get_dir_contents() call the
same endpoint, with slightly different error handling, and with the
difference that get_dir_contents() throws an odd exception if you call
it with a file. get_contents() already even handles being called for a
directory anyway, so deprecate get_dir_contents(), and refactor the code
so the tests pass.

Fixes #1283
2019-11-14 22:17:34 +11:00
Adam Baratz ac68274200 Expand Topic class and add test coverage (#1252)
* Expand Topic class and add test coverage

* Add test coverage for Topic properties

* Fix misspelling in comment
2019-11-04 15:06:52 +11:00
Adam Baratz ec3c8d7b3b Add support for team discussions (#1246) (#1249)
* Add support for team discussions (#1246)

* Make a TeamDiscussion completeable
2019-10-31 21:19:10 +11:00
Steve Kowalik 077c80ba2d Correct API for NamedUser.get_organization_membership (#1277)
NamedUser.get_organization_membership() was calling the API method for
fetching the currently authenticated user only, which is incorrect. The
method was not tested directly, so add tests.  Furthermore, Membership
had some errors which had slipped through review, so correct them.

Sadly, this is an API break, since passing the organization as an int
made no sense in this case.

Fixes #1276
2019-10-31 20:56:46 +11:00
Steve Kowalik 6ad592b1b6 Correct header check for 2FA required (#1274)
Currently, we were checking for an uppercase header if GitHub was
refusing our authentication because we didn't provide a token. Requests
returns headers with all lowercase. Fix the const, and add a test for
good measure.

Fixes #1273
2019-10-25 21:01:58 +11:00
Pavan Kunisetty a163ba1562 Add assignee removal/addition support to PRs (#1241)
Add assignee removal/addition support to PRs
Fixes #1109

Add test for new PR assignee functionality

Add record file

Addressed comments on #1016
2019-10-22 21:34:55 +11:00
Steve Kowalik bc225f9d11 Encode content for {create,update}_file (#1267)
If a byte object (for Python 3) was passed into either create_file or
update_file, it was attempted to be co-erced into a bytearray, which
failed. Check for encoded content before we encode it into bytes and
then base64 encode it.

Fixes #1266
2019-10-22 21:30:34 +11:00
Adam Baratz a076508370 Stop ignoring unused imports and remove them (#1250)
* Stop ignoring unused imports and remove them

* Stop ignoring * imports
2019-10-19 16:43:14 +11:00
Pavan Kunisetty e50420f771 Implemented user organization membership. Added test case. (#1237)
1. Added AuthenticatedUser:get_organization_membership
2. Added NamedUser:get_organization_membership
3. Added related tests as GitMembership and related replay data
2019-10-03 22:33:06 +10:00
Steve Kowalik e33858a3dc Support non-default URLs in GithubIntegration (#1229)
The get_installation() method of GithubIntegration was hardcoded to
always use the default URL of api.github.com, making it impossible to
fetch the installation of an GitHub Enterprise installation.
2019-09-25 23:01:31 +10:00
Steve Kowalik 89c967bb77 Cleanup try/except import in PaginatedList (#1228)
Since we're using six.moves to import parse_qs, we don't need to check
for an import exception, we can just import it directly.
2019-09-25 15:22:06 +10:00
Steve Kowalik f91cbac2e3 Add an IncompletableObject exception (#1227)
If a returned object from GitHub does not include an URL, that object
can not be completed, and used to fail with an obscure traceback saying
NoneType has no method startswith. Check for this, and raise
IncompletableObject instead.
2019-09-23 16:40:06 +10:00
Jake Klingensmith 850da5af27 Fix redundant int checks (#1226) 2019-09-23 16:28:07 +10:00
Olof-Joachim Frahm (欧雅福) 020fbebcaf Jump from notifications to related PRs/issues. (#1168)
* Jump from notifications to related PRs/issues.

* Add test case for jumping to related PRs/issues.

Also another method to get notifications scoped to a repository,
otherwise it's hard to keep out sensitive information from the test
cases.
2019-09-22 18:59:21 +10:00
Olof-Joachim Frahm (欧雅福) b84d9b1928 Code review bodies are optional in some cases. (#1169)
* Code review bodies are optional in some cases.

* Add test for approving PRs without body set.
2019-09-20 11:00:07 +10:00
Steve Kowalik a0f01cf9cf Remove more Python version specific code (#1193)
Remove a bunch of other call sites that behaved differently between
Python 2 and 3, massively cleaning up a few messy methods.
2019-08-28 15:24:54 +10:00
Olof-Joachim Frahm (欧雅福) e90cdab06d Fix PR review creation. (#1184)
Do not modify the attributes of a PR when creating a review.
2019-08-09 19:12:55 +10:00
Will Li 8abd50e225 Add support to vulnerability alert and automated security fixes APIs (#1195)
* Add functions about automated security fixes and vulnerability alerts

* Refine methods and add unit test

* Add record

* Update record file  - change user name

* Add get vulnerability alert function

* Fix typo

* Create file for testCreateFile

* Add tests

* Add unit test

* Simplify assert statement
2019-08-08 12:24:33 +10:00
Steve Kowalik 7ddb657d47 Delete Legacy submodule (#1192)
Since the only part of the Legacy submodule that is used and tested is
the transform issue function, refactor it into a Repository method and
delete it.
2019-08-06 15:16:07 +10:00
Steve Kowalik cca8e3a5b4 Remove some uses of atLeastPython3 (#1191)
There are a number of call sites that would behave differently depending
on Python 2 or 3. A fair amount of them are left over from Python 3.2 or
Python 2.6 were the current versions, and it was much harder to write
compatible code for both versions. Happily, that is now in the past, so
refactor some of them out.
2019-08-05 16:14:39 +10:00
Steve Kowalik f93207b4ca Run flake8 in Travis (#1163)
Clean up a few errors I missed, ignore another, and configure flake8 using
a config file to ignore certain errors. The next step would be to remove
the F* ignores.
2019-08-05 15:03:10 +10:00
Steve Kowalik dc2f2ad8cb Switch to using six (#1189)
With the Python 2.7 deadline fast approaching, modernize the codebase
making use of the modernize module to switch to using six, as well as
other upcoming features, such as absolute imports . Stop using 2to3
for Travis, yay!
2019-08-05 14:06:19 +10:00
Steve Kowalik f1ae7200ba Update Repository.update_file() docstring (#1186)
The docstring for Repository.update_file() insisted that content be
base64 encoded, which is not quite correct, update it.

Closes #1069
2019-08-05 09:14:06 +10:00
Steve Kowalik 6e79d2704b Correct return type of MainClass.get_organizations (#1179)
The doc string and the code disagreed about the return type of
MainClass.get_organizations(), correct the code, which was incorrect.

Fixes #1177
2019-07-23 22:38:36 +10:00
ebrown a0731685f5 Add two factor attributes on organizations (#1132)
* Add 2fa attribute on organizations

* Fix property name and test value
2019-07-03 14:51:28 +08:00
Steve Kowalik 57af1e0526 Add Repository methods for pending invitations (#1159)
Make a start on implementing more of the invitations API, by adding
methods to Repository to list and remove pending invitations.

Closes #1120
2019-07-03 14:48:30 +08:00
Mark Browning acd515aaec Adds get_issue_events to PullRequest object (#1154)
* Adds `get_issue_events` to `PullRequest` object

* Add unit test for

* Fix PullRequest.get_issue_events unit test

Use actual event ids...

* Fix missing import on PullRequest.

I wish the unit tests would run in Python3...

* Add PulReqeust.testGetIssueEvents ReplayData

* Updating replay data to use developer's personal credentials.
2019-07-03 08:52:11 +08:00
Steve Kowalik 828b53b756 Silence more flake8 errors (#1160)
Make more whitespace changes to silence flake8 errors under the github
directory only.
2019-07-02 17:55:04 +08:00
Steve Kowalik b8dad9817e Clean up a lot of pyflakes warnings (#1153)
Clean up unused imports or unused variables to mostly silence pyflakes.
We aren't quite yet in a place where we can run it via Travis, but baby
steps.
2019-07-02 18:06:09 +10:00
Steve Kowalik 0f2beaca83 Add invitee and inviter to Invitation (#1156)
Invitations contain information about the user they are for, and
which user invited them, so export that too.

During invesigating attmepting to test the new attributes of Invitation,
it was discovered that there are no code paths to fetch them, so add
AuthenticatedUser.get_invitations(). The test added can do double duty.
2019-07-02 10:59:04 +08:00
Shibasis PatelandWan Liuyang edab176b5d Adding support for pending team invitations (#993)
* fixes issue#823

* Update GithubObject.py

* Added tests for Pending team invitations(Issue#823)


Co-authored-by: Wan Liuyang <tsfdye@gmail.com>
2019-06-28 11:35:58 +08:00
Steve Kowalik 8d2a6b534d Allow name to be specified for upload_asset (#1151)
GitRelease.upload_asset() calculates the name based on the filename, and
doesn't allow it to be overridden. Add a new name argument that is used
if it is set. Drive by changing the default of the content_type argument
to NotSet.

Closes #1095
2019-06-24 15:14:23 +08:00
Pascal Bach 03939fe55c Fix assertion in add_to_members (#1146)
The role parameter is set to NotSet by default
but the assertion only allowed str and unicode.
So it would always fail. Add NotSet to the assertion
to allow calling the function without a role.

Signed-off-by: Pascal Bach <pascal.bach@nextrem.ch>
2019-06-21 10:01:15 +08:00
chillipeper 6cd0d644cf Add support for custom base_url in GithubIntegration class (#1093)
* Add support for custom base_url in GithubIntegration

* Fix non default argument issue
2019-06-20 16:08:04 +08:00
Tomas Tomecek 18187045a4 GithubIntegration: enable getting installation (#1135)
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
2019-06-20 16:05:53 +08:00
Geoffroy Jabouley ef6f009dc3 Add sorting capability to Organization.get_repos() (#1139) 2019-06-20 15:51:55 +08:00
Steve Kowalik 4349bca136 Add new Organization.get_team_by_slug method (#1144)
Add a new API call to Organization that allows fetching teams by
slug.

Closes #1116
2019-06-20 15:40:20 +08:00
Brian Choy 4a37860bc4 Add description field when creating a new team (#1125) 2019-05-23 08:07:53 +08:00
Steve Kowalik 102c820806 Handle a path of / in Repository.get_contents() (#1070)
The path requested in Repository.get_contents() is appended to the URL,
so the root path should be requested with the empty string. If path is
'/', set it to the empty string. Copy the replay data from the original
test, since it is identical.

Drive-by renaming the test to include the missing 's'.

Closes #1059
2019-05-22 15:10:27 +08:00
Wan Liuyang 3d43e9c0e6 update doc, fix #1123 2019-05-21 10:02:14 +08:00
Wan Liuyang 01737a13f8 Merge get_file_contents with get_contents 2019-05-07 10:47:22 +08:00
Filipe LaínsandWan Liuyang ec7bbcf586 issue: add lock/unlock (#1107)
* issue: add lock/unlock

* tests: add test for issue lock/unlock

* tests: add lock/unlock sample data

* Fix tests, add locked and active_lock_reason


Co-authored-by: Wan Liuyang <tsfdye@gmail.com>
2019-05-06 09:38:05 +08:00
Caleb Sweeney 54065792b8 fixes #1106 for GitHub Enterprise API (#1110) 2019-05-03 09:24:59 +08:00
TechnicalPirate 78d283b9b5 Updated setup.py to exclude tests (#1031)
# Problem #
The `.whl` available on PyPi for this repository contains its entire `tests` submodule. 

The total size of the `pygithub` module is less than `1mb` without tests and `>23mb` with. 

Previous discussions on this topic indicated the removal of tests would be accepted if someone created a pull request to do so: https://github.com/PyGithub/PyGithub/issues/672 

This is that pull request! 😄

# Solution/Implementation # 

- Moved "tests" to root of the repository ( outside the package ) 
    - Added `tests.` module path to the imports in `AllTests.py`
- Updated `setup.py`
    - Removed `package_data` from product
    - Removed "tests" from packages definition
    - Repointed `test_suite` to new location
- Updated `travis.yml`
    - Added conditional ( if not `py2.7` ) conversion of code to `py3`

_... apologies for all the failed build spam below - new to working with Travis CI / had some gotcha moments!_
2019-04-16 11:45:02 +08:00
Jake Wilkins 818bd78fe9 Use non-deprecated path for creating GitHub App access tokens (#1086)
/installations/<installation_id>/access_tokens was deprecated as of
https://developer.github.com/changes/2018-08-16-renaming-and-deprecation-of-github-app-installation-access-token-route/
2019-04-10 10:11:06 +08:00
Alex 293846bee3 Add url parameter to include anonymous contributors in get_contributors() (#1075)
Add the anon parameter missing from get_contributors() so anonymous contributors can be included in results as specified in the [Github REST API Reference](https://developer.github.com/v3/repos/#list-contributors).
2019-04-05 13:51:40 +08:00
Isac Souza 5ae7af55ea Adding communications Retry functionality into requests via urllib3 retry object. (#1002)
This is a continuation of the work started by @allevin on https://github.com/PyGithub/PyGithub/pull/860.

I have refactored the testing Framework to use the `httpretty` library in order to use the urllib3 retry feature and therefore be able to test it.

Please refer to https://github.com/PyGithub/PyGithub/pull/860 for additional context.

cc: @allevin @mfonville @jrouquie @sfdye

Closes #757 
Closes #860
2019-04-05 13:49:01 +08:00
Wan Liuyang 6efd631890 Remove status API, closes #1080 2019-04-04 13:54:09 +08:00
Jon Dufresne 74c3040ae4 Run pyupgrade across the project (#1067)
https://github.com/asottile/pyupgrade

- Use dict comprehension
- Use set literals
2019-03-29 15:43:37 +08:00
Hamel Husain 86a9d8e973 provide option to extend expiration of jwt token (#1068)
supply optional parameter for `create_jwt` method
2019-03-29 15:37:36 +08:00