示例#1
0
def test_timeout2_tuple(mocker):
    # So we test if the value properly set
    openvidu_instance = OpenVidu(URL_BASE,
                                 SECRET,
                                 initial_fetch=False,
                                 timeout=(1, 2))

    mocker.patch.object(requests.Session, "request", autospec=True)

    openvidu_instance.fetch()

    args, kwargs = requests.Session.request.call_args

    assert kwargs['timeout'] == (1, 2)
示例#2
0
def test_timeout(requests_mock):
    openvidu_instance = OpenVidu(URL_BASE,
                                 SECRET,
                                 initial_fetch=False,
                                 timeout=2)

    # This will always raise the exception, regardless if timeout is set or not
    a = requests_mock.get(urljoin(URL_BASE, 'sessions'),
                          exc=requests.exceptions.ConnectTimeout)

    with pytest.raises(requests.exceptions.ConnectTimeout):
        openvidu_instance.fetch()

    assert a.called_once
示例#3
0
def openvidu_instance(requests_mock):
    requests_mock.get(urljoin(URL_BASE, 'api/sessions'), json=SESSIONS)
    requests_mock.get(urljoin(URL_BASE, 'api/sessions/TestSession'),
                      json=SESSIONS['content'][0])
    requests_mock.get(urljoin(URL_BASE, 'api/sessions/TestSession2'),
                      json=SESSIONS['content'][1])
    yield OpenVidu(URL_BASE, SECRET)
示例#4
0
def test_empty_with_no_fetch(requests_mock):
    a = requests_mock.get(urljoin(URL_BASE, 'sessions'), json=SESSIONS)
    openvidu_instance = OpenVidu(URL_BASE, SECRET, initial_fetch=False)

    assert not a.called_once

    assert openvidu_instance.sessions == []
    assert openvidu_instance.session_count == 0
示例#5
0
def no_fetch_openvidu_instance():
    yield OpenVidu(URL_BASE, SECRET, initial_fetch=False)
示例#6
0
def openvidu_instance(requests_mock):
    requests_mock.get(urljoin(URL_BASE, 'api/sessions'), json=SESSIONS)
    yield OpenVidu(URL_BASE, SECRET)