-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,667 additions
and
679 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
aiohappyeyeballs==2.4.3 ; python_version >= "3.9" and python_version < "3.13" | ||
aiohttp==3.10.10 ; python_version >= "3.9" and python_version < "3.13" | ||
aiosignal==1.3.1 ; python_version >= "3.9" and python_version < "3.13" | ||
anyio==4.6.2.post1 ; python_version >= "3.9" and python_version < "3.13" | ||
apprise==1.9.0 ; python_version >= "3.9" and python_version < "3.13" | ||
async-timeout==4.0.3 ; python_version >= "3.9" and python_version < "3.11" | ||
attrs==24.2.0 ; python_version >= "3.9" and python_version < "3.13" | ||
babel==2.16.0 ; python_version >= "3.9" and python_version < "3.13" | ||
cachetools==5.5.0 ; python_version >= "3.9" and python_version < "3.13" | ||
certifi==2024.8.30 ; python_version >= "3.9" and python_version < "3.13" | ||
charset-normalizer==3.4.0 ; python_version >= "3.9" and python_version < "3.13" | ||
click==8.1.7 ; python_version >= "3.9" and python_version < "3.13" | ||
aiohappyeyeballs==2.4.6 ; python_version >= "3.9" and python_version < "3.13" | ||
aiohttp==3.11.13 ; python_version >= "3.9" and python_version < "3.13" | ||
aiosignal==1.3.2 ; python_version >= "3.9" and python_version < "3.13" | ||
anyio==4.8.0 ; python_version >= "3.9" and python_version < "3.13" | ||
apprise==1.9.2 ; python_version >= "3.9" and python_version < "3.13" | ||
async-timeout==5.0.1 ; python_version >= "3.9" and python_version < "3.11" | ||
attrs==25.1.0 ; python_version >= "3.9" and python_version < "3.13" | ||
babel==2.17.0 ; python_version >= "3.9" and python_version < "3.13" | ||
cachetools==5.5.2 ; python_version >= "3.9" and python_version < "3.13" | ||
certifi==2025.1.31 ; python_version >= "3.9" and python_version < "3.13" | ||
charset-normalizer==3.4.1 ; python_version >= "3.9" and python_version < "3.13" | ||
click==8.1.8 ; python_version >= "3.9" and python_version < "3.13" | ||
colorama==0.4.6 ; python_version >= "3.9" and python_version < "3.13" and (sys_platform == "win32" or platform_system == "Windows") | ||
colorlog==6.9.0 ; python_version >= "3.9" and python_version < "3.13" | ||
cron-descriptor==1.4.5 ; python_version >= "3.9" and python_version < "3.13" | ||
discord-py==2.4.0 ; python_version >= "3.9" and python_version < "3.13" | ||
discord-py==2.5.0 ; python_version >= "3.9" and python_version < "3.13" | ||
discord==2.3.2 ; python_version >= "3.9" and python_version < "3.13" | ||
exceptiongroup==1.2.2 ; python_version >= "3.9" and python_version < "3.11" | ||
frozenlist==1.5.0 ; python_version >= "3.9" and python_version < "3.13" | ||
googlemaps==4.10.0 ; python_version >= "3.9" and python_version < "3.13" | ||
h11==0.14.0 ; python_version >= "3.9" and python_version < "3.13" | ||
httpcore==1.0.6 ; python_version >= "3.9" and python_version < "3.13" | ||
httpx==0.27.2 ; python_version >= "3.9" and python_version < "3.13" | ||
humanize==4.11.0 ; python_version >= "3.9" and python_version < "3.13" | ||
httpcore==1.0.7 ; python_version >= "3.9" and python_version < "3.13" | ||
httpx==0.28.1 ; python_version >= "3.9" and python_version < "3.13" | ||
humanize==4.12.1 ; python_version >= "3.9" and python_version < "3.13" | ||
idna==3.10 ; python_version >= "3.9" and python_version < "3.13" | ||
importlib-metadata==8.5.0 ; python_version >= "3.9" and python_version < "3.10" | ||
importlib-metadata==8.6.1 ; python_version >= "3.9" and python_version < "3.10" | ||
markdown==3.7 ; python_version >= "3.9" and python_version < "3.13" | ||
multidict==6.1.0 ; python_version >= "3.9" and python_version < "3.13" | ||
oauthlib==3.2.2 ; python_version >= "3.9" and python_version < "3.13" | ||
packaging==24.1 ; python_version >= "3.9" and python_version < "3.13" | ||
packaging==24.2 ; python_version >= "3.9" and python_version < "3.13" | ||
progress==1.6 ; python_version >= "3.9" and python_version < "3.13" | ||
prometheus-client==0.21.0 ; python_version >= "3.9" and python_version < "3.13" | ||
propcache==0.2.0 ; python_version >= "3.9" and python_version < "3.13" | ||
pycron==3.1.1 ; python_version >= "3.9" and python_version < "3.13" | ||
prometheus-client==0.21.1 ; python_version >= "3.9" and python_version < "3.13" | ||
propcache==0.3.0 ; python_version >= "3.9" and python_version < "3.13" | ||
pycron==3.1.2 ; python_version >= "3.9" and python_version < "3.13" | ||
python-pushsafer==1.1 ; python_version >= "3.9" and python_version < "3.13" | ||
python-telegram-bot[callback-data]==21.6 ; python_version >= "3.9" and python_version < "3.13" | ||
python-telegram-bot[callback-data]==21.10 ; python_version >= "3.9" and python_version < "3.13" | ||
pyyaml==6.0.2 ; python_version >= "3.9" and python_version < "3.13" | ||
requests-oauthlib==2.0.0 ; python_version >= "3.9" and python_version < "3.13" | ||
requests==2.32.3 ; python_version >= "3.9" and python_version < "3.13" | ||
sniffio==1.3.1 ; python_version >= "3.9" and python_version < "3.13" | ||
typing-extensions==4.12.2 ; python_version >= "3.9" and python_version < "3.11" | ||
urllib3==2.2.3 ; python_version >= "3.9" and python_version < "3.13" | ||
yarl==1.17.1 ; python_version >= "3.9" and python_version < "3.13" | ||
zipp==3.20.2 ; python_version >= "3.9" and python_version < "3.10" | ||
typing-extensions==4.12.2 ; python_version >= "3.9" and python_version < "3.13" | ||
urllib3==2.3.0 ; python_version >= "3.9" and python_version < "3.13" | ||
yarl==1.18.3 ; python_version >= "3.9" and python_version < "3.13" | ||
zipp==3.21.0 ; python_version >= "3.9" and python_version < "3.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,12 @@ | |
|
||
from tgtg_scanner.models import Config | ||
from tgtg_scanner.tgtg.tgtg_client import ( | ||
API_ITEM_ENDPOINT, | ||
AUTH_BY_EMAIL_ENDPOINT, | ||
AUTH_POLLING_ENDPOINT, | ||
BASE_URL, | ||
FAVORITE_ITEM_ENDPOINT, | ||
REFRESH_ENDPOINT, | ||
USER_AGENTS, | ||
TgtgClient, | ||
) | ||
|
@@ -49,30 +53,27 @@ def test_tgtg_login_with_mail(mocker: MockerFixture): | |
"access_token": "new_access_token", | ||
"access_token_ttl_seconds": 172800, | ||
"refresh_token": "new_refresh_token", | ||
"startup_data": {"user": {"user_id": "123456789"}}, | ||
} | ||
responses.add( | ||
responses.POST, | ||
"https://apptoogoodtogo.com/api/auth/v3/authByEmail", | ||
urljoin(BASE_URL, AUTH_BY_EMAIL_ENDPOINT), | ||
json.dumps(auth_response_data), | ||
status=200, | ||
) | ||
responses.add( | ||
responses.POST, | ||
"https://apptoogoodtogo.com/api/auth/v3/authByRequestPollingId", | ||
urljoin(BASE_URL, AUTH_POLLING_ENDPOINT), | ||
status=202, | ||
) | ||
responses.add( | ||
responses.POST, | ||
"https://apptoogoodtogo.com/api/auth/v3/authByRequestPollingId", | ||
urljoin(BASE_URL, AUTH_POLLING_ENDPOINT), | ||
json.dumps(poll_response_data), | ||
status=200, | ||
) | ||
client.login() | ||
assert client.access_token == poll_response_data.get("access_token") | ||
assert client.refresh_token == poll_response_data.get("refresh_token") | ||
user_id = poll_response_data.get("startup_data", {}).get("user", {}).get("user_id") # type: ignore[attr-defined] | ||
assert client.user_id == user_id | ||
assert json.loads(responses.calls[1].request.body) == { | ||
"device_type": client.device_type, | ||
"email": client.email, | ||
|
@@ -90,7 +91,6 @@ def test_tgtg_login_with_token(mocker: MockerFixture): | |
email="[email protected]", | ||
access_token="old_access_token", | ||
refresh_token="old_refresh_token", | ||
user_id="old_user_id", | ||
) | ||
response_data = { | ||
"access_token": "new_access_token", | ||
|
@@ -99,7 +99,7 @@ def test_tgtg_login_with_token(mocker: MockerFixture): | |
} | ||
responses.add( | ||
responses.POST, | ||
"https://apptoogoodtogo.com/api/auth/v3/token/refresh", | ||
urljoin(BASE_URL, REFRESH_ENDPOINT), | ||
json.dumps(response_data), | ||
status=200, | ||
) | ||
|
@@ -117,15 +117,14 @@ def test_tgtg_get_items(mocker: MockerFixture, tgtg_item: dict): | |
mocker.patch("tgtg_scanner.tgtg.tgtg_client.TgtgClient.login", return_value=None) | ||
responses.add( | ||
responses.POST, | ||
"https://apptoogoodtogo.com/api/item/v8/", | ||
urljoin(BASE_URL, API_ITEM_ENDPOINT), | ||
json.dumps({"items": [tgtg_item]}), | ||
status=200, | ||
) | ||
client = TgtgClient( | ||
email="[email protected]", | ||
access_token="access_token", | ||
refresh_token="refresh_token", | ||
user_id="user_id", | ||
) | ||
response = client.get_items(favorites_only=True) | ||
assert response == [tgtg_item] | ||
|
@@ -141,15 +140,14 @@ def test_tgtg_get_item(mocker: MockerFixture, tgtg_item: dict): | |
item_id = tgtg_item.get("item", {}).get("item_id") | ||
responses.add( | ||
responses.POST, | ||
f"https://apptoogoodtogo.com/api/item/v8/{item_id}", | ||
urljoin(BASE_URL, API_ITEM_ENDPOINT + item_id), | ||
json.dumps(tgtg_item), | ||
status=200, | ||
) | ||
client = TgtgClient( | ||
email="[email protected]", | ||
access_token="access_token", | ||
refresh_token="refresh_token", | ||
user_id="user_id", | ||
) | ||
response = client.get_item(item_id) | ||
assert response == tgtg_item | ||
|
@@ -173,7 +171,6 @@ def test_tgtg_set_favorite(mocker: MockerFixture): | |
email="[email protected]", | ||
access_token="access_token", | ||
refresh_token="refresh_token", | ||
user_id="user_id", | ||
) | ||
client.set_favorite(item_id, True) | ||
assert json.loads(responses.calls[0].request.body) == {"is_favorite": True} | ||
|
@@ -196,7 +193,6 @@ def test_tgtg_api(item_properties: dict): | |
polling_wait_time=config.tgtg.polling_wait_time, | ||
access_token=config.tgtg.access_token, | ||
refresh_token=config.tgtg.refresh_token, | ||
user_id=config.tgtg.user_id, | ||
datadome_cookie=config.tgtg.datadome, | ||
) | ||
|
||
|
@@ -207,7 +203,6 @@ def test_tgtg_api(item_properties: dict): | |
with open(env_file, "a", encoding="utf-8") as file: | ||
file.write(f"TGTG_ACCESS_TOKEN={credentials['access_token']}\n") | ||
file.write(f"TGTG_REFRESH_TOKEN={credentials['refresh_token']}\n") | ||
file.write(f"TGTG_USER_ID={credentials['user_id']}\n") | ||
file.write(f"TGTG_COOKIE={credentials['datadome_cookie']}\n") | ||
|
||
# Tests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.