Skip to content
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

Allow aiodynamo to fetch credentials for snapstart lambdas. #196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/aiodynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,12 @@ def serialize_dict(value: Mapping[str, Any]) -> Dict[str, Dict[str, Any]]:


def parse_amazon_timestamp(timestamp: str) -> datetime.datetime:
return datetime.datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%SZ").replace(
tzinfo=datetime.timezone.utc
)
if "." in timestamp:
value = datetime.datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%fZ")
else:
value = datetime.datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%SZ")

return value.replace(tzinfo=datetime.timezone.utc)


async def wait(
Expand Down
24 changes: 23 additions & 1 deletion tests/unit/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import base64
import datetime
from decimal import Decimal
from functools import partial
from typing import Any, Callable, Dict
Expand All @@ -10,7 +11,28 @@
)

from aiodynamo.types import NumericTypeConverter
from aiodynamo.utils import deserialize, dy2py
from aiodynamo.utils import deserialize, dy2py, parse_amazon_timestamp


@pytest.mark.parametrize(
("amazon_timestamp", "expected"),
[
(
"2020-03-12T15:37:51Z",
datetime.datetime(2020, 3, 12, 15, 37, 51, tzinfo=datetime.timezone.utc),
),
(
"2024-12-06T08:03:52.192266Z",
datetime.datetime(
2024, 12, 6, 8, 3, 52, 192266, tzinfo=datetime.timezone.utc
),
),
],
)
def test_parse_amazon_timestamp(
amazon_timestamp: str, expected: datetime.datetime
) -> None:
assert parse_amazon_timestamp(amazon_timestamp) == expected


def test_binary_decode() -> None:
Expand Down
Loading