Skip to content

Commit

Permalink
s/profile/social_profile (#79)
Browse files Browse the repository at this point in the history
* s/profile/social_profile

* fix linting
  • Loading branch information
matin authored Dec 9, 2024
1 parent 00bb84f commit c3e3ced
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
14 changes: 7 additions & 7 deletions garth/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Client:
backoff_factor: float = 0.5
pool_connections: int = 10
pool_maxsize: int = 10
_profile: Dict[str, Any] | None = None
_social_profile: Dict[str, Any] | None = None

def __init__(self, session: Session | None = None, **kwargs):
self.sess = session if session else Session()
Expand Down Expand Up @@ -92,19 +92,19 @@ def configure(
self.sess.mount("https://", adapter)

@property
def profile(self):
if not self._profile:
self._profile = self.connectapi(
def social_profile(self):
if not self._social_profile:
self._social_profile = self.connectapi(
"/userprofile-service/socialProfile"
)
assert isinstance(
self._profile, dict
self._social_profile, dict
), "No profile from connectapi"
return self._profile
return self._social_profile

@property
def username(self):
return self.profile["userName"]
return self.social_profile["userName"]

def request(
self,
Expand Down
12 changes: 8 additions & 4 deletions tests/test_http.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import tempfile
import time
from typing import Any, cast

import pytest
from requests.adapters import HTTPAdapter
Expand Down Expand Up @@ -143,15 +144,18 @@ def mock_input(_):

@pytest.mark.vcr
def test_username(authed_client: Client):
assert authed_client._profile is None
assert authed_client._social_profile is None
assert authed_client.username
assert authed_client._profile
assert authed_client._social_profile


@pytest.mark.vcr
def test_connectapi(authed_client: Client):
stress = authed_client.connectapi(
"/usersummary-service/stats/stress/daily/2023-07-21/2023-07-21"
stress = cast(
list[dict[str, Any]],
authed_client.connectapi(
"/usersummary-service/stats/stress/daily/2023-07-21/2023-07-21"
),
)
assert stress
assert isinstance(stress, list)
Expand Down

0 comments on commit c3e3ced

Please sign in to comment.