示例#1
0
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)
示例#2
0
def client():
    return Webodm()
示例#3
0
def test_init_missing_username():
    with pytest.raises(AttributeError) as e:
        Webodm(password='******')
    assert 'Password passed, but username is missing.' in str(e.value)
示例#4
0
def test_init_missing_password():
    with pytest.raises(AttributeError) as e:
        Webodm(username='******')
    assert 'Username passed, but password is missing.' in str(e.value)
示例#5
0
def test_init_authenticated(mocker):
    mocker.patch('requests.post', side_effect=mocked_requests_post)
    client = Webodm('user', 'password123')
    assert client.token == '123456'
示例#6
0
def auth_client():
    return Webodm('user', 'password123')
示例#7
0
def test_init_ok(mocker):
    mocker.patch('webodm.services.AuthService.auth', side_effect=mocked_token)
    client = Webodm('user', 'password123')
    assert client.token == '123456'