def test_rest_desc_handles_unicode(requests): snowman = u'☃' response = Mock() response.json.return_value = { 'fields': { 'summary': snowman, }, } requests.get.return_value = response assert jira._rest_desc(snowman, snowman) == u'[{0}] {0} ({0})'.format(snowman) response.json.side_effect = Exception assert jira._rest_desc(snowman, snowman) == u'[{0}] {0}'.format(snowman)
def test_rest_desc(requests): response = Mock() response.json.return_value = { 'fields': { 'summary': 'title', }, } requests.get.return_value = response assert jira._rest_desc('foo', 'url') == '[FOO] title (url)'
def test_rest_desc_without_summary(requests): response = Mock() response.json.side_effect = Exception requests.get.return_value = response assert jira._rest_desc('foo', 'url') == '[FOO] url'
def test_rest_desc_request_error(requests): response = Mock() response.raise_for_status.side_effect = Exception requests.get.return_value = response assert jira._rest_desc('foo', 'url') is None