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)
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
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)
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
def no_fetch_openvidu_instance(): yield OpenVidu(URL_BASE, SECRET, initial_fetch=False)
def openvidu_instance(requests_mock): requests_mock.get(urljoin(URL_BASE, 'api/sessions'), json=SESSIONS) yield OpenVidu(URL_BASE, SECRET)