Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# license information.
# --------------------------------------------------------------------------

from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from typing import Any, cast, Dict, Optional, Union

from ._generated._utils.serialization import Serializer
Expand Down Expand Up @@ -38,6 +38,8 @@ def _parse_datetime_from_str(string_datetime):
dt = datetime.strptime(dt, "%Y-%m-%dT%H:%M:%S")
us = int(us[:-2]) # microseconds
datetime_obj = dt + timedelta(microseconds=us)
if not datetime_obj.tzinfo:
datetime_obj = datetime_obj.replace(tzinfo=timezone.utc)
return datetime_obj


Expand Down
10 changes: 5 additions & 5 deletions sdk/storage/azure-storage-file-share/tests/test_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# license information.
# --------------------------------------------------------------------------
import unittest
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone

import pytest
from azure.core.exceptions import ClientAuthenticationError, ResourceExistsError, ResourceNotFoundError
Expand Down Expand Up @@ -110,7 +110,7 @@ def test_create_directory_set_smb_properties(self, **kwargs):

directory_client = share_client.get_directory_client('dir1')
file_attributes = NTFSAttributes(read_only=True, directory=True)
file_creation_time = file_last_write_time = file_change_time = datetime(2022, 3, 10, 10, 14, 30, 500000)
file_creation_time = file_last_write_time = file_change_time = datetime(2022, 3, 10, 10, 14, 30, 500000, tzinfo=timezone.utc)

# Act
directory_client.create_directory(
Expand Down Expand Up @@ -1262,9 +1262,9 @@ def test_rename_directory_smb_properties(self, **kwargs):
source_directory = share_client.create_directory('dir1')

file_attributes = NTFSAttributes(read_only=True, directory=True)
file_creation_time = datetime(2022, 1, 26, 10, 9, 30, 500000)
file_last_write_time = datetime(2022, 1, 26, 10, 14, 30, 500000)
file_change_time = datetime(2022, 3, 7, 10, 14, 30, 500000)
file_creation_time = datetime(2022, 1, 26, 10, 9, 30, 500000, tzinfo=timezone.utc)
file_last_write_time = datetime(2022, 1, 26, 10, 14, 30, 500000, tzinfo=timezone.utc)
file_change_time = datetime(2022, 3, 7, 10, 14, 30, 500000, tzinfo=timezone.utc)

# Act
new_directory = source_directory.rename_directory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# --------------------------------------------------------------------------
import unittest
import asyncio
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone

import pytest
from azure.core.exceptions import ClientAuthenticationError, ResourceExistsError, ResourceNotFoundError
Expand Down Expand Up @@ -115,7 +115,7 @@ async def test_create_directory_set_smb_properties(self, **kwargs):

directory_client = share_client.get_directory_client('dir1')
file_attributes = NTFSAttributes(read_only=True, directory=True)
file_creation_time = file_last_write_time = file_change_time = datetime(2022, 3, 10, 10, 14, 30, 500000)
file_creation_time = file_last_write_time = file_change_time = datetime(2022, 3, 10, 10, 14, 30, 500000, tzinfo=timezone.utc)

# Act
await directory_client.create_directory(
Expand Down Expand Up @@ -1362,9 +1362,9 @@ async def test_rename_directory_smb_properties(self, **kwargs):
source_directory = await share_client.create_directory('dir1')

file_attributes = NTFSAttributes(read_only=True, directory=True)
file_creation_time = datetime(2022, 1, 26, 10, 9, 30, 500000)
file_last_write_time = datetime(2022, 1, 26, 10, 14, 30, 500000)
file_change_time = datetime(2022, 3, 7, 10, 14, 30, 500000)
file_creation_time = datetime(2022, 1, 26, 10, 9, 30, 500000, tzinfo=timezone.utc)
file_last_write_time = datetime(2022, 1, 26, 10, 14, 30, 500000, tzinfo=timezone.utc)
file_change_time = datetime(2022, 3, 7, 10, 14, 30, 500000, tzinfo=timezone.utc)

# Act
new_directory = await source_directory.rename_directory(
Expand Down
8 changes: 4 additions & 4 deletions sdk/storage/azure-storage-file-share/tests/test_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def test_create_file_set_smb_properties(self, **kwargs):
file_client = self._get_file_client()

file_attributes = NTFSAttributes(read_only=True, archive=True)
file_creation_time = file_last_write_time = file_change_time = datetime(2022, 3, 10, 10, 14, 30, 500000)
file_creation_time = file_last_write_time = file_change_time = datetime(2022, 3, 10, 10, 14, 30, 500000, tzinfo=timezone.utc)

# Act
file_client.create_file(
Expand Down Expand Up @@ -3598,9 +3598,9 @@ def test_rename_file_smb_properties(self, **kwargs):
source_file = self._create_file('file1')

file_attributes = NTFSAttributes(read_only=True, archive=True)
file_creation_time = datetime(2022, 1, 26, 10, 9, 30, 500000)
file_last_write_time = datetime(2022, 1, 26, 10, 14, 30, 500000)
file_change_time = datetime(2022, 3, 7, 10, 14, 30, 500000)
file_creation_time = datetime(2022, 1, 26, 10, 9, 30, 500000, tzinfo=timezone.utc)
file_last_write_time = datetime(2022, 1, 26, 10, 14, 30, 500000, tzinfo=timezone.utc)
file_change_time = datetime(2022, 3, 7, 10, 14, 30, 500000, tzinfo=timezone.utc)

# Act
new_file = source_file.rename_file(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ async def test_create_file_set_smb_properties(self, **kwargs):
file_client = await self._get_file_client(storage_account_name, storage_account_key)

file_attributes = NTFSAttributes(read_only=True, archive=True)
file_creation_time = file_last_write_time = file_change_time = datetime(2022, 3, 10, 10, 14, 30, 500000)
file_creation_time = file_last_write_time = file_change_time = datetime(2022, 3, 10, 10, 14, 30, 500000, tzinfo=timezone.utc)

# Act
await file_client.create_file(
Expand Down Expand Up @@ -3711,9 +3711,9 @@ async def test_rename_file_smb_properties(self, **kwargs):
source_file = await self._create_file(storage_account_name, storage_account_key, 'file1')

file_attributes = NTFSAttributes(read_only=True, archive=True)
file_creation_time = datetime(2022, 1, 26, 10, 9, 30, 500000)
file_last_write_time = datetime(2022, 1, 26, 10, 14, 30, 500000)
file_change_time = datetime(2022, 3, 7, 10, 14, 30, 500000)
file_creation_time = datetime(2022, 1, 26, 10, 9, 30, 500000, tzinfo=timezone.utc)
file_last_write_time = datetime(2022, 1, 26, 10, 14, 30, 500000, tzinfo=timezone.utc)
file_change_time = datetime(2022, 3, 7, 10, 14, 30, 500000, tzinfo=timezone.utc)

# Act
new_file = await source_file.rename_file(
Expand Down