Skip to content

Commit

Permalink
Revert "send current timestamp inside departure info request (#302)"
Browse files Browse the repository at this point in the history
This reverts commit 94aa29a.
  • Loading branch information
prvakt authored Dec 31, 2024
1 parent 94aa29a commit 9f09614
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
16 changes: 1 addition & 15 deletions myskoda/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from collections.abc import Callable
from dataclasses import dataclass
from datetime import UTC, datetime
from urllib.parse import quote

from aiohttp import ClientResponseError, ClientSession

Expand Down Expand Up @@ -284,20 +283,7 @@ async def get_departure_timers(
self, vin: str, anonymize: bool = False
) -> GetEndpointResult[DepartureInfo]:
"""Retrieve departure timers for the vehicle."""
# Get the current local time with timezone
now = datetime.now().astimezone()
# Format the datetime string with timezone
formatted_time = (
now.strftime("%Y-%m-%dT%H:%M:%S.%f")
+ now.strftime("%z")[:3]
+ ":"
+ now.strftime("%z")[3:]
)

url = (
f"/v1/vehicle-automatization/{vin}/departure/timers"
f"?deviceDateTime={quote(formatted_time, safe='')}"
)
url = f"/v1/vehicle-automatization/{vin}/departure/timers"
raw = self.process_json(
data=await self._make_get_request(url),
anonymize=anonymize,
Expand Down
7 changes: 1 addition & 6 deletions tests/test_rest_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Unit tests for myskoda.rest_api."""

import json
import re
from pathlib import Path

import pytest
Expand Down Expand Up @@ -308,12 +307,8 @@ async def test_get_departure_timers(
"""Example unit test for RestAPI.charging(). Needs more work."""
for departure_timer in departure_timers:
target_vin = "TMBJM0CKV1N12345"
base_url = f"https://mysmob.api.connect.skoda-auto.cz/api/v1/vehicle-automatization/{target_vin}/departure/timers"
# Add a regular expression for the dynamic timestamp query parameter
url_pattern = re.compile(rf"{base_url}\?deviceDateTime=.*")

responses.get(
url=url_pattern,
url=f"https://mysmob.api.connect.skoda-auto.cz/api/v1/vehicle-automatization/{target_vin}/departure/timers",
body=departure_timer,
)
get_departure_timers_result = await myskoda.get_departure_timers(target_vin)
Expand Down

0 comments on commit 9f09614

Please sign in to comment.