-
-
Notifications
You must be signed in to change notification settings - Fork 53
next release - feature parity - high testing coverage (Sourcery refactored) #175
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -331,9 +331,11 @@ async def get_session(self) -> Union[Session, None]: | |
| if current_session.expires_at | ||
| else False | ||
| ) | ||
| if not has_expired: | ||
| return current_session | ||
| return await self._call_refresh_token(current_session.refresh_token) | ||
| return ( | ||
| await self._call_refresh_token(current_session.refresh_token) | ||
| if has_expired | ||
| else current_session | ||
| ) | ||
|
|
||
| async def get_user(self, jwt: Union[str, None] = None) -> UserResponse: | ||
| """ | ||
|
|
@@ -582,7 +584,6 @@ async def _save_session(self, session: Session) -> None: | |
| self._in_memory_session = session | ||
| expire_at = session.expires_at | ||
| if expire_at: | ||
| pass | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| time_now = round(time()) | ||
| expire_in = expire_at - time_now | ||
| refresh_duration_before_expires = ( | ||
|
|
@@ -648,8 +649,7 @@ def _get_valid_session( | |
| except ValueError: | ||
| return None | ||
| try: | ||
| session = Session.parse_obj(data) | ||
| return session | ||
| return Session.parse_obj(data) | ||
|
Comment on lines
-651
to
+652
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| except Exception: | ||
| return None | ||
|
|
||
|
|
@@ -658,9 +658,7 @@ def _get_param( | |
| query_params: Dict[str, List[str]], | ||
| name: str, | ||
| ) -> Union[str, None]: | ||
| if name in query_params: | ||
| return query_params[name][0] | ||
| return None | ||
| return query_params[name][0] if name in query_params else None | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def _is_implicit_grant_flow(self, url: str) -> bool: | ||
| result = urlparse(url) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -331,9 +331,11 @@ def get_session(self) -> Union[Session, None]: | |
| if current_session.expires_at | ||
| else False | ||
| ) | ||
| if not has_expired: | ||
| return current_session | ||
| return self._call_refresh_token(current_session.refresh_token) | ||
| return ( | ||
| self._call_refresh_token(current_session.refresh_token) | ||
| if has_expired | ||
| else current_session | ||
| ) | ||
|
Comment on lines
-334
to
+338
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def get_user(self, jwt: Union[str, None] = None) -> UserResponse: | ||
| """ | ||
|
|
@@ -582,7 +584,6 @@ def _save_session(self, session: Session) -> None: | |
| self._in_memory_session = session | ||
| expire_at = session.expires_at | ||
| if expire_at: | ||
| pass | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| time_now = round(time()) | ||
| expire_in = expire_at - time_now | ||
| refresh_duration_before_expires = ( | ||
|
|
@@ -648,8 +649,7 @@ def _get_valid_session( | |
| except ValueError: | ||
| return None | ||
| try: | ||
| session = Session.parse_obj(data) | ||
| return session | ||
| return Session.parse_obj(data) | ||
|
Comment on lines
-651
to
+652
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| except Exception: | ||
| return None | ||
|
|
||
|
|
@@ -658,9 +658,7 @@ def _get_param( | |
| query_params: Dict[str, List[str]], | ||
| name: str, | ||
| ) -> Union[str, None]: | ||
| if name in query_params: | ||
| return query_params[name][0] | ||
| return None | ||
| return query_params[name][0] if name in query_params else None | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def _is_implicit_grant_flow(self, url: str) -> bool: | ||
| result = urlparse(url) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,10 +79,7 @@ async def test_sign_in(client: AsyncGoTrueClient): | |
| async def test_sign_in_with_the_wrong_password(client: AsyncGoTrueClient): | ||
| expected_error_message = "Invalid login credentials" | ||
| try: | ||
| await client.sign_in( | ||
| email=email, | ||
| password=password + "2", | ||
| ) | ||
| await client.sign_in(email=email, password=f"{password}2") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| assert False | ||
| except APIError as e: | ||
| assert e.msg == expected_error_message | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,10 +79,7 @@ def test_sign_in(client: SyncGoTrueClient): | |
| def test_sign_in_with_the_wrong_password(client: SyncGoTrueClient): | ||
| expected_error_message = "Invalid login credentials" | ||
| try: | ||
| client.sign_in( | ||
| email=email, | ||
| password=password + "2", | ||
| ) | ||
| client.sign_in(email=email, password=f"{password}2") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| assert False | ||
| except APIError as e: | ||
| assert e.msg == expected_error_message | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
AsyncGoTrueClient.get_sessionrefactored with the following changes:reintroduce-else)assign-if-exp)swap-if-expression)