Exemple #1
0
def test_jira_full_descriptions_handles_auth(rest_desc, auth):
    client = Mock()
    auth.return_value = auth
    rest_desc.return_value = 'blah'

    settings_stub.JIRA_AUTH = ('user', 'pass')
    urls = {'foo': 'foo_url', 'bar': 'bar_url'}

    jira.jira_full_descriptions(client, '#bots', urls)

    assert call('foo', 'foo_url', auth) in rest_desc.call_args_list
    assert call('bar', 'bar_url', auth) in rest_desc.call_args_list
Exemple #2
0
def test_jira_full_descriptions_handles_auth(soup_desc, rest_desc, auth):
    client = Mock()
    auth.return_value = auth
    rest_desc.return_value = soup_desc.return_value = 'blah'

    settings_stub.JIRA_REST_API = 'http://example.com/'
    settings_stub.JIRA_AUTH = ('user', 'pass')
    urls = {'foo': 'foo_url', 'bar': 'bar_url'}

    jira.jira_full_descriptions(client, '#bots', urls)

    assert call('foo', 'foo_url', auth) in rest_desc.call_args_list
    assert call('bar', 'bar_url', auth) in rest_desc.call_args_list
Exemple #3
0
def test_jira_full_descriptions_handles_no_auth(rest_desc, auth):
    client = Mock()
    rest_desc.return_value = 'blah'
    settings_stub.JIRA_AUTH = ('', '')
    urls = {'foo': 'foo_url', 'bar': 'bar_url'}

    jira.jira_full_descriptions(client, '#bots', urls)

    assert not auth.called
    rest_desc.assert_has_calls([
        call('foo', 'foo_url', None),
        call('bar', 'bar_url', None),
    ], any_order=True)
Exemple #4
0
def test_jira_full_descriptions_handles_unicode(rest_desc, auth):
    snowman = u'☃'
    client = Mock()
    auth.return_value = auth
    rest_desc.return_value = snowman

    settings_stub.JIRA_AUTH = (snowman, snowman)
    urls = {snowman: u'{0}_url'.format(snowman)}

    jira.jira_full_descriptions(client, snowman, urls)

    assert rest_desc.call_args_list == [
        call(snowman, u'{0}_url'.format(snowman), auth),
    ]
Exemple #5
0
def test_jira_full_descriptions_uses_api(soup_desc, rest_desc):
    client = Mock()
    soup_desc.return_value = 'soup'
    rest_desc.return_value = 'rest'

    settings_stub.JIRA_REST_API = 'http://example.com/'
    urls = {'foo': 'foo_url', 'bar': 'bar_url'}

    jira.jira_full_descriptions(client, '#bots', urls)
    assert not soup_desc.called
    assert rest_desc.called
    assert call('foo', 'foo_url', None) in rest_desc.call_args_list
    assert call('bar', 'bar_url', None) in rest_desc.call_args_list
    client.msg.assert_called_with('#bots', 'rest\nrest')
Exemple #6
0
def test_jira_full_descriptions_uses_beautifulsoup(soup_desc, rest_desc):
    client = Mock()
    soup_desc.return_value = 'soup'
    rest_desc.return_value = 'rest'

    delattr(settings_stub, 'JIRA_REST_API')
    urls = {'foo': 'foo_url', 'bar': 'bar_url'}

    jira.jira_full_descriptions(client, '#bots', urls)
    assert soup_desc.called
    assert not rest_desc.called
    assert call('foo', 'foo_url', None) in soup_desc.call_args_list
    assert call('bar', 'bar_url', None) in soup_desc.call_args_list
    client.msg.assert_called_with('#bots', 'soup\nsoup')
Exemple #7
0
def test_jira_full_descriptions_uses_api(soup_desc, rest_desc):
    client = Mock()
    soup_desc.return_value = 'soup'
    rest_desc.return_value = 'rest'

    settings_stub.JIRA_REST_API = 'http://example.com/'
    urls = {'foo': 'foo_url', 'bar': 'bar_url'}

    jira.jira_full_descriptions(client, '#bots', urls)
    assert not soup_desc.called
    assert rest_desc.called
    assert call('foo', 'foo_url', None) in rest_desc.call_args_list
    assert call('bar', 'bar_url', None) in rest_desc.call_args_list
    client.msg.assert_called_with('#bots', 'rest\nrest')
Exemple #8
0
def test_jira_full_descriptions_uses_beautifulsoup(soup_desc, rest_desc):
    client = Mock()
    soup_desc.return_value = 'soup'
    rest_desc.return_value = 'rest'

    delattr(settings_stub, 'JIRA_REST_API')
    urls = {'foo': 'foo_url', 'bar': 'bar_url'}

    jira.jira_full_descriptions(client, '#bots', urls)
    assert soup_desc.called
    assert not rest_desc.called
    assert call('foo', 'foo_url', None) in soup_desc.call_args_list
    assert call('bar', 'bar_url', None) in soup_desc.call_args_list
    client.msg.assert_called_with('#bots', 'soup\nsoup')
Exemple #9
0
def test_jira_full_descriptions_handles_unicode(soup_desc, rest_desc, auth):
    snowman = u'☃'
    client = Mock()
    auth.return_value = auth
    rest_desc.return_value = soup_desc.return_value = snowman

    settings_stub.JIRA_REST_API = snowman
    settings_stub.JIRA_AUTH = (snowman, snowman)
    urls = {snowman: u'{0}_url'.format(snowman)}

    jira.jira_full_descriptions(client, snowman, urls)

    assert rest_desc.call_args_list == [
        call(snowman, u'{0}_url'.format(snowman), auth),
    ]