Skip to content

Commit c208e5d

Browse files
author
Abel Milash
committed
test: review fixes and assertion strengthening
1 parent ea3aaaf commit c208e5d

5 files changed

Lines changed: 155 additions & 49 deletions

File tree

tests/unit/core/test_auth.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ class TestAuthManager(unittest.TestCase):
1414

1515
def test_non_token_credential_raises(self):
1616
"""_AuthManager raises TypeError when credential does not implement TokenCredential."""
17-
with self.assertRaises(TypeError):
17+
with self.assertRaises(TypeError) as ctx:
1818
_AuthManager("not-a-credential")
19+
self.assertEqual(
20+
str(ctx.exception),
21+
"credential must implement azure.core.credentials.TokenCredential.",
22+
)
1923

2024
def test_acquire_token_returns_token_pair(self):
2125
"""_acquire_token calls get_token and returns a _TokenPair with scope and token."""
@@ -29,4 +33,3 @@ def test_acquire_token_returns_token_pair(self):
2933
self.assertIsInstance(result, _TokenPair)
3034
self.assertEqual(result.resource, "https://org.crm.dynamics.com/.default")
3135
self.assertEqual(result.access_token, "my-access-token")
32-

tests/unit/core/test_http_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_default_timeout_overrides_per_method_default(self):
4949
_, kwargs = mock_req.call_args
5050
self.assertEqual(kwargs["timeout"], 30.0)
5151

52-
def test_explicit_timeout_in_kwargs_is_not_overridden(self):
52+
def test_explicit_timeout_kwarg_takes_precedence(self):
5353
"""If timeout is already in kwargs it is passed through unchanged."""
5454
client = _HttpClient(retries=1, timeout=30.0)
5555
with patch("requests.request", return_value=self._make_response()) as mock_req:
@@ -66,7 +66,7 @@ def _make_response(self):
6666
resp.status_code = 200
6767
return resp
6868

69-
def test_uses_requests_request_when_no_session(self):
69+
def test_uses_direct_request_without_session(self):
7070
"""Without a session, _request uses requests.request directly."""
7171
client = _HttpClient(retries=1)
7272
with patch("requests.request", return_value=self._make_response()) as mock_req:

tests/unit/core/test_http_errors.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ def test_correlation_id_shared_inside_call_scope():
182182
assert h1["x-ms-correlation-id"] == h2["x-ms-correlation-id"]
183183

184184

185-
# --- ValidationError / SQLParseError / HttpError optional fields ---
186-
187185
def test_validation_error_instantiates():
188186
"""ValidationError can be raised and carries the correct code."""
189187
from PowerPlatform.Dataverse.core.errors import ValidationError

0 commit comments

Comments
 (0)