# This file is part of the CERN Indico plugins.
# Copyright (C) 2014 - 2022 CERN
#
# The CERN Indico plugins are free software; you can redistribute
# them and/or modify them under the terms of the MIT License; see
# the LICENSE file for more details.

from unittest.mock import MagicMock

import pytest
from requests.exceptions import HTTPError, Timeout

from indico.testing.util import extract_logs

from indico_ravem.plugin import RavemPlugin
from indico_ravem.util import has_access, ravem_api_call


@pytest.mark.usefixtures('db')
@pytest.mark.parametrize('method', ('get', 'post'))
def test_correct_http_method(mocker, method):
    request = mocker.patch('indico_ravem.util.requests.request')
    response = MagicMock()
    response.json.return_value = {'result': 'test'}
    response.raise_for_status.return_value = False
    request.return_value = response

    ravem_api_call('test_endpoint', method=method, param1='test1', param2='test2')

    assert request.call_count == 1
    assert request.call_args[0][0] == method


@pytest.mark.usefixtures('db')
def test_correct_auth_method(mocker):
    request = mocker.patch('indico_ravem.util.requests.request')
    response = MagicMock()
    response.json.return_value = {'result': 'test'}
    response.raise_for_status.return_value = False
    request.return_value = response

    token = 'foo'
    RavemPlugin.settings.set('access_token', token)
    ravem_api_call('test_endpoint', param1='test1', param2='test2')

    assert request.call_count == 1
    assert 'Authorization' in request.call_args[1]['headers']
    assert request.call_args[1]['headers']['Authorization'] == 'Bearer %s' % token


@pytest.mark.usefixtures('db')
def test_accepts_json(mocker):
    request = mocker.patch('indico_ravem.util.requests.request')
    response = MagicMock()
    response.json.return_value = {'result': 'test'}
    response.raise_for_status.return_value = False
    request.return_value = response

    ravem_api_call('test_endpoint', param1='test1', param2='test2')

    assert request.call_count == 1
    assert request.call_args[1]['headers']['Accept'] == 'application/json'


@pytest.mark.usefixtures('db')
@pytest.mark.parametrize(('root_endpoint', 'endpoint', 'expected_url'), (
    ('https://ravem.test/', 'final_endpoint', 'https://ravem.test/final_endpoint'),
    ('https://ravem.test/api/', 'final_endpoint', 'https://ravem.test/api/final_endpoint'),
    ('https://ravem.test/api/v2/', 'final_endpoint', 'https://ravem.test/api/v2/final_endpoint'),
    ('https://ravem.test', './final_endpoint', 'https://ravem.test/final_endpoint'),
    ('https://ravem.test/api/', './final_endpoint', 'https://ravem.test/api/final_endpoint'),
    ('https://ravem.test/api/v2/', './final_endpoint', 'https://ravem.test/api/v2/final_endpoint'),
    ('https://ravem.test', 'sub/final_endpoint', 'https://ravem.test/sub/final_endpoint'),
    ('https://ravem.test/api/', 'sub/final_endpoint', 'https://ravem.test/api/sub/final_endpoint'),
    ('https://ravem.test/api/v2/', 'sub/final_endpoint', 'https://ravem.test/api/v2/sub/final_endpoint'),
    ('https://ravem.test', './sub/final_endpoint', 'https://ravem.test/sub/final_endpoint'),
    ('https://ravem.test/api/', './sub/final_endpoint', 'https://ravem.test/api/sub/final_endpoint'),
    ('https://ravem.test/api/v2/', './sub/final_endpoint', 'https://ravem.test/api/v2/sub/final_endpoint'),
    ('https://ravem.test/', '', 'https://ravem.test/'),
    ('https://ravem.test/api/', '', 'https://ravem.test/api/'),
    ('https://ravem.test/api/v2/', '', 'https://ravem.test/api/v2/'),
))
def test_correct_api_endpoint(mocker, root_endpoint, endpoint, expected_url):
    request = mocker.patch('indico_ravem.util.requests.request')
    response = MagicMock()
    response.json.return_value = {'result': 'test'}
    response.raise_for_status.return_value = False
    request.return_value = response

    RavemPlugin.settings.set('api_endpoint', root_endpoint)
    ravem_api_call(endpoint, param1='test1', param2='test2')

    assert request.call_count == 1
    assert request.call_args[0][1] == expected_url


@pytest.mark.usefixtures('db')
@pytest.mark.parametrize('params', (
    {},
    {'p1': '1stparam'},
    {'p1': '1stparam', 'p2': '2ndparam'}
))
def test_params_generated(mocker, params):
    request = mocker.patch('indico_ravem.util.requests.request')
    response = MagicMock()
    response.json.return_value = {'result': 'test'}
    response.raise_for_status.return_value = False
    request.return_value = response

    ravem_api_call('test_endpoint', params=params)

    assert request.call_count == 1
    assert request.call_args[1]['params'] == params


@pytest.mark.usefixtures('db')
def test_raises_timeout(mocker):
    request = mocker.patch('indico_ravem.util.requests.request')
    request.side_effect = Timeout('Timeout test error message', request=request)

    with pytest.raises(Timeout) as excinfo:
        ravem_api_call('test_endpoint')

    assert str(excinfo.value) == "Timeout while contacting the room."
    assert request.call_count == 1


@pytest.mark.usefixtures('db')
@pytest.mark.parametrize(('method', 'params'), (
    ('get', {}),
    ('post', {}),
    ('get', {'p1': '1stparam'}),
    ('post', {'p1': '1stparam'}),
    ('get', {'p1': '1stparam', 'p2': '2ndparam'}),
    ('post', {'p1': '1stparam', 'p2': '2ndparam'})
))
def test_unexpected_exception_is_logged(mocker, caplog, method, params):
    request = mocker.patch('indico_ravem.util.requests.request')
    request.side_effect = IndexError('this is unexpected')

    with pytest.raises(IndexError) as excinfo:
        ravem_api_call('test_endpoint', method=method, **params)

    assert str(excinfo.value) == 'this is unexpected'
    log = extract_logs(caplog, one=True, name='indico.plugin.ravem')
    assert log.message == "failed call: {} {} with {}: {}".format(method.upper(), 'test_endpoint', params,
                                                                  'this is unexpected')
    assert request.call_count == 1


@pytest.mark.usefixtures('db')
@pytest.mark.parametrize(('method', 'params'), (
    ('get', {}),
    ('post', {}),
    ('get', {'p1': '1stparam'}),
    ('post', {'p1': '1stparam'}),
    ('get', {'p1': '1stparam', 'p2': '2ndparam'}),
    ('post', {'p1': '1stparam', 'p2': '2ndparam'})
))
def test_http_error_is_logged(mocker, caplog, method, params):
    request = mocker.patch('indico_ravem.util.requests.request')
    request.method = method.upper()
    request.url = RavemPlugin.settings.get('api_endpoint') + 'test_endpoint'
    response = MagicMock()
    response.raise_for_status.side_effect = HTTPError('Well this is embarrassing')
    response.request = request
    response.url = response.request.url
    request.return_value = response

    with pytest.raises(HTTPError) as excinfo:
        ravem_api_call('test_endpoint', method=method, **params)

    assert str(excinfo.value) == 'Well this is embarrassing'
    log = extract_logs(caplog, one=True, name='indico.plugin.ravem')
    assert log.message == '{} {} failed with {}'.format(
        method.upper(), RavemPlugin.settings.get('api_endpoint') + 'test_endpoint', 'Well this is embarrassing')

    assert request.call_count == 1


@pytest.mark.usefixtures('db')
def test_unlinked_event_vc_room_has_no_access():
    event_vc_room = MagicMock()
    event_vc_room.link_object = None

    assert not has_access(event_vc_room)


@pytest.mark.usefixtures('db', 'request_context')
def test_unlinked_room_has_no_access(mocker):
    session = mocker.patch('indico_ravem.util.session')
    session.user = 'Guinea Pig'

    event_vc_room = MagicMock()
    event_vc_room.link_object.room = None

    assert not has_access(event_vc_room)


@pytest.mark.usefixtures('db', 'request_context')
def test_check_if_current_user_is_room_owner(mocker):
    session = mocker.patch('indico_ravem.util.session')
    session.user = 'Guinea Pig'
    request = mocker.patch('indico_ravem.util.request')
    request.remote_addr = '111.222.123.123'
    retrieve_principal = mocker.patch('indico_ravem.util._retrieve_principal')
    retrieve_principal.side_effect = lambda x: session.user

    event_vc_room = MagicMock()
    event_vc_room.link_object.room.has_equipment = MagicMock(return_value=True)
    event_vc_room.link_object.room.get_attribute_value.return_value = request.remote_addr
    event_vc_room.vc_room.data.get.return_value = 'User:123'
    event_vc_room.event.can_manage.return_value = False

    assert has_access(event_vc_room)


@pytest.mark.usefixtures('db', 'request_context')
def test_check_if_current_user_can_modify(mocker):
    request = mocker.patch('indico_ravem.util.request')
    request.remote_addr = '111.222.123.123'
    session = mocker.patch('indico_ravem.util.session')
    session.user = 'Guinea Pig'
    mocker.patch('indico_ravem.util._retrieve_principal')

    event_vc_room = MagicMock()
    event_vc_room.link_object.room.has_equipment = MagicMock(return_value=True)
    event_vc_room.link_object.room.get_attribute_value.return_value = request.remote_addr
    event_vc_room.event.can_manage.return_value = True

    assert has_access(event_vc_room)
    event_vc_room.event.can_manage.assert_called_once_with(session.user)

[((19, 1, 19, 30), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(19, 25, 19, 29): '"""db"""'}, {}), "('db')", False, 'import pytest\n'), ((20, 1, 20, 51), 'pytest.mark.parametrize', 'pytest.mark.parametrize', ({(20, 25, 20, 33): '"""method"""', (20, 35, 20, 50): "('get', 'post')"}, {}), "('method', ('get', 'post'))", False, 'import pytest\n'), ((34, 1, 34, 30), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(34, 25, 34, 29): '"""db"""'}, {}), "('db')", False, 'import pytest\n'), ((51, 1, 51, 30), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(51, 25, 51, 29): '"""db"""'}, {}), "('db')", False, 'import pytest\n'), ((65, 1, 65, 30), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(65, 25, 65, 29): '"""db"""'}, {}), "('db')", False, 'import pytest\n'), ((66, 1, 82, 2), 'pytest.mark.parametrize', 'pytest.mark.parametrize', ({(66, 25, 66, 70): "('root_endpoint', 'endpoint', 'expected_url')", (66, 72, 82, 1): "(('https://ravem.test/', 'final_endpoint',\n    'https://ravem.test/final_endpoint'), ('https://ravem.test/api/',\n    'final_endpoint', 'https://ravem.test/api/final_endpoint'), (\n    'https://ravem.test/api/v2/', 'final_endpoint',\n    'https://ravem.test/api/v2/final_endpoint'), ('https://ravem.test',\n    './final_endpoint', 'https://ravem.test/final_endpoint'), (\n    'https://ravem.test/api/', './final_endpoint',\n    'https://ravem.test/api/final_endpoint'), ('https://ravem.test/api/v2/',\n    './final_endpoint', 'https://ravem.test/api/v2/final_endpoint'), (\n    'https://ravem.test', 'sub/final_endpoint',\n    'https://ravem.test/sub/final_endpoint'), ('https://ravem.test/api/',\n    'sub/final_endpoint', 'https://ravem.test/api/sub/final_endpoint'), (\n    'https://ravem.test/api/v2/', 'sub/final_endpoint',\n    'https://ravem.test/api/v2/sub/final_endpoint'), ('https://ravem.test',\n    './sub/final_endpoint', 'https://ravem.test/sub/final_endpoint'), (\n    'https://ravem.test/api/', './sub/final_endpoint',\n    'https://ravem.test/api/sub/final_endpoint'), (\n    'https://ravem.test/api/v2/', './sub/final_endpoint',\n    'https://ravem.test/api/v2/sub/final_endpoint'), ('https://ravem.test/',\n    '', 'https://ravem.test/'), ('https://ravem.test/api/', '',\n    'https://ravem.test/api/'), ('https://ravem.test/api/v2/', '',\n    'https://ravem.test/api/v2/'))"}, {}), "(('root_endpoint', 'endpoint', 'expected_url'), ((\n    'https://ravem.test/', 'final_endpoint',\n    'https://ravem.test/final_endpoint'), ('https://ravem.test/api/',\n    'final_endpoint', 'https://ravem.test/api/final_endpoint'), (\n    'https://ravem.test/api/v2/', 'final_endpoint',\n    'https://ravem.test/api/v2/final_endpoint'), ('https://ravem.test',\n    './final_endpoint', 'https://ravem.test/final_endpoint'), (\n    'https://ravem.test/api/', './final_endpoint',\n    'https://ravem.test/api/final_endpoint'), ('https://ravem.test/api/v2/',\n    './final_endpoint', 'https://ravem.test/api/v2/final_endpoint'), (\n    'https://ravem.test', 'sub/final_endpoint',\n    'https://ravem.test/sub/final_endpoint'), ('https://ravem.test/api/',\n    'sub/final_endpoint', 'https://ravem.test/api/sub/final_endpoint'), (\n    'https://ravem.test/api/v2/', 'sub/final_endpoint',\n    'https://ravem.test/api/v2/sub/final_endpoint'), ('https://ravem.test',\n    './sub/final_endpoint', 'https://ravem.test/sub/final_endpoint'), (\n    'https://ravem.test/api/', './sub/final_endpoint',\n    'https://ravem.test/api/sub/final_endpoint'), (\n    'https://ravem.test/api/v2/', './sub/final_endpoint',\n    'https://ravem.test/api/v2/sub/final_endpoint'), ('https://ravem.test/',\n    '', 'https://ravem.test/'), ('https://ravem.test/api/', '',\n    'https://ravem.test/api/'), ('https://ravem.test/api/v2/', '',\n    'https://ravem.test/api/v2/')))", False, 'import pytest\n'), ((97, 1, 97, 30), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(97, 25, 97, 29): '"""db"""'}, {}), "('db')", False, 'import pytest\n'), ((98, 1, 102, 2), 'pytest.mark.parametrize', 'pytest.mark.parametrize', ({(98, 25, 98, 33): '"""params"""', (98, 35, 102, 1): "({}, {'p1': '1stparam'}, {'p1': '1stparam', 'p2': '2ndparam'})"}, {}), "('params', ({}, {'p1': '1stparam'}, {'p1':\n    '1stparam', 'p2': '2ndparam'}))", False, 'import pytest\n'), ((116, 1, 116, 30), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(116, 25, 116, 29): '"""db"""'}, {}), "('db')", False, 'import pytest\n'), ((128, 1, 128, 30), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(128, 25, 128, 29): '"""db"""'}, {}), "('db')", False, 'import pytest\n'), ((129, 1, 136, 2), 'pytest.mark.parametrize', 'pytest.mark.parametrize', ({(129, 25, 129, 45): "('method', 'params')", (129, 47, 136, 1): "(('get', {}), ('post', {}), ('get', {'p1': '1stparam'}), ('post', {'p1':\n    '1stparam'}), ('get', {'p1': '1stparam', 'p2': '2ndparam'}), ('post', {\n    'p1': '1stparam', 'p2': '2ndparam'}))"}, {}), "(('method', 'params'), (('get', {}), ('post', {}), (\n    'get', {'p1': '1stparam'}), ('post', {'p1': '1stparam'}), ('get', {'p1':\n    '1stparam', 'p2': '2ndparam'}), ('post', {'p1': '1stparam', 'p2':\n    '2ndparam'})))", False, 'import pytest\n'), ((151, 1, 151, 30), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(151, 25, 151, 29): '"""db"""'}, {}), "('db')", False, 'import pytest\n'), ((152, 1, 159, 2), 'pytest.mark.parametrize', 'pytest.mark.parametrize', ({(152, 25, 152, 45): "('method', 'params')", (152, 47, 159, 1): "(('get', {}), ('post', {}), ('get', {'p1': '1stparam'}), ('post', {'p1':\n    '1stparam'}), ('get', {'p1': '1stparam', 'p2': '2ndparam'}), ('post', {\n    'p1': '1stparam', 'p2': '2ndparam'}))"}, {}), "(('method', 'params'), (('get', {}), ('post', {}), (\n    'get', {'p1': '1stparam'}), ('post', {'p1': '1stparam'}), ('get', {'p1':\n    '1stparam', 'p2': '2ndparam'}), ('post', {'p1': '1stparam', 'p2':\n    '2ndparam'})))", False, 'import pytest\n'), ((181, 1, 181, 30), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(181, 25, 181, 29): '"""db"""'}, {}), "('db')", False, 'import pytest\n'), ((189, 1, 189, 49), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(189, 25, 189, 29): '"""db"""', (189, 31, 189, 48): '"""request_context"""'}, {}), "('db', 'request_context')", False, 'import pytest\n'), ((200, 1, 200, 49), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(200, 25, 200, 29): '"""db"""', (200, 31, 200, 48): '"""request_context"""'}, {}), "('db', 'request_context')", False, 'import pytest\n'), ((218, 1, 218, 49), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', ({(218, 25, 218, 29): '"""db"""', (218, 31, 218, 48): '"""request_context"""'}, {}), "('db', 'request_context')", False, 'import pytest\n'), ((23, 15, 23, 26), 'unittest.mock.MagicMock', 'MagicMock', ({}, {}), '()', False, 'from unittest.mock import MagicMock\n'), ((28, 4, 28, 82), 'indico_ravem.util.ravem_api_call', 'ravem_api_call', (), '', False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((37, 15, 37, 26), 'unittest.mock.MagicMock', 'MagicMock', ({}, {}), '()', False, 'from unittest.mock import MagicMock\n'), ((43, 4, 43, 51), 'indico_ravem.plugin.RavemPlugin.settings.set', 'RavemPlugin.settings.set', ({(43, 29, 43, 43): '"""access_token"""', (43, 45, 43, 50): 'token'}, {}), "('access_token', token)", False, 'from indico_ravem.plugin import RavemPlugin\n'), ((44, 4, 44, 67), 'indico_ravem.util.ravem_api_call', 'ravem_api_call', (), '', False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((54, 15, 54, 26), 'unittest.mock.MagicMock', 'MagicMock', ({}, {}), '()', False, 'from unittest.mock import MagicMock\n'), ((59, 4, 59, 67), 'indico_ravem.util.ravem_api_call', 'ravem_api_call', (), '', False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((85, 15, 85, 26), 'unittest.mock.MagicMock', 'MagicMock', ({}, {}), '()', False, 'from unittest.mock import MagicMock\n'), ((90, 4, 90, 59), 'indico_ravem.plugin.RavemPlugin.settings.set', 'RavemPlugin.settings.set', ({(90, 29, 90, 43): '"""api_endpoint"""', (90, 45, 90, 58): 'root_endpoint'}, {}), "('api_endpoint', root_endpoint)", False, 'from indico_ravem.plugin import RavemPlugin\n'), ((91, 4, 91, 60), 'indico_ravem.util.ravem_api_call', 'ravem_api_call', (), '', False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((105, 15, 105, 26), 'unittest.mock.MagicMock', 'MagicMock', ({}, {}), '()', False, 'from unittest.mock import MagicMock\n'), ((110, 4, 110, 50), 'indico_ravem.util.ravem_api_call', 'ravem_api_call', (), '', False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((119, 26, 119, 80), 'requests.exceptions.Timeout', 'Timeout', (), '', False, 'from requests.exceptions import HTTPError, Timeout\n'), ((145, 10, 145, 68), 'indico.testing.util.extract_logs', 'extract_logs', (), '', False, 'from indico.testing.util import extract_logs\n'), ((164, 15, 164, 26), 'unittest.mock.MagicMock', 'MagicMock', ({}, {}), '()', False, 'from unittest.mock import MagicMock\n'), ((165, 44, 165, 82), 'requests.exceptions.HTTPError', 'HTTPError', ({(165, 54, 165, 81): '"""Well this is embarrassing"""'}, {}), "('Well this is embarrassing')", False, 'from requests.exceptions import HTTPError, Timeout\n'), ((174, 10, 174, 68), 'indico.testing.util.extract_logs', 'extract_logs', (), '', False, 'from indico.testing.util import extract_logs\n'), ((183, 20, 183, 31), 'unittest.mock.MagicMock', 'MagicMock', ({}, {}), '()', False, 'from unittest.mock import MagicMock\n'), ((194, 20, 194, 31), 'unittest.mock.MagicMock', 'MagicMock', ({}, {}), '()', False, 'from unittest.mock import MagicMock\n'), ((209, 20, 209, 31), 'unittest.mock.MagicMock', 'MagicMock', ({}, {}), '()', False, 'from unittest.mock import MagicMock\n'), ((210, 51, 210, 79), 'unittest.mock.MagicMock', 'MagicMock', (), '', False, 'from unittest.mock import MagicMock\n'), ((215, 11, 215, 36), 'indico_ravem.util.has_access', 'has_access', ({(215, 22, 215, 35): 'event_vc_room'}, {}), '(event_vc_room)', False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((226, 20, 226, 31), 'unittest.mock.MagicMock', 'MagicMock', ({}, {}), '()', False, 'from unittest.mock import MagicMock\n'), ((227, 51, 227, 79), 'unittest.mock.MagicMock', 'MagicMock', (), '', False, 'from unittest.mock import MagicMock\n'), ((231, 11, 231, 36), 'indico_ravem.util.has_access', 'has_access', ({(231, 22, 231, 35): 'event_vc_room'}, {}), '(event_vc_room)', False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((121, 9, 121, 31), 'pytest.raises', 'pytest.raises', ({(121, 23, 121, 30): 'Timeout'}, {}), '(Timeout)', False, 'import pytest\n'), ((122, 8, 122, 39), 'indico_ravem.util.ravem_api_call', 'ravem_api_call', ({(122, 23, 122, 38): '"""test_endpoint"""'}, {}), "('test_endpoint')", False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((141, 9, 141, 34), 'pytest.raises', 'pytest.raises', ({(141, 23, 141, 33): 'IndexError'}, {}), '(IndexError)', False, 'import pytest\n'), ((142, 8, 142, 64), 'indico_ravem.util.ravem_api_call', 'ravem_api_call', (), '', False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((163, 18, 163, 58), 'indico_ravem.plugin.RavemPlugin.settings.get', 'RavemPlugin.settings.get', ({(163, 43, 163, 57): '"""api_endpoint"""'}, {}), "('api_endpoint')", False, 'from indico_ravem.plugin import RavemPlugin\n'), ((170, 9, 170, 33), 'pytest.raises', 'pytest.raises', ({(170, 23, 170, 32): 'HTTPError'}, {}), '(HTTPError)', False, 'import pytest\n'), ((171, 8, 171, 64), 'indico_ravem.util.ravem_api_call', 'ravem_api_call', (), '', False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((186, 15, 186, 40), 'indico_ravem.util.has_access', 'has_access', ({(186, 26, 186, 39): 'event_vc_room'}, {}), '(event_vc_room)', False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((197, 15, 197, 40), 'indico_ravem.util.has_access', 'has_access', ({(197, 26, 197, 39): 'event_vc_room'}, {}), '(event_vc_room)', False, 'from indico_ravem.util import has_access, ravem_api_call\n'), ((176, 24, 176, 64), 'indico_ravem.plugin.RavemPlugin.settings.get', 'RavemPlugin.settings.get', ({(176, 49, 176, 63): '"""api_endpoint"""'}, {}), "('api_endpoint')", False, 'from indico_ravem.plugin import RavemPlugin\n')]