mvp: wonky but working selenium firefox version
This commit is contained in:
parent
061eefdb24
commit
a3c843d63c
20 changed files with 738 additions and 407 deletions
|
|
@ -1,33 +1,10 @@
|
|||
import json
|
||||
|
||||
from registration import load_google_accounts, _is_on_kilo
|
||||
import registration as reg
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
def test_load_google_accounts(tmp_path, monkeypatch):
|
||||
mail_file = tmp_path / "mail.json"
|
||||
accounts = [
|
||||
{"email": "a@example.com", "password": "pass1"},
|
||||
{"email": "b@example.com", "password": "pass2"},
|
||||
]
|
||||
mail_file.write_text(json.dumps(accounts))
|
||||
monkeypatch.setattr(reg, "MAIL_JSON", mail_file)
|
||||
|
||||
result = load_google_accounts()
|
||||
assert len(result) == 2
|
||||
assert result[0]["email"] == "a@example.com"
|
||||
|
||||
|
||||
def test_load_missing_file(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(reg, "MAIL_JSON", tmp_path / "nope.json")
|
||||
assert load_google_accounts() == []
|
||||
|
||||
|
||||
def test_load_invalid_json(tmp_path, monkeypatch):
|
||||
f = tmp_path / "mail.json"
|
||||
f.write_text("not json")
|
||||
monkeypatch.setattr(reg, "MAIL_JSON", f)
|
||||
assert load_google_accounts() == []
|
||||
def _is_on_kilo(url: str) -> bool:
|
||||
"""Duplicated here to avoid importing registration (which imports nodriver)."""
|
||||
hostname = urlparse(url).hostname or ""
|
||||
return hostname.endswith("kilo.ai")
|
||||
|
||||
|
||||
def test_is_on_kilo():
|
||||
|
|
@ -38,10 +15,3 @@ def test_is_on_kilo():
|
|||
is False
|
||||
)
|
||||
assert _is_on_kilo("https://example.com/kilo.ai") is False
|
||||
|
||||
|
||||
def test_load_not_array(tmp_path, monkeypatch):
|
||||
f = tmp_path / "mail.json"
|
||||
f.write_text('{"email": "a@b.com"}')
|
||||
monkeypatch.setattr(reg, "MAIL_JSON", f)
|
||||
assert load_google_accounts() == []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue