Commits

Brad Montgomery committed e0c262a

completed nosetests

Comments (0)

Files changed (1)

bitbucket/tests/test_bitbucket.py

     eq_(len(filter(lambda x: x['name'] == 'python-bitbucket', repos)), 1)
 
     # events
+    events = user.events()
+    eq_(events.keys(), [u'count', u'events'])
+    eq_(len(events['events']) > 0, True)
+
     # get
+    u = user.get()
+    eq_(u.keys(), [u'repositories', u'user'])
+    eq_(u['user']['username'], u'bkmontgomery')
+    eq_(u['user']['first_name'], u'Brad')
+    eq_(u['user']['last_name'], u'Montgomery')
     
     eq_('<User: bkmontgomery>', '%s' % user)
 
+def test_repository():
+    bb = BitBucket()
+    repo = bb.repository('bkmontgomery', 'python-bitbucket')
+    
+    # get
+    data = repo.get()
+    eq_(data.keys(), [u'website', u'name', u'description', u'followers_count', u'owner', u'logo', u'slug', u'resource_uri'])
+    eq_(data['name'], u'python-bitbucket')
+    eq_(data['slug'], u'python-bitbucket')
 
+    # changeset
+    cset = repo.changeset('37e6264f654b')
+    eq_(len(cset.keys()) > 0, True)
+    eq_(cset['node'], u'37e6264f654b')
+    eq_(cset['message'], u'typo fix')
+
+    # changesets
+    csets = repo.changesets(limit=1)
+    eq_(csets.keys(), [u'count', u'start', u'limit', u'changesets'])
+    eq_(csets['limit'], 1)
+    eq_(csets['start'], None)
+    eq_(len(csets['changesets']) > 0, True)
+
+    # parse_changeset_for_author (user the above ``cset``)
+    data = repo.parse_changeset_for_author(cset)
+    eq_(data['author'], u'bkmontgomery')
+    eq_(data['email'], u'brad@bradmontgomery.net')
+    eq_(data['gravatar_id'], 'd57aec10399cbb252bd890c2bb3fe1c9')
+    eq_(u'Brad Montgomery' in data['name'], True)
+
+    # tags
+    tags = repo.tags()
+    eq_('tip' in tags.keys(), True)
+
+    # branches
+    branches = repo.branches()
+    eq_('default' in branches.keys(), True)
+
+    # issues
+    issue = repo.issue(1)
+    eq_('%s' % issue, "<Issue #1 on bkmontgomery's python-bitbucket>")
+
+    issues = repo.issues()
+    eq_(issues['count'] > 0, True)
+    eq_(len(issues['issues']) > 0, True)
+
+    # events
+    events = repo.events()
+    eq_(events.keys(), [u'count', u'events'])
+    eq_(len(events['events']) > 0, True)
+
+    # followers
+    followers = repo.followers()
+    eq_(followers.keys(), [u'count', u'followers'])
+    eq_(len(followers['followers']) > 0, True)
+    eq_(u'bkmontgomery'  in [u['username'] for u in followers['followers']], True)
+
+    # forks/fork
+    eq_(repo.forks() > 0, True)
+    eq_(repo.fork(), True)
+
+    # contributors
+    contributors = repo.contributors()
+    eq_('contributors' in contributors.keys(), True)
+    eq_(len(contributors['contributors']) > 0, True)
+
+    # __repr__
+    eq_("%s" % repo, "<Repository: bkmontgomery's python-bitbucket>")
+
+def test_issue():
+    bb = BitBucket()
+    repo = bb.repository('bkmontgomery', 'python-bitbucket')
+    issue = repo.issue(1)
+    eq_('%s' % issue, "<Issue #1 on bkmontgomery's python-bitbucket>")
+
+    # get
+    data = issue.get()
+    eq_(data['content'], u"there aren't any tests!")
+
+    # followers
+    followers = issue.followers()
+    eq_(followers.keys(), [u'count', u'followers'])
+    eq_(len(followers['followers']) > 0, True)