Skip to content

Commit

Permalink
Add extra login option tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wvanhed committed Jan 2, 2024
1 parent bc531ca commit 62627a9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/test_mijnbibliotheek.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from mijnbib import MijnBibliotheek
from mijnbib.errors import AuthenticationError
from mijnbib.login_handlers import LoginByForm
from mijnbib.login_handlers import LoginByForm, LoginByOAuth

CONFIG_FILE = "mijnbib.ini"

Expand Down Expand Up @@ -36,11 +36,25 @@ def submit(self, *args, **kwargs) -> BinaryIO:
return io.BytesIO(self._form_response)


class TestFakedLogins:
def test_default_login_is_by_form(self):
class TestLoginByOption:
def test_login_by_options_default_is_by_form(self):
mb = MijnBibliotheek("user", "pwd", "city")
assert mb._login_handler_class == LoginByForm

def test_login_by_options_by_form(self):
mb = MijnBibliotheek("user", "pwd", "city", "form")
assert mb._login_handler_class == LoginByForm

def test_login_by_options_by_oauth(self):
mb = MijnBibliotheek("user", "pwd", "city", "oauth")
assert mb._login_handler_class == LoginByOAuth

def test_login_by_options_invalid_option_raises_error(self):
with pytest.raises(ValueError):
MijnBibliotheek("user", "pwd", "city", login_by="foo")


class TestFakedLogins:
def test_login_ok(self):
mb = MijnBibliotheek("user", "pwd", "city")
mb._br = FakeMechanizeBrowser(form_response="Profiel") # type: ignore
Expand Down

0 comments on commit 62627a9

Please sign in to comment.