mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
test(sap): check the token refreshes inside the expiry buffer
This commit is contained in:
parent
7ad39b6b4b
commit
121f39acc9
1 changed files with 14 additions and 0 deletions
|
|
@ -160,3 +160,17 @@ def test_credentials_without_authentication_mode(monkeypatch):
|
|||
# validate_credentials should raise because no authentication mode is provided
|
||||
with pytest.raises(ValueError, match="SAP AI Core credentials are incomplete"):
|
||||
sap_credentials.validate_credentials(**creds)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"expires_in, expected_token_requests",
|
||||
[(43200, 1), (3000, 3)],
|
||||
ids=["reused-while-valid", "refreshed-inside-60-minute-buffer"],
|
||||
)
|
||||
def test_token_is_shared_across_token_creators_until_refresh_buffer(aicore, expires_in, expected_token_requests):
|
||||
aicore.token.respond(json={"access_token": "mock-token", "expires_in": expires_in})
|
||||
|
||||
tokens = tuple(sap_credentials.get_token_creator()[0]() for _ in range(3))
|
||||
|
||||
assert tokens == ("Bearer mock-token",) * 3
|
||||
assert aicore.token.call_count == expected_token_requests
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue