|
| 1 | +# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"). You |
| 4 | +# may not use this file except in compliance with the License. A copy of |
| 5 | +# the License is located at |
| 6 | +# |
| 7 | +# http://aws.amazon.com/apache2.0/ |
| 8 | +# |
| 9 | +# or in the "license" file accompanying this file. This file is |
| 10 | +# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF |
| 11 | +# ANY KIND, either express or implied. See the License for the specific |
| 12 | +# language governing permissions and limitations under the License. |
| 13 | +"""Functional tests for ``dynamodb_encryption_sdk.material_providers.most_recent``.""" |
| 14 | +from mock import MagicMock, sentinel |
| 15 | +import pytest |
| 16 | + |
| 17 | +from dynamodb_encryption_sdk.material_providers.most_recent import MostRecentProvider |
| 18 | +from dynamodb_encryption_sdk.material_providers.store import ProviderStore |
| 19 | + |
| 20 | +pytestmark = [pytest.mark.functional, pytest.mark.local] |
| 21 | + |
| 22 | + |
| 23 | +def test_failed_lock_acquisition(): |
| 24 | + store = MagicMock(__class__=ProviderStore) |
| 25 | + provider = MostRecentProvider( |
| 26 | + provider_store=store, |
| 27 | + material_name='my material', |
| 28 | + version_ttl=10.0 |
| 29 | + ) |
| 30 | + provider._version = 9 |
| 31 | + provider._cache.put(provider._version, sentinel.nine) |
| 32 | + |
| 33 | + with provider._lock: |
| 34 | + test = provider._get_most_recent_version(allow_local=True) |
| 35 | + |
| 36 | + assert test is sentinel.nine |
| 37 | + assert not store.mock_calls |
0 commit comments