Skip to content

Commit 5664833

Browse files
committed
full test coverage
1 parent ed4c0e1 commit 5664833

26 files changed

+2511
-643
lines changed

fitbit_client/auth/callback_server.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,13 @@ def start(self) -> None:
180180
error_type="system",
181181
)
182182

183-
except SystemException:
184-
raise
185183
except Exception as e:
186-
error_msg = f"Failed to start callback server: {str(e)}"
187-
self.logger.error(error_msg)
188-
raise SystemException(message=error_msg, status_code=500, error_type="system")
184+
# Only catch non-SystemException exceptions here
185+
if not isinstance(e, SystemException):
186+
error_msg = f"Failed to start callback server: {str(e)}"
187+
self.logger.error(error_msg)
188+
raise SystemException(message=error_msg, status_code=500, error_type="system")
189+
raise
189190

190191
def wait_for_callback(self, timeout: int = 300) -> Optional[str]:
191192
"""Wait for OAuth callback

fitbit_client/auth/oauth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
token_cache_path: str,
6363
use_callback_server: bool = True,
6464
) -> None:
65-
self.logger = getLogger("fitbit_client.oauth") # Add this line
65+
self.logger = getLogger("fitbit_client.oauth")
6666
self.client_id = client_id
6767
self.client_secret = client_secret
6868
self.redirect_uri = redirect_uri

fitbit_client/utils/helpers.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ def to_camel_case(snake_str: str, cap_first: bool = False) -> str:
2424
snake_str: a snake_case string
2525
cap_first: if True, returns CamelCase, otherwise camelCase (default is False)
2626
"""
27+
if not snake_str: # handle empty string case
28+
return ""
29+
2730
camel_string = "".join(l.capitalize() for l in snake_str.lower().split("_"))
2831
if cap_first:
2932
return camel_string
@@ -33,13 +36,13 @@ def to_camel_case(snake_str: str, cap_first: bool = False) -> str:
3336

3437
def print_json(obj: JSONType, f: TextIO = stdout):
3538
"""
36-
Prett print JSON-serializable objects.
39+
Pretty print JSON-serializable objects.
3740
3841
Args:
3942
obj: Any JSON serializable object
4043
f: A file-like object to which the object should be serialized. Default: stdout
4144
"""
42-
print(dumps(obj, ensure_ascii=False, indent=2), file=f)
45+
print(dumps(obj, ensure_ascii=False, indent=2), file=f, flush=True)
4346

4447

4548
def date_range(start_date: str, end_date: str) -> Iterator[str]:
@@ -67,5 +70,5 @@ def date_range(start_date: str, end_date: str) -> Iterator[str]:
6770
while start <= end:
6871
yield start.isoformat()
6972
start += timedelta(days=1)
70-
else: # Handles start == end
73+
else: # start == end
7174
yield start.isoformat()

fitbit_client/utils/pagination_validation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
def validate_pagination_params(
19-
*,
2019
before_field: str = "before_date",
2120
after_field: str = "after_date",
2221
sort_field: str = "sort",

0 commit comments

Comments
 (0)