| •1 |
import pytest |
| 2 |
|
| 3 |
pytest.skip( |
| 4 |
"Disabled in Debian: test_phab requires Phabricator/API not available", |
| 5 |
allow_module_level=True, |
| 6 |
) |
| 7 |
|
| 8 |
import datetime |
| 9 |
import unittest |
| 10 |
|
| 11 |
import pytz |
| 12 |
|
| 13 |
from bugwarrior.services.phab import PhabricatorService |
| 14 |
|
| 15 |
from .base import ServiceTest, AbstractServiceTest |
| 16 |
|
| 17 |
|
| 18 |
class TestPhabricatorIssue(AbstractServiceTest, ServiceTest): |
| 19 |
maxDiff = None |
| 20 |
SERVICE_CONFIG = { |
| 21 |
'phabricator.host': 'phabricator.example.com', |
| 22 |
} |
| 23 |
|
| 24 |
def setUp(self): |
| 25 |
super(TestPhabricatorIssue, self).setUp() |
| 26 |
self.service = self.get_mock_service(PhabricatorService) |
| 27 |
self.arbitrary_created = ( |
| 28 |
datetime.datetime.utcnow() - datetime.timedelta(hours=1) |
| 29 |
).replace(tzinfo=pytz.UTC, microsecond=0) |
| 30 |
self.arbitrary_updated = datetime.datetime.utcnow().replace( |
| 31 |
tzinfo=pytz.UTC, microsecond=0) |
| 32 |
self.arbitrary_duedate = ( |
| 33 |
datetime.datetime.combine(datetime.date.today(), |
| 34 |
datetime.datetime.min.time()) |
| 35 |
).replace(tzinfo=pytz.UTC) |
| 36 |
self.arbitrary_issue = { |
| 37 |
"id": 42, |
| 38 |
"uri": "https://phabricator.example.com/arbitrary_username/project/issues/3", |
| 39 |
"title": "A phine phabricator issue", |
| 40 |
} |
| 41 |
self.arbitrary_extra = { |
| 42 |
'type': 'issue', |
| 43 |
'project': 'PHROJECT', |
| 44 |
'annotations': [], |
| 45 |
} |
| 46 |
|
| 47 |
def test_to_taskwarrior(self): |
| 48 |
self.service.import_labels_as_tags = True |
| 49 |
issue = self.service.get_issue_for_record( |
| 50 |
self.arbitrary_issue, |
| 51 |
self.arbitrary_extra |
| 52 |
) |
| 53 |
|
| 54 |
expected_output = { |
| 55 |
issue.URL: self.arbitrary_issue['uri'], |
| 56 |
issue.TYPE: self.arbitrary_extra['type'], |
| 57 |
issue.TITLE: self.arbitrary_issue['title'], |
| 58 |
issue.OBJECT_NAME: '3', |
| 59 |
'project': 'PHROJECT', |
| 60 |
'priority': 'M', |
| 61 |
'annotations': [], |
| 62 |
} |
| 63 |
actual_output = issue.to_taskwarrior() |
| 64 |
|
| 65 |
self.assertEqual(actual_output, expected_output) |
| 66 |
|
| 67 |
@unittest.skip('The phabricator library is hard to mock.') |
| 68 |
def test_issues(self): |
| 69 |
pass |