Skip to content

Commit

Permalink
Bitbucket: add tests for the pagination and assignee
Browse files Browse the repository at this point in the history
  • Loading branch information
gdetrez committed May 20, 2016
1 parent b32bb03 commit d796bc8
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bugwarrior/db.py
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

from ConfigParser import NoOptionError, NoSectionError
import os
import re
Expand Down
2 changes: 2 additions & 0 deletions bugwarrior/services/__init__.py
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

import copy
import multiprocessing
import time
Expand Down
2 changes: 2 additions & 0 deletions bugwarrior/services/bitbucket.py
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

import requests
from twiggy import log

Expand Down
56 changes: 56 additions & 0 deletions tests/test_bitbucket.py
@@ -1,3 +1,5 @@
from __future__ import unicode_literals

import responses

from bugwarrior.services.bitbucket import BitbucketService
Expand Down Expand Up @@ -112,3 +114,57 @@ def test_issues(self):
'tags': []}

self.assertEqual(pr.get_taskwarrior_record(), expected_pr)

def test_get_owner(self):
issue = {
'title': 'Foobar',
'assignee': {'username': 'tintin'},
}
self.assertEqual(self.service.get_owner(('foo', issue)), 'tintin')

def test_get_owner_none(self):
issue = {
'title': 'Foobar',
'assignee': None,
}
self.assertIsNone(self.service.get_owner(('foo', issue)))

@responses.activate
def test_fetch_issues_pagination(self):
self.add_response(
'https://api.bitbucket.org/2.0/repositories/somename/somerepo/issues/',
json={
'values': [{
'title': 'Some Bug',
'status': 'open',
'links': {'html': {'href': 'example.com'}},
'id': 1
}],
'next': 'https://api.bitbucket.org/2.0/repositories/somename/somerepo/issues/?page=2',
})
self.add_response(
'https://api.bitbucket.org/2.0/repositories/somename/somerepo/issues/?page=2',
json={
'values': [{
'title': 'Some Other Bug',
'status': 'open',
'links': {'html': {'href': 'example.com'}},
'id': 2
}],
})
issues = list(self.service.fetch_issues('somename/somerepo'))
expected = [
('somename/somerepo', {
'title': 'Some Bug',
'status': 'open',
'links': {'html': {'href': 'example.com'}},
'id': 1
}),
('somename/somerepo', {
'title': 'Some Other Bug',
'status': 'open',
'links': {'html': {'href': 'example.com'}},
'id': 2
}),
]
self.assertEqual(issues, expected)

0 comments on commit d796bc8

Please sign in to comment.