Skip to content

Commit

Permalink
add unit test for endpoint resolution caching (#2770)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlm6693 authored Nov 30, 2022
1 parent c19a85d commit 85499a8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/unit/test_endpoint_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import json
import logging
import os
from unittest.mock import Mock

import pytest

Expand Down Expand Up @@ -433,3 +434,20 @@ def test_auth_schemes_conversion_first_authtype_unknown(
at, sc = empty_resolver.auth_schemes_to_signing_ctx(auth_schemes)
assert at == 'bar'
assert sc == {'region': 'ap-south-2', 'signing_name': 's3'}


def test_endpoint_resolution_caches(endpoint_provider, monkeypatch):
mock_evaluate = Mock()
monkeypatch.setattr(RuleSet, "evaluate", mock_evaluate)
for _ in range(5):
endpoint_provider.resolve_endpoint(Region="us-east-2")
mock_evaluate.assert_called_once_with({"Region": "us-east-2"})


def test_endpoint_reevaluates_result(endpoint_provider, monkeypatch):
regions = ["us-east-1", "us-west-2"]
mock_evaluate = Mock()
monkeypatch.setattr(RuleSet, "evaluate", mock_evaluate)
for region in regions:
endpoint_provider.resolve_endpoint(Region=region)
assert mock_evaluate.call_count == 2

0 comments on commit 85499a8

Please sign in to comment.