def test_authenticate_unable_to_login(mocker): mocker.patch('requests.post', side_effect=mocked_requests_post) with pytest.raises(NonFieldErrors) as e: Webodm('invalid', 'invalid') assert 'Unable to login with provided credentials.' in str(e.value)
def client(): return Webodm()
def test_init_missing_username(): with pytest.raises(AttributeError) as e: Webodm(password='******') assert 'Password passed, but username is missing.' in str(e.value)
def test_init_missing_password(): with pytest.raises(AttributeError) as e: Webodm(username='******') assert 'Username passed, but password is missing.' in str(e.value)
def test_init_authenticated(mocker): mocker.patch('requests.post', side_effect=mocked_requests_post) client = Webodm('user', 'password123') assert client.token == '123456'
def auth_client(): return Webodm('user', 'password123')
def test_init_ok(mocker): mocker.patch('webodm.services.AuthService.auth', side_effect=mocked_token) client = Webodm('user', 'password123') assert client.token == '123456'