Skip to content

Commit

Permalink
fix failing tests due to different local formats.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrueastman committed Nov 11, 2024
1 parent 35ff436 commit 15c708b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from __future__ import annotations

from dataclasses import fields, is_dataclass
from datetime import date, datetime, time, timedelta
from datetime import date, datetime, time, timedelta, timezone
from enum import Enum
from io import BytesIO
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Set, TypeVar, Union
Expand Down Expand Up @@ -298,7 +298,11 @@ def _get_sanitized_value(self, value: Any) -> Any:
elif isinstance(value, list) and all(isinstance(x, Enum) for x in value):
sanitized_value = ','.join([x.value for x in value])
elif isinstance(value, datetime):
sanitized_value = value.astimezone().isoformat("T")
timezone_info = value.tzinfo
if timezone_info is None:
timezone_info = timezone.utc
temp_date_with_tz_info = datetime(value.year, value.month, value.day, value.hour, value.minute, value.second, value.microsecond, timezone_info)
sanitized_value = temp_date_with_tz_info.isoformat("T")
elif any([isinstance(value, UUID), isinstance(value, date), isinstance(value, time)]):
sanitized_value = str(value)
return sanitized_value
Expand Down
2 changes: 1 addition & 1 deletion packages/abstractions/tests/test_request_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test_sets_datetime_values_in_path_parameters():
"""
request_info = RequestInformation(Method.GET, "https://example.com/daysFrom/{startDate}")
request_info.path_parameters["startDate"] = datetime(year=2020, month=8, day=1, hour=0, minute=20, second=0, microsecond=0)
assert request_info.url == "https://example.com/daysFrom/2020-08-01T00%3A20%3A00%2B03%3A00"
assert request_info.url == "https://example.com/daysFrom/2020-08-01T00%3A20%3A00%2B00%3A00"

def test_sets_int_values_in_path_parameters():
"""Tests setting int values values in path parameters
Expand Down

0 comments on commit 15c708b

Please sign in to comment.