Skip to content

Commit dd472a5

Browse files
committed
Revert "Fix signup_by_email (#320)"
This reverts commit 91c7c3c.
1 parent 7419787 commit dd472a5

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

tests/test_signup.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,23 @@
33
import pytest
44
import responses
55

6-
from tgtg import AUTH_POLLING_ENDPOINT, BASE_URL, SIGNUP_BY_EMAIL_ENDPOINT, TgtgClient
6+
from tgtg import BASE_URL, SIGNUP_BY_EMAIL_ENDPOINT, TgtgClient
77
from tgtg.exceptions import TgtgAPIError
88

99

1010
def test_signup_ok():
11-
responses.add(
12-
responses.POST,
13-
urljoin(BASE_URL, AUTH_POLLING_ENDPOINT),
14-
json={
15-
"access_token": "an_access_token",
16-
"refresh_token": "a_refresh_token",
17-
"startup_data": {"user": {"user_id": 1234}},
18-
},
19-
status=200,
20-
adding_headers={"set-cookie": "sweet sweet cookie"},
21-
)
22-
responses.add(
23-
responses.POST,
24-
urljoin(BASE_URL, AUTH_POLLING_ENDPOINT),
25-
status=202,
26-
)
2711
responses.add(
2812
responses.POST,
2913
urljoin(BASE_URL, SIGNUP_BY_EMAIL_ENDPOINT),
3014
json={
31-
"state": "WAIT",
32-
"polling_id": "a_polling_id",
15+
"login_response": {
16+
"access_token": "an_access_token",
17+
"refresh_token": "a_refresh_token",
18+
}
3319
},
3420
status=200,
3521
)
36-
client = TgtgClient()
37-
client.signup_by_email(email="test@test.com")
22+
client = TgtgClient().signup_by_email(email="test@test.com")
3823
assert client.access_token == "an_access_token"
3924
assert client.refresh_token == "a_refresh_token"
4025

tgtg/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,11 @@ def signup_by_email(
390390
timeout=self.timeout,
391391
)
392392
if response.status_code == HTTPStatus.OK:
393-
first_signup_response = response.json()
394-
if first_signup_response["state"] == "WAIT":
395-
self.start_polling(first_signup_response["polling_id"])
396-
else:
397-
raise TgtgAPIError(response.status_code, response.content)
393+
self.access_token = response.json()["login_response"]["access_token"]
394+
self.refresh_token = response.json()["login_response"]["refresh_token"]
395+
self.last_time_token_refreshed = datetime.datetime.now()
396+
397+
return self
398398
else:
399399
raise TgtgAPIError(response.status_code, response.content)
400400

0 commit comments

Comments
 (0)