refactor!: a lot of stuff
This commit is contained in:
parent
d6396e4050
commit
0af7179596
15 changed files with 663 additions and 302 deletions
37
tests/test_registration_unit.py
Normal file
37
tests/test_registration_unit.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from providers.chatgpt.registration import (
|
||||
build_authorize_url,
|
||||
extract_verification_code,
|
||||
generate_birthdate_90s,
|
||||
generate_name,
|
||||
)
|
||||
|
||||
|
||||
def test_generate_name_shape():
|
||||
name = generate_name()
|
||||
parts = name.split(" ")
|
||||
assert len(parts) == 2
|
||||
assert all(p.isalpha() for p in parts)
|
||||
|
||||
|
||||
def test_generate_birthdate_90s_range():
|
||||
month, day, year = generate_birthdate_90s()
|
||||
assert 1 <= int(month) <= 12
|
||||
assert 1 <= int(day) <= 28
|
||||
assert 1990 <= int(year) <= 1999
|
||||
|
||||
|
||||
def test_extract_verification_code_prefers_chatgpt_phrase():
|
||||
text = "foo 123456 bar Your ChatGPT code is 654321"
|
||||
assert extract_verification_code(text) == "654321"
|
||||
|
||||
|
||||
def test_extract_verification_code_fallback_last_code():
|
||||
text = "codes 111111 and 222222"
|
||||
assert extract_verification_code(text) == "222222"
|
||||
|
||||
|
||||
def test_build_authorize_url_contains_required_params():
|
||||
url = build_authorize_url("challenge", "state123")
|
||||
assert "response_type=code" in url
|
||||
assert "code_challenge=challenge" in url
|
||||
assert "state=state123" in url
|
||||
Loading…
Add table
Add a link
Reference in a new issue