-
Notifications
You must be signed in to change notification settings - Fork 56
Fix bugs identified in #72, #74, and #75 #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
060b060
1fdcb5c
608842a
5001aad
2d3d289
11e3039
0ceb1b7
27c1640
1b8c922
3bed103
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -304,7 +304,7 @@ class TableInfo(object): | |
default=None | ||
) | ||
_secondary_indexes = attr.ib( | ||
validator=attr.validators.optional(iterable_validator(set, TableIndex)), | ||
validator=attr.validators.optional(iterable_validator(list, TableIndex)), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the type annotation for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope, that was an oversight |
||
default=None | ||
) | ||
|
||
|
@@ -378,10 +378,10 @@ def refresh_indexed_attributes(self, client): | |
table = client.describe_table(TableName=self.name)['Table'] | ||
self._primary_index = TableIndex.from_key_schema(table['KeySchema']) | ||
|
||
self._secondary_indexes = set() | ||
self._secondary_indexes = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there anything that relied on the unordered property of I didn't see anything in my quick look but you know the code base best. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we're actually not doing anything with it at all at the moment, it's just being opportunistically collected since it's all in the same API call. I went with the change to list rather than tuple to retain the mutability and the change away from set rather than adding hash capability to TableIndex because I think the later is something that, while it might be useful later, needs more thought if we want to do. |
||
for group in ('LocalSecondaryIndexes', 'GlobalSecondaryIndexes'): | ||
try: | ||
for index in table[group]: | ||
self._secondary_indexes.add(TableIndex.from_key_schema(index['KeySchema'])) | ||
self._secondary_indexes.append(TableIndex.from_key_schema(index['KeySchema'])) | ||
except KeyError: | ||
pass # Not all tables will have secondary indexes. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
"""Functional tests for ``dynamodb_encryption_sdk.material_providers.most_recent``.""" | ||
from mock import MagicMock, sentinel | ||
import pytest | ||
|
||
from dynamodb_encryption_sdk.material_providers.most_recent import MostRecentProvider | ||
from dynamodb_encryption_sdk.material_providers.store import ProviderStore | ||
|
||
pytestmark = [pytest.mark.functional, pytest.mark.local] | ||
|
||
|
||
def test_failed_lock_acquisition(): | ||
store = MagicMock(__class__=ProviderStore) | ||
provider = MostRecentProvider( | ||
provider_store=store, | ||
material_name='my material', | ||
version_ttl=10.0 | ||
) | ||
provider._version = 9 | ||
provider._cache.put(provider._version, sentinel.nine) | ||
|
||
with provider._lock: | ||
test = provider._get_most_recent_version(allow_local=True) | ||
|
||
assert test is sentinel.nine | ||
assert not store.mock_calls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not ideal, but with the travel and everything in play, if you want to put a reasonable date in here I can commit to getting it pushed by then, depending on your thoughts on the rest of the comments.