Permalink
Browse files

Added a basic User object

  • Loading branch information...
1 parent 4c036aa commit fed0810c16ba14f3972883b5edc899a676fade99 @Singletoned Singletoned committed Oct 23, 2011
Showing with 13 additions and 3 deletions.
  1. +10 −1 github.py
  2. +3 −2 tests/test_pygithub.py
View
@@ -17,4 +17,13 @@ def __init__(self, username, password):
def user(self):
response = requests.get('https://api.github.com/users/%s' % self.username)
content = response.content
- return json.loads(content)
+ data = json.loads(content)
+ user = User(data)
+ return user
+
+class User(object):
+ _keys = ['name', 'email']
+
+ def __init__(self, data):
+ for key in self._keys:
+ setattr(self, key, data[key])
View
@@ -10,5 +10,6 @@
def test_user():
gh = github.Github(username, password)
user = gh.user
- assert user['name'] == "Ed Singleton"
- assert user['email'] == "singletoned@gmail.com"
+ assert user.name == "Ed Singleton"
+ assert user.email == "singletoned@gmail.com"
+ assert isinstance(user, github.User)

0 comments on commit fed0810

Please sign in to comment.