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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
from builtins import next
from unittest import mock
import responses
from bugwarrior.services.teamlab import TeamLabService
from .base import ServiceTest, AbstractServiceTest
class TestTeamlabIssue(AbstractServiceTest, ServiceTest):
SERVICE_CONFIG = {
'teamlab.hostname': 'something',
'teamlab.login': 'alkjdsf',
'teamlab.password': 'lkjklj',
'teamlab.project_name': 'abcdef',
}
arbitrary_issue = {
'title': 'Hello',
'id': 10,
'projectOwner': {
'id': 140,
},
'status': 1,
}
def setUp(self):
super(TestTeamlabIssue, self).setUp()
with mock.patch(
'bugwarrior.services.teamlab.TeamLabClient.authenticate'
):
self.service = self.get_mock_service(TeamLabService)
def test_to_taskwarrior(self):
arbitrary_url = 'http://galkjsdflkj.com/'
issue = self.service.get_issue_for_record(self.arbitrary_issue)
expected_output = {
'project': self.SERVICE_CONFIG['teamlab.project_name'],
'priority': self.service.default_priority,
issue.TITLE: self.arbitrary_issue['title'],
issue.FOREIGN_ID: self.arbitrary_issue['id'],
issue.URL: arbitrary_url,
issue.PROJECTOWNER_ID: self.arbitrary_issue['projectOwner']['id']
}
def get_url(*args):
return arbitrary_url
with mock.patch.object(issue, 'get_issue_url', side_effect=get_url):
actual_output = issue.to_taskwarrior()
self.assertEqual(actual_output, expected_output)
@responses.activate
def test_issues(self):
self.add_response(
'http://something/api/1.0/project/task/@self.json',
json=[self.arbitrary_issue])
issue = next(self.service.issues())
expected = {
'description':
u'(bw)Is#10 - Hello .. http://something/products/projects/tasks.aspx?prjID=140&id=10',
'priority': 'M',
'project': 'abcdef',
'tags': [],
'teamlabid': 10,
'teamlabprojectownerid': 140,
'teamlabtitle': u'Hello',
'teamlaburl':
'http://something/products/projects/tasks.aspx?prjID=140&id=10'}
self.assertEqual(issue.get_taskwarrior_record(), expected)
|