Yes.
This commit is contained in:
parent
d369ac4232
commit
a2c86dfea7
|
|
@ -93,15 +93,16 @@ def test_login_resume_fail_falls_back(mock_garmin, mock_sso):
|
|||
mock_login.return_value = (MagicMock(), MagicMock())
|
||||
|
||||
inst = mock_garmin.return_value
|
||||
inst.login.side_effect = Exception("Resume fail")
|
||||
inst.login.side_effect = [Exception("Resume fail"), None]
|
||||
|
||||
client = GarminClient(email="test", password="test")
|
||||
# Step 3 will check if creds exist. If they do, it goes to login.
|
||||
# But resume_fail_falls_back test expects FAILURE if not force_login.
|
||||
# We expect SUCCESS because it should fall back to a fresh login
|
||||
with patch("os.path.exists", return_value=True), \
|
||||
patch("os.path.getsize", return_value=100), \
|
||||
patch("os.remove"):
|
||||
assert client.login() == "FAILURE"
|
||||
assert client.login() == "SUCCESS"
|
||||
mock_login.assert_called_once()
|
||||
|
||||
def test_login_resume_fail_force_retries(mock_garmin, mock_sso):
|
||||
mock_login, _ = mock_sso
|
||||
|
|
@ -118,16 +119,20 @@ def test_login_resume_fail_force_retries(mock_garmin, mock_sso):
|
|||
assert client.login(force_login=True) == "SUCCESS"
|
||||
assert mock_login.called
|
||||
|
||||
def test_login_empty_token_cleanup(mock_garmin):
|
||||
client = GarminClient()
|
||||
def test_login_empty_token_cleanup(mock_garmin, monkeypatch):
|
||||
monkeypatch.setenv("GARMIN_EMAIL", "")
|
||||
monkeypatch.setenv("GARMIN_PASSWORD", "")
|
||||
client = GarminClient(email="", password="")
|
||||
with patch("os.path.exists", return_value=True), \
|
||||
patch("os.path.getsize", return_value=0), \
|
||||
patch("os.remove") as mock_remove:
|
||||
assert client.login() == "FAILURE"
|
||||
assert mock_remove.called
|
||||
|
||||
def test_login_json_error_cleanup(mock_garmin):
|
||||
client = GarminClient()
|
||||
def test_login_json_error_cleanup(mock_garmin, monkeypatch):
|
||||
monkeypatch.setenv("GARMIN_EMAIL", "")
|
||||
monkeypatch.setenv("GARMIN_PASSWORD", "")
|
||||
client = GarminClient(email="", password="")
|
||||
inst = mock_garmin.return_value
|
||||
inst.login.side_effect = Exception("Expecting value: line 1 column 1")
|
||||
|
||||
|
|
@ -137,6 +142,15 @@ def test_login_json_error_cleanup(mock_garmin):
|
|||
assert client.login() == "FAILURE"
|
||||
assert mock_remove.called
|
||||
|
||||
def test_login_general_error(mock_garmin, mock_sso):
|
||||
mock_login, _ = mock_sso
|
||||
mock_login.side_effect = Exception("General failure")
|
||||
|
||||
client = GarminClient(email="test", password="test")
|
||||
# Resume fails, then new login fails
|
||||
with patch("os.path.exists", return_value=False):
|
||||
assert client.login(force_login=True) == "FAILURE"
|
||||
|
||||
def test_login_missing_creds(mock_garmin, monkeypatch):
|
||||
monkeypatch.setenv("GARMIN_EMAIL", "")
|
||||
monkeypatch.setenv("GARMIN_PASSWORD", "")
|
||||
|
|
|
|||
Loading…
Reference in New Issue