test: more code coverage
This commit is contained in:
@@ -41,17 +41,21 @@ class TestCrossFitBookerInit:
|
||||
def test_init_missing_credentials(self):
|
||||
"""Test initialization fails with missing credentials"""
|
||||
with patch.dict(os.environ, {}, clear=True):
|
||||
with pytest.raises(ValueError, match="Missing environment variables"):
|
||||
try:
|
||||
CrossFitBooker()
|
||||
except ValueError as e:
|
||||
assert str(e) == "Missing environment variables"
|
||||
|
||||
def test_init_partial_credentials(self):
|
||||
"""Test initialization fails with partial credentials"""
|
||||
with patch.dict(os.environ, {
|
||||
'CROSSFIT_USERNAME': 'test_user'
|
||||
# Missing PASSWORD
|
||||
}):
|
||||
with pytest.raises(ValueError, match="Missing environment variables"):
|
||||
}, clear=True):
|
||||
try:
|
||||
CrossFitBooker()
|
||||
except ValueError as e:
|
||||
assert str(e) == "Missing environment variables"
|
||||
|
||||
|
||||
class TestCrossFitBookerAuthHeaders:
|
||||
@@ -214,4 +218,22 @@ class TestCrossFitBookerGetAvailableSessions:
|
||||
assert result["success"] is True
|
||||
|
||||
@patch('requests.Session.post')
|
||||
def test
|
||||
def test_get_available_sessions_failure(self, mock_post):
|
||||
"""Test get_available_sessions with API failure"""
|
||||
mock_response = Mock()
|
||||
mock_response.status_code = 400
|
||||
mock_response.text = "Bad Request"
|
||||
|
||||
mock_post.return_value = mock_response
|
||||
|
||||
with patch.dict(os.environ, {
|
||||
'CROSSFIT_USERNAME': 'test_user',
|
||||
'CROSSFIT_PASSWORD': 'test_pass'
|
||||
}):
|
||||
booker = CrossFitBooker()
|
||||
booker.auth_token = "test_token"
|
||||
booker.user_id = "12345"
|
||||
|
||||
result = booker.get_available_sessions(date(2025, 7, 24), date(2025, 7, 25))
|
||||
|
||||
assert result is None
|
||||
Reference in New Issue
Block a user