public
Description: Python interface for talking to the github API
Clone URL: git://github.com/dustin/py-github.git
dustin (author)
Thu Apr 10 02:11:10 -0700 2008
commit  b5f988d4cf9d7fb50c1e9ad9a2a58396576006ad
tree    4192a1ef1e8411f6e33b26621ec58245df053311
py-github / githubtest.py
100755 49 lines (39 sloc) 1.576 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
"""
 
Copyright (c) 2007 Dustin Sallings <dustin@spy.net>
"""
 
import unittest
 
import github
 
class GitHubTest(unittest.TestCase):
 
    def __gh(self, expUrl, filename):
        def opener(url):
            self.assertEquals(expUrl, url)
            return open(filename)
        return github.GitHub(opener)
 
    def __loadUser(self):
        return self.__gh('http://github.com/api/v1/xml/dustin',
            'data/user.xml').user('dustin')
 
    def testUserBase(self):
        """Test the base properties of the user object."""
        u=self.__loadUser()
        self.assertEquals("Dustin Sallings", u.name)
        self.assertEquals("dustin", u.login)
        self.assertEquals("dustin@spy.net", u.email)
        self.assertEquals("Santa Clara, CA", u.location)
        self.assertEquals("<<User dustin with 19 repos>>", repr(u))
 
    def testUserRepos(self):
        """Test the repositories within the user object."""
        u=self.__loadUser()
        self.assertEquals(19, len(u.repos))
        self.assertEquals('buildwatch', u.repos['buildwatch'].name)
        self.assertEquals('http://github.com/dustin/buildwatch',
            u.repos['buildwatch'].url)
        self.assertEquals('A buildbot GUI for OS X',
            u.repos['buildwatch'].description)
        self.assertEquals('http://code.google.com/p/buildwatch/',
            u.repos['buildwatch'].homepage)
        self.assertEquals("<<Repository buildwatch>>",
            repr(u.repos['buildwatch']))
 
if __name__ == '__main__':
    unittest.main()
    # gh=github.GitHub(hack)