Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Nov 26, 2014
1 parent bc04158 commit 177d69b
Showing 1 changed file with 37 additions and 30 deletions.
67 changes: 37 additions & 30 deletions tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,56 @@ class TestGithubIssue(ServiceTest):
'github.password': 'arbitrary_password',
'github.username': 'arbitrary_username',
}
arbitrary_created = (
datetime.datetime.utcnow() - datetime.timedelta(hours=1)
).replace(tzinfo=pytz.UTC)
arbitrary_updated = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
arbitrary_issue = {
'title': 'Hallo',
'html_url': 'http://whanot.com/',
'number': 10,
'body': 'Something',
'milestone': {'id': 'alpha'},
'created_at': arbitrary_created.isoformat(),
'updated_at': arbitrary_updated.isoformat(),
}
arbitrary_extra = {
'project': 'one',
'type': 'issue',
'annotations': [],
}

def setUp(self):
self.service = self.get_mock_service(GithubService)

def test_to_taskwarrior(self):
arbitrary_created = (
datetime.datetime.utcnow() - datetime.timedelta(hours=1)
).replace(tzinfo=pytz.UTC)
arbitrary_updated = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
arbitrary_issue = {
'title': 'Hallo',
'html_url': 'http://whanot.com/',
'number': 10,
'body': 'Something',
'milestone': {'id': 'alpha'},
'created_at': arbitrary_created.isoformat(),
'updated_at': arbitrary_updated.isoformat(),
}
arbitrary_extra = {
'project': 'one',
'type': 'issue',
'annotations': [],
}
def test_normalize_label_to_tag(self):
issue = self.service.get_issue_for_record(
self.arbitrary_issue,
self.arbitrary_extra
)
self.assertEqual(issue._normalize_label_to_tag('needs work'),
'needs_work')

def test_to_taskwarrior(self):
issue = self.service.get_issue_for_record(
arbitrary_issue,
arbitrary_extra
self.arbitrary_issue,
self.arbitrary_extra
)

expected_output = {
'project': arbitrary_extra['project'],
'project': self.arbitrary_extra['project'],
'priority': self.service.default_priority,
'annotations': [],
'tags': [],

issue.URL: arbitrary_issue['html_url'],
issue.TYPE: arbitrary_extra['type'],
issue.TITLE: arbitrary_issue['title'],
issue.NUMBER: arbitrary_issue['number'],
issue.UPDATED_AT: arbitrary_updated,
issue.CREATED_AT: arbitrary_created,
issue.BODY: arbitrary_issue['body'],
issue.MILESTONE: arbitrary_issue['milestone']['id'],
issue.URL: self.arbitrary_issue['html_url'],
issue.TYPE: self.arbitrary_extra['type'],
issue.TITLE: self.arbitrary_issue['title'],
issue.NUMBER: self.arbitrary_issue['number'],
issue.UPDATED_AT: self.arbitrary_updated,
issue.CREATED_AT: self.arbitrary_created,
issue.BODY: self.arbitrary_issue['body'],
issue.MILESTONE: self.arbitrary_issue['milestone']['id'],
}
actual_output = issue.to_taskwarrior()

Expand Down

0 comments on commit 177d69b

Please sign in to comment.