Skip to content

Commit 40f7b9a

Browse files
committed
cleaner
1 parent 23e9c55 commit 40f7b9a

File tree

8 files changed

+199
-196
lines changed

8 files changed

+199
-196
lines changed

.vscode/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@
44
"editor.insertSpaces": true,
55
"editor.detectIndentation": false
66
},
7-
"python.analysis.typeCheckingMode": "basic"
7+
"python.analysis.typeCheckingMode": "basic",
8+
"python.testing.pytestArgs": [
9+
"tests"
10+
],
11+
"python.testing.unittestEnabled": false,
12+
"python.testing.pytestEnabled": true
813
}

garth/http.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def configure(
8080
self.sess.mount("https://", adapter)
8181

8282
@property
83-
def username(self) -> str | None:
83+
def username(self):
8484
if not self._username:
8585
self._username = self.connectapi(
8686
"/userprofile-service/socialProfile"
@@ -97,7 +97,7 @@ def request(
9797
referrer: str | bool = False,
9898
headers: dict = {},
9999
**kwargs,
100-
):
100+
) -> Response:
101101
url = f"https://{subdomain}.{self.domain}{path}"
102102
if referrer is True and self.last_resp:
103103
headers["referer"] = self.last_resp.url
@@ -113,10 +113,10 @@ def request(
113113
self.last_resp.raise_for_status()
114114
return self.last_resp
115115

116-
def get(self, *args, **kwargs):
116+
def get(self, *args, **kwargs) -> Response:
117117
return self.request("GET", *args, **kwargs)
118118

119-
def post(self, *args, **kwargs):
119+
def post(self, *args, **kwargs) -> Response:
120120
return self.request("POST", *args, **kwargs)
121121

122122
def login(self, *args):

garth/sso.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,12 @@ def login(
4242
embedWidget="true",
4343
gauthHost=SSO,
4444
)
45-
SIGNIN_PARAMS = dict(
46-
id="gauth-widget",
45+
SIGNIN_PARAMS = SSO_EMBED_PARAMS | dict(
46+
gauthHost=SSO_EMBED,
4747
service=SSO_EMBED,
4848
source=SSO_EMBED,
4949
redirectAfterAccountLoginUrl=SSO_EMBED,
5050
redirectAfterAccountCreationUrl=SSO_EMBED,
51-
gauthHost=SSO_EMBED,
5251
)
5352

5453
# Set cookies
@@ -132,7 +131,7 @@ def handle_mfa(client: "http.Client", signin_params: dict) -> None:
132131
client.post(
133132
"sso",
134133
"/sso/verifyMFA/loginEnterMfaCode",
135-
params=signin_params | dict(embedWidget="true"),
134+
params=signin_params,
136135
referrer=True,
137136
data={
138137
"mfa-code": mfa_code,

garth/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.4.2"
1+
__version__ = "0.4.3"

tests/cassettes/test_login_email_password_fail.yaml

Lines changed: 43 additions & 43 deletions
Large diffs are not rendered by default.

tests/cassettes/test_login_success.yaml

Lines changed: 52 additions & 53 deletions
Large diffs are not rendered by default.

tests/cassettes/test_login_success_mfa.yaml

Lines changed: 89 additions & 89 deletions
Large diffs are not rendered by default.

tests/test_sso.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_login_success(client: Client):
3030
@pytest.mark.vcr
3131
def test_login_success_mfa(monkeypatch, client: Client):
3232
def mock_input(_):
33-
return "327751"
33+
return "671091"
3434

3535
monkeypatch.setattr("builtins.input", mock_input)
3636
oauth1, oauth2 = sso.login(

0 commit comments

Comments
 (0)