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

Revert "send current timestamp inside departure info request" #305

Closed
wants to merge 1 commit into from
Closed
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
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
Loading