Skip to content

Commit 86ef503

Browse files
authored
Merge pull request #68 from gene1wood/release-2.2.1
Release 2.2.1
2 parents 8d5ef2d + 31b0d6b commit 86ef503

File tree

13 files changed

+123
-52
lines changed

13 files changed

+123
-52
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# http://krlmlr.github.io/using-gitattributes-to-avoid-merge-conflicts/
2+
/CHANGELOG.md merge=union

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
tags
22
*.py[co]
3-
.*
43
MANIFEST
54
dist/*
65
agithub.egg-info/
76
build/
87
dist/
8+
.tox
9+
.eggs

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: python
2+
python:
3+
- '3.7'
4+
- '2.7'
5+
6+
install: pip install -U tox-travis
7+
script: tox

CHANGELOG.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [2.2.1] - 2019-10-07
10+
### Added
11+
* Mozilla code of conduct
12+
* Long description to setup.py containing README
13+
* End to end GitHub unit test and tox testing with pytest
14+
* Integration with Travis CI
15+
16+
### Changed
17+
* Moved to SCM (git) driven version instead of a hard coded one
18+
* VERSION constant from semver list (e.g. [2, 2, 1]) to string version (e.g. 2.2.1)
19+
20+
### Removed
21+
* mock module to avoid collision with builtin mock module
22+
* STR_VERSION constant
23+
24+
### Fixed
25+
* TypeError when paginate is `True` and `sleep_on_ratelimit` is the default (#66 by [@huma23](https://github.com/huma23))
26+
927
## [2.2.0] - 2019-01-16
1028
### Added
1129
* GitHub pagination support, which can be enabled
@@ -71,7 +89,8 @@ contributed!)
7189
* Has a version number. (Yippie!)
7290
* First more-or-less stable version
7391

74-
[Unreleased]: https://github.com/mozilla/agithub/compare/v2.2.0...HEAD
92+
[Unreleased]: https://github.com/mozilla/agithub/compare/v2.2.1...HEAD
93+
[2.2.1]: https://github.com/mozilla/agithub/compare/v2.2.0...v2.2.1
7594
[2.2.0]: https://github.com/mozilla/agithub/compare/v2.1...v2.2.0
7695
[2.1]: https://github.com/mozilla/agithub/compare/v2.0...v2.1
7796
[2.0]: https://github.com/mozilla/agithub/compare/v1.3...v2.0

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,5 +427,4 @@ become an expert on the code. From there, anything's possible.
427427

428428
## License
429429
Copyright 2012–2016 Jonathan Paugh and contributors
430-
See [COPYING][LIC] for license details
431-
[LIC]: COPYING
430+
See [COPYING](COPYING) for license details

agithub/GitHub.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
import re
66
import logging
77

8-
from agithub.base import API, ConnectionProperties, Client, RequestBody, ResponseBody
8+
from agithub.base import (
9+
API, ConnectionProperties, Client, RequestBody, ResponseBody)
910

1011
logger = logging.getLogger(__name__)
1112

13+
1214
class GitHub(API):
1315
"""
1416
The agnostic GitHub API. It doesn't know, and you don't care.
@@ -92,7 +94,7 @@ def request(self, method, url, bodyData, headers):
9294
if 'content-type' in headers:
9395
del headers['content-type']
9496

95-
#TODO: Context manager
97+
# TODO: Context manager
9698
requestBody = RequestBody(bodyData, headers)
9799

98100
if self.sleep_on_ratelimit and self.no_ratelimit_remaining():
@@ -107,12 +109,14 @@ def request(self, method, url, bodyData, headers):
107109
self.headers = response.getheaders()
108110

109111
conn.close()
110-
if status == 403 and self.sleep_on_ratelimit and self.no_ratelimit_remaining():
112+
if (status == 403 and self.sleep_on_ratelimit and
113+
self.no_ratelimit_remaining()):
111114
self.sleep_until_more_ratelimit()
112115
else:
113116
data = content.processBody()
114117
if self.paginate and type(data) == list:
115-
data.extend(self.get_additional_pages(method, bodyData, headers))
118+
data.extend(
119+
self.get_additional_pages(method, bodyData, headers))
116120
return status, data
117121

118122
def get_additional_pages(self, method, bodyData, headers):
@@ -165,9 +169,10 @@ def get_next_link_url(self):
165169
"""Given a set of HTTP headers find the RFC 5988 Link header field,
166170
determine if it contains a relation type indicating a next resource and
167171
if so return the URL of the next resource, otherwise return an empty
168-
string."""
172+
string.
169173
170-
# From https://github.com/requests/requests/blob/master/requests/utils.py
174+
From https://github.com/requests/requests/blob/master/requests/utils.py
175+
"""
171176
for value in [x[1] for x in self.headers if x[0].lower() == 'link']:
172177
replace_chars = ' \'"'
173178
value = value.strip(replace_chars)

agithub/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright 2012-2016 Jonathan Paugh and contributors
22
# See COPYING for license details
3-
from agithub.base import VERSION, STR_VERSION
3+
from agithub.base import VERSION
44

5-
__all__ = ["VERSION", "STR_VERSION"]
5+
__all__ = ["VERSION"]

agithub/agithub_test.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,33 @@
33
# See COPYING for license details
44
from agithub.GitHub import GitHub
55
from agithub.base import IncompleteRequest
6-
import mock
76
import unittest
87

98

9+
class Client(object):
10+
http_methods = ('demo', 'test')
11+
12+
def __init__(self, username=None, password=None, token=None,
13+
connection_properties=None):
14+
pass
15+
16+
def setConnectionProperties(self, props):
17+
pass
18+
19+
def demo(self, *args, **params):
20+
return self.methodCalled('demo', *args, **params)
21+
22+
def test(self, *args, **params):
23+
return self.methodCalled('test', *args, **params)
24+
25+
def methodCalled(self, methodName, *args, **params):
26+
return {
27+
'methodName': methodName,
28+
'args': args,
29+
'params': params
30+
}
31+
32+
1033
class TestGitHubObjectCreation(unittest.TestCase):
1134
def test_user_pw(self):
1235
gh = GitHub('korfuri', '1234')
@@ -30,7 +53,7 @@ def test_token_password(self):
3053
class TestIncompleteRequest(unittest.TestCase):
3154

3255
def newIncompleteRequest(self):
33-
return IncompleteRequest(mock.Client())
56+
return IncompleteRequest(Client())
3457

3558
def test_pathByGetAttr(self):
3659
rb = self.newIncompleteRequest()
@@ -64,5 +87,18 @@ def test_callMethodTest(self):
6487
}
6588
)
6689

90+
91+
def test_github():
92+
g = GitHub()
93+
status, data = g.users.octocat.get()
94+
assert data.get('name') == 'The Octocat'
95+
assert status == 200
96+
# Workaround to https://github.com/mozilla/agithub/issues/67
97+
response_headers = dict([(x.lower(), y) for x, y in g.getheaders()])
98+
assert (
99+
response_headers.get('Content-Type'.lower()) ==
100+
'application/json; charset=utf-8')
101+
102+
67103
if __name__ == '__main__':
68104
unittest.main()

agithub/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# See COPYING for license details
33
import json
44
from functools import partial, update_wrapper
5+
from setuptools_scm import get_version
56

67
import sys
78
if sys.version_info[0:2] > (3, 0):
@@ -14,14 +15,13 @@
1415
class ConnectionError(OSError):
1516
pass
1617

17-
VERSION = [2, 1]
18-
STR_VERSION = 'v' + '.'.join(str(v) for v in VERSION)
18+
VERSION = get_version(root='..', relative_to=__file__)
1919

2020
# These headers are implicitly included in each request; however, each
2121
# can be explicitly overridden by the client code. (Used in Client
2222
# objects.)
2323
_default_headers = {
24-
'user-agent': 'agithub/' + STR_VERSION,
24+
'user-agent': 'agithub/' + VERSION,
2525
'content-type': 'application/json'
2626
}
2727

agithub/mock.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)