Skip to content

Commit a166230

Browse files
committed
minor docs and comment updates
1 parent f4088de commit a166230

File tree

5 files changed

+5
-19
lines changed

5 files changed

+5
-19
lines changed

docs/DEVELOPMENT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Conventions, Patterns, and Development Guide
22

3-
## Development Environment Setup
3+
## Set up Development Environment
44

55
### Prerequisites
66

77
- Python 3.13+
88
- PDM
99
- Git
1010

11-
### Initial Setup
11+
### Download and Install the Source Code
1212

1313
1. Clone the repository:
1414

@@ -206,7 +206,7 @@ Method aliases were implemented for several important reasons:
206206
direct aliases, developers can choose the approach that best fits their needs
207207
\- organization or conciseness.
208208

209-
All method aliases are set up in the `_setup_method_aliases()` method in the
209+
All method aliases are set up in the `_set_up_method_aliases()` method in the
210210
[`FitbitClient`](fitbit_client/client.py) class, which is called during
211211
initialization. Each alias is a direct reference to the corresponding resource
212212
method, ensuring consistent behavior regardless of how the method is accessed.

fitbit_client/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def __init__(
235235
self.logger.debug("Fitbit client initialized successfully")
236236

237237
# Set up method aliases
238-
self._setup_method_aliases()
238+
self._set_up_method_aliases()
239239

240240
def authenticate(self, force_new: bool = False) -> bool:
241241
"""
@@ -268,7 +268,7 @@ def authenticate(self, force_new: bool = False) -> bool:
268268
self.logger.error(f"System error during authentication: {str(e)}")
269269
raise
270270

271-
def _setup_method_aliases(self) -> None:
271+
def _set_up_method_aliases(self) -> None:
272272
"""Set up direct access to resource methods as client attributes for convenience."""
273273
self.logger.debug("Setting up method aliases")
274274

tests/auth/test_callback_server.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,12 @@ def test_initialization_with_valid_uri(self):
7979

8080
def test_create_handler(self, server):
8181
"""Test the factory function for creating CallbackHandler instances"""
82-
# Setup mock objects
8382
mock_request = MagicMock()
8483
mock_client_address = ("127.0.0.1", 1234)
8584
mock_server = MagicMock()
8685

8786
# Patch the CallbackHandler to verify it gets instantiated correctly
8887
with patch("fitbit_client.auth.callback_server.CallbackHandler") as mock_handler_class:
89-
# Setup the mock to return a mock instance
9088
mock_handler = MagicMock()
9189
mock_handler_class.return_value = mock_handler
9290

@@ -361,7 +359,6 @@ def test_wait_for_callback_success(self, server):
361359
def test_stop_server_removes_temp_files(self, server):
362360
"""Test that temporary files are cleaned up"""
363361
with patch("fitbit_client.auth.callback_server.unlink") as mock_unlink:
364-
# Setup mock temp files
365362
server.cert_file = Mock()
366363
server.cert_file.name = "test_cert.pem"
367364
server.key_file = Mock()
@@ -383,7 +380,6 @@ def test_stop_server_handles_cleanup_errors(self, server):
383380
with patch(
384381
"fitbit_client.auth.callback_server.unlink", side_effect=Exception("Cleanup Error")
385382
):
386-
# Setup mock temp files
387383
server.cert_file = Mock()
388384
server.cert_file.name = "test_cert.pem"
389385
server.key_file = Mock()

tests/auth/test_oauth.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ def test_authenticate_force_new(self, oauth):
191191
"expires_at": time() + 3600,
192192
}
193193

194-
# Setup mocks
195194
oauth.is_authenticated = Mock(return_value=True)
196195
oauth.get_authorization_url = Mock(return_value=("test_url", "test_state"))
197196
oauth.fetch_token = Mock(return_value=mock_token)
@@ -215,7 +214,6 @@ def test_authenticate_uses_fetch_token_directly(self, oauth):
215214
"expires_at": time() + 3600,
216215
}
217216

218-
# Setup mocks
219217
oauth.get_authorization_url = Mock(return_value=("test_url", "test_state"))
220218
oauth.fetch_token = Mock(return_value=mock_token)
221219
oauth.is_authenticated = Mock(return_value=False)
@@ -356,7 +354,6 @@ def test_fetch_token_catches_oauth_errors(self, oauth):
356354
mock_session.fetch_token.side_effect = original_error
357355
oauth.session = mock_session
358356

359-
# Setup logger mock to capture log message
360357
mock_logger = Mock()
361358
oauth.logger = mock_logger
362359

@@ -386,7 +383,6 @@ def test_fetch_token_no_matching_error_type(self, oauth):
386383
mock_session.fetch_token.side_effect = original_error
387384
oauth.session = mock_session
388385

389-
# Setup logger mock to capture log message
390386
mock_logger = Mock()
391387
oauth.logger = mock_logger
392388

@@ -479,7 +475,6 @@ def test_refresh_token_wraps_unexpected_errors(self, oauth):
479475
mock_session.refresh_token.side_effect = unexpected_error
480476
oauth.session = mock_session
481477

482-
# Setup logger mock to capture log message
483478
mock_logger = Mock()
484479
oauth.logger = mock_logger
485480

@@ -677,7 +672,6 @@ def test_is_authenticated_no_token(self, oauth):
677672

678673
def test_is_authenticated_with_valid_token(self, oauth):
679674
"""Test is_authenticated with a non-expired token"""
680-
# Setup a valid token with future expiry
681675
future_time = time() + 3600 # 1 hour in the future
682676
oauth.token = {"access_token": "valid_token", "expires_at": future_time}
683677

@@ -688,7 +682,6 @@ def test_is_authenticated_with_valid_token(self, oauth):
688682

689683
def test_is_authenticated_with_expired_token(self, oauth):
690684
"""Test is_authenticated with an expired token"""
691-
# Setup an expired token
692685
past_time = time() - 3600 # 1 hour in the past
693686
oauth.token = {"access_token": "expired_token", "expires_at": past_time}
694687

tests/resources/test_base.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,7 @@ def test_make_direct_request_unexpected_content_type(mock_get_calling, base_reso
672672
@patch("fitbit_client.resources.base.BaseResource._get_retry_after")
673673
def test_direct_request_rate_limit_retry(mock_get_retry, mock_sleep, base_resource, mock_logger):
674674
"""Test rate limit retry for direct requests."""
675-
# This tests lines 691-693 in base.py
676675

677-
# Setup mock responses
678676
rate_limit_response = Mock()
679677
rate_limit_response.status_code = 429
680678
rate_limit_response.headers = {
@@ -1022,7 +1020,6 @@ def test_rate_limit_retry_with_fitbit_headers(
10221020
mock_sleep, base_resource, mock_oauth_session, mock_logger
10231021
):
10241022
"""Test that rate limit retry correctly uses Fitbit headers for retry timing."""
1025-
# Setup mock responses
10261023
rate_limit_response = Mock()
10271024
rate_limit_response.status_code = 429
10281025
rate_limit_response.headers = {

0 commit comments

Comments
 (0)