volkswagencarnet 5.0.0b4__tar.gz → 5.0.0b5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of volkswagencarnet might be problematic. Click here for more details.
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/codeql-analysis.yml +1 -1
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/release.yaml +1 -1
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/testrelease.yaml +3 -3
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/validate.yml +7 -25
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.pre-commit-config.yaml +1 -12
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/PKG-INFO +5 -5
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/README.md +2 -2
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/pyproject.toml +0 -13
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/requirements-test.txt +0 -3
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/setup.cfg +2 -28
- volkswagencarnet-5.0.0b5/tests/conftest.py +4 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/dummy_test.py +4 -3
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/connection.py +10 -3
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/integration_test.py +11 -12
- volkswagencarnet-5.0.0b5/tests/vw_connection_test.py +98 -0
- volkswagencarnet-5.0.0b5/tests/vw_utilities_test.py +116 -0
- volkswagencarnet-5.0.0b5/tests/vw_vehicle_test.py +245 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/version.py +1 -1
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/vw_connection.py +489 -398
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/vw_const.py +1 -1
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/vw_dashboard.py +548 -139
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/vw_utilities.py +24 -40
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/vw_vehicle.py +1712 -687
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet.egg-info/PKG-INFO +5 -5
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet.egg-info/SOURCES.txt +0 -4
- volkswagencarnet-5.0.0b4/.github/workflows/codecov.yaml +0 -35
- volkswagencarnet-5.0.0b4/tests/conftest.py +0 -8
- volkswagencarnet-5.0.0b4/tests/vw_connection_test.py +0 -178
- volkswagencarnet-5.0.0b4/tests/vw_exceptions_test.py +0 -14
- volkswagencarnet-5.0.0b4/tests/vw_utilities_test.py +0 -168
- volkswagencarnet-5.0.0b4/tests/vw_vehicle_test.py +0 -300
- volkswagencarnet-5.0.0b4/volkswagencarnet/vw_exceptions.py +0 -7
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/CODEOWNERS +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/dependabot.yml +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/release-drafter.yml +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/renovate.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/publish.yaml +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/snyk.yaml +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/validate_pr.yaml +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.gitignore +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/LICENSE.txt +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/requirements.txt +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/__init__.py +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/credentials.py.sample +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/__init__.py +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/constants.py +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/mock_server.py +1 -1
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/dummy_cookies.pickle +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/README.md +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/arteon_2023_diesel/capabilities.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/arteon_2023_diesel/last_trip.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/arteon_2023_diesel/parkingposition.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/arteon_2023_diesel/selectivestatus_by_app.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/egolf/README.md +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/egolf/capabilities.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/egolf/last_trip.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/egolf/parkingposition.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/egolf/selectivestatus_by_app.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/eup_electric/capabilities.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/eup_electric/last_trip.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/eup_electric/parkingposition.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/eup_electric/selectivestatus_by_app.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/golf_gte_hybrid/capabilities.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/golf_gte_hybrid/last_trip.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/golf_gte_hybrid/selectivestatus_by_app.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/status.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/timer.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/timer_without_settings.json +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/__init__.py +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet.egg-info/dependency_links.txt +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet.egg-info/requires.txt +0 -0
- {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet.egg-info/top_level.txt +0 -0
|
@@ -36,6 +36,6 @@ jobs:
|
|
|
36
36
|
- name: Publish package to Test PyPI
|
|
37
37
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
38
38
|
with:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
repository-url: https://test.pypi.org/legacy/
|
|
40
|
+
print-hash: true
|
|
41
|
+
skip-existing: true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# This workflow will install Python dependencies, run tests and
|
|
1
|
+
# This workflow will install Python dependencies, run tests and ruff with a variety of Python versions
|
|
2
2
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
|
3
3
|
|
|
4
4
|
name: Validate
|
|
@@ -14,43 +14,25 @@ on:
|
|
|
14
14
|
- master
|
|
15
15
|
|
|
16
16
|
jobs:
|
|
17
|
-
|
|
18
|
-
name:
|
|
17
|
+
ruff:
|
|
18
|
+
name: Ruff
|
|
19
19
|
runs-on: ubuntu-latest
|
|
20
20
|
|
|
21
21
|
steps:
|
|
22
22
|
- name: Checkout code
|
|
23
23
|
uses: actions/checkout@v4
|
|
24
24
|
|
|
25
|
-
- name:
|
|
26
|
-
uses:
|
|
25
|
+
- name: Check ruff
|
|
26
|
+
uses: chartboost/ruff-action@v1
|
|
27
27
|
with:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- name: Install dependencies
|
|
31
|
-
run: |
|
|
32
|
-
python -m pip install --upgrade pip
|
|
33
|
-
pip install flake8 black
|
|
34
|
-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
35
|
-
|
|
36
|
-
- name: Lint with flake8
|
|
37
|
-
run: |
|
|
38
|
-
# stop the build if there are Python syntax errors or undefined names
|
|
39
|
-
flake8 . --select=E9,F63,F7,F82,F841,E266
|
|
40
|
-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
|
41
|
-
flake8 . --exit-zero --max-complexity=10 --max-line-length=127
|
|
42
|
-
|
|
43
|
-
- name: Lint with black
|
|
44
|
-
#uses: psf/black@stable
|
|
45
|
-
run: |
|
|
46
|
-
black --check --diff --color .
|
|
28
|
+
args: 'format --diff'
|
|
47
29
|
|
|
48
30
|
test-n-build:
|
|
49
31
|
name: Test and Build
|
|
50
32
|
runs-on: ubuntu-latest
|
|
51
33
|
strategy:
|
|
52
34
|
matrix:
|
|
53
|
-
python-version: ["3.
|
|
35
|
+
python-version: ["3.11", "3.12"]
|
|
54
36
|
|
|
55
37
|
steps:
|
|
56
38
|
- name: Checkout code
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# See https://pre-commit.com for more information
|
|
2
2
|
# See https://pre-commit.com/hooks.html for more hooks
|
|
3
3
|
default_language_version:
|
|
4
|
-
python: python3.
|
|
4
|
+
python: python3.11
|
|
5
5
|
|
|
6
6
|
repos:
|
|
7
7
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
@@ -18,17 +18,6 @@ repos:
|
|
|
18
18
|
- id: requirements-txt-fixer
|
|
19
19
|
- id: trailing-whitespace
|
|
20
20
|
|
|
21
|
-
- repo: https://github.com/psf/black
|
|
22
|
-
rev: '22.10.0'
|
|
23
|
-
hooks:
|
|
24
|
-
- id: black
|
|
25
|
-
|
|
26
|
-
- repo: https://github.com/pycqa/flake8
|
|
27
|
-
rev: '4.0.1'
|
|
28
|
-
hooks:
|
|
29
|
-
- id: flake8
|
|
30
|
-
additional_dependencies: [ flake8-docstrings ]
|
|
31
|
-
|
|
32
21
|
- repo: https://github.com/asottile/pyupgrade
|
|
33
22
|
rev: v2.31.0
|
|
34
23
|
hooks:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: volkswagencarnet
|
|
3
|
-
Version: 5.0.
|
|
4
|
-
Summary: Communicate with Volkswagen
|
|
3
|
+
Version: 5.0.0b5
|
|
4
|
+
Summary: Communicate with Volkswagen Connect
|
|
5
5
|
Home-page: https://github.com/robinostlund/volkswagencarnet
|
|
6
6
|
Author: Robin Ostlund
|
|
7
7
|
Author-email: me@robinostlund.name
|
|
@@ -10,7 +10,7 @@ Project-URL: Bug Tracker, https://github.com/robinostlund/volkswagencarnet/issue
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
13
|
-
Requires-Python: >=3.
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE.txt
|
|
16
16
|
Requires-Dist: lxml
|
|
@@ -25,7 +25,7 @@ Requires-Dist: pyjwt
|
|
|
25
25
|

|
|
26
26
|

|
|
27
27
|

|
|
28
|
-

|
|
29
29
|

|
|
30
30
|
[](https://github.com/robinostlund/volkswagencarnet/actions/workflows/codeql-analysis.yml)
|
|
31
31
|
[](https://codecov.io/gh/robinostlund/volkswagencarnet)
|
|
@@ -37,7 +37,7 @@ Requires-Dist: pyjwt
|
|
|
37
37
|
|
|
38
38
|
## Help Wanted
|
|
39
39
|
|
|
40
|
-
As i don't have a car with
|
|
40
|
+
As i don't have a car with Volkswagen Connect anymore i would appreciate if it would be possible to get help to keep this repository maintained. So if you feel that you have some time over and is interested in helping out with this. Please feel to contact me! Thanks
|
|
41
41
|
|
|
42
42
|
## Information
|
|
43
43
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|

|
|
6
6
|

|
|
7
7
|

|
|
8
|
-

|
|
9
9
|

|
|
10
10
|
[](https://github.com/robinostlund/volkswagencarnet/actions/workflows/codeql-analysis.yml)
|
|
11
11
|
[](https://codecov.io/gh/robinostlund/volkswagencarnet)
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
## Help Wanted
|
|
19
19
|
|
|
20
|
-
As i don't have a car with
|
|
20
|
+
As i don't have a car with Volkswagen Connect anymore i would appreciate if it would be possible to get help to keep this repository maintained. So if you feel that you have some time over and is interested in helping out with this. Please feel to contact me! Thanks
|
|
21
21
|
|
|
22
22
|
## Information
|
|
23
23
|
|
|
@@ -10,19 +10,6 @@ build-backend = "setuptools.build_meta"
|
|
|
10
10
|
fallback_version = "0.0.0"
|
|
11
11
|
write_to = "volkswagencarnet/version.py"
|
|
12
12
|
|
|
13
|
-
[tool.black]
|
|
14
|
-
line-length = 120
|
|
15
|
-
target-version = ['py37', 'py38', 'py39', 'py310']
|
|
16
|
-
include = '\.pyi?$'
|
|
17
|
-
extend-exclude = '''
|
|
18
|
-
/(
|
|
19
|
-
# The following are specific to Black, you probably don't want those.
|
|
20
|
-
| blib2to3
|
|
21
|
-
| tests/data
|
|
22
|
-
| profiling
|
|
23
|
-
)/
|
|
24
|
-
'''
|
|
25
|
-
|
|
26
13
|
[tool.pytest.ini_options]
|
|
27
14
|
minversion = "6.0"
|
|
28
15
|
addopts = "-ra"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = volkswagencarnet
|
|
3
3
|
author = Robin Ostlund
|
|
4
4
|
author_email = me@robinostlund.name
|
|
5
|
-
description = Communicate with Volkswagen
|
|
5
|
+
description = Communicate with Volkswagen Connect
|
|
6
6
|
long_description = file: README.md
|
|
7
7
|
long_description_content_type = text/markdown
|
|
8
8
|
url = https://github.com/robinostlund/volkswagencarnet
|
|
@@ -23,7 +23,7 @@ install_requires =
|
|
|
23
23
|
package_dir =
|
|
24
24
|
= .
|
|
25
25
|
packages = find:
|
|
26
|
-
python_requires = >= 3.
|
|
26
|
+
python_requires = >= 3.11
|
|
27
27
|
|
|
28
28
|
[options.packages.find]
|
|
29
29
|
where = .
|
|
@@ -31,32 +31,6 @@ exclude =
|
|
|
31
31
|
tests
|
|
32
32
|
tests.*
|
|
33
33
|
|
|
34
|
-
[flake8]
|
|
35
|
-
ignore =
|
|
36
|
-
E722,
|
|
37
|
-
I201,
|
|
38
|
-
W503,
|
|
39
|
-
CFQ001,
|
|
40
|
-
CFQ002,
|
|
41
|
-
E501,
|
|
42
|
-
W503,
|
|
43
|
-
E203,
|
|
44
|
-
D202,
|
|
45
|
-
W504
|
|
46
|
-
filename =
|
|
47
|
-
*.py
|
|
48
|
-
exclude =
|
|
49
|
-
.git,
|
|
50
|
-
__pycache__,
|
|
51
|
-
*.txt,
|
|
52
|
-
*.md,
|
|
53
|
-
*.cfg
|
|
54
|
-
max_line_length = 120
|
|
55
|
-
count = True
|
|
56
|
-
inline_quotes = double
|
|
57
|
-
show_source = True
|
|
58
|
-
statistics = True
|
|
59
|
-
|
|
60
34
|
[pycodestyle]
|
|
61
35
|
max_line_length = 120
|
|
62
36
|
statistics = True
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"""Dummy tests. Might be removed once there are proper ones."""
|
|
2
2
|
|
|
3
|
-
import pytest
|
|
4
3
|
from aiohttp import ClientSession
|
|
5
|
-
|
|
4
|
+
import pytest
|
|
6
5
|
from volkswagencarnet import vw_connection
|
|
7
6
|
|
|
8
7
|
|
|
@@ -10,6 +9,8 @@ from volkswagencarnet import vw_connection
|
|
|
10
9
|
async def test_volkswagencarnet():
|
|
11
10
|
"""Dummy test to ensure logged in status is false by default."""
|
|
12
11
|
async with ClientSession() as session:
|
|
13
|
-
connection = vw_connection.Connection(
|
|
12
|
+
connection = vw_connection.Connection(
|
|
13
|
+
session, "test@example.com", "test_password"
|
|
14
|
+
)
|
|
14
15
|
# if await connection._login():
|
|
15
16
|
assert connection.logged_in is False
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
|
|
5
|
+
from aiohttp import ClientSession, CookieJar
|
|
5
6
|
import pytest
|
|
6
7
|
import pytest_asyncio
|
|
7
|
-
from aiohttp import CookieJar, ClientSession
|
|
8
|
-
|
|
9
8
|
from volkswagencarnet.vw_connection import Connection
|
|
9
|
+
|
|
10
10
|
from .constants import resource_path
|
|
11
11
|
|
|
12
12
|
|
|
@@ -23,4 +23,11 @@ async def session():
|
|
|
23
23
|
@pytest.fixture
|
|
24
24
|
def connection(session):
|
|
25
25
|
"""Real connection for integration tests."""
|
|
26
|
-
return Connection(
|
|
26
|
+
return Connection(
|
|
27
|
+
session=session,
|
|
28
|
+
username="",
|
|
29
|
+
password="",
|
|
30
|
+
country="DE",
|
|
31
|
+
interval=999,
|
|
32
|
+
fulldebug=True,
|
|
33
|
+
)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Integration tests.
|
|
1
|
+
"""Integration tests.
|
|
3
2
|
|
|
4
3
|
These tests use actual credentials, and should thus be used with care.
|
|
5
4
|
Credentials have to be specified in credentials.py.
|
|
@@ -7,22 +6,22 @@ Credentials have to be specified in credentials.py.
|
|
|
7
6
|
|
|
8
7
|
import logging
|
|
9
8
|
|
|
10
|
-
import pytest
|
|
11
9
|
from aiohttp import ClientSession
|
|
12
|
-
|
|
10
|
+
import pytest
|
|
13
11
|
from volkswagencarnet import vw_connection
|
|
14
12
|
|
|
15
13
|
try:
|
|
16
|
-
from credentials import
|
|
14
|
+
from credentials import password, spin, username, vin
|
|
17
15
|
except ImportError:
|
|
18
16
|
username = password = spin = vin = None
|
|
19
17
|
|
|
20
18
|
|
|
21
19
|
@pytest.mark.skipif(
|
|
22
|
-
username is None or password is None,
|
|
20
|
+
username is None or password is None,
|
|
21
|
+
reason="Username or password is not set. Check credentials.py.sample",
|
|
23
22
|
)
|
|
24
23
|
@pytest.mark.asyncio
|
|
25
|
-
async def test_successful_login():
|
|
24
|
+
async def test_successful_login() -> None:
|
|
26
25
|
"""Test that login succeeds."""
|
|
27
26
|
async with ClientSession() as session:
|
|
28
27
|
connection = vw_connection.Connection(session, username, password)
|
|
@@ -31,14 +30,14 @@ async def test_successful_login():
|
|
|
31
30
|
|
|
32
31
|
|
|
33
32
|
@pytest.mark.skipif(
|
|
34
|
-
username is None or password is None,
|
|
33
|
+
username is None or password is None,
|
|
34
|
+
reason="Username or password is not set. Check credentials.py.sample",
|
|
35
35
|
)
|
|
36
36
|
@pytest.mark.asyncio
|
|
37
37
|
@pytest.mark.skip("Not yet implemented")
|
|
38
|
-
async def test_spin_action():
|
|
39
|
-
"""
|
|
40
|
-
Test something that uses s-pin.
|
|
38
|
+
async def test_spin_action() -> None:
|
|
39
|
+
"""Test something that uses s-pin.
|
|
41
40
|
|
|
42
41
|
Not yet implemented...
|
|
43
42
|
"""
|
|
44
|
-
logging.getLogger().debug(
|
|
43
|
+
logging.getLogger().debug("using vin: %s and s-pin: %s", vin, spin)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""Tests for main connection class."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from unittest import IsolatedAsyncioTestCase
|
|
5
|
+
from unittest.mock import MagicMock, patch
|
|
6
|
+
|
|
7
|
+
import aiohttp
|
|
8
|
+
from aiohttp import client_exceptions
|
|
9
|
+
import pytest
|
|
10
|
+
from volkswagencarnet import vw_connection
|
|
11
|
+
from volkswagencarnet.vw_connection import Connection
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TwoVehiclesConnection(Connection):
|
|
15
|
+
"""Connection that return two vehicles."""
|
|
16
|
+
|
|
17
|
+
ALLOW_RATE_LIMIT_DELAY = False
|
|
18
|
+
|
|
19
|
+
# noinspection PyUnusedLocal
|
|
20
|
+
# noinspection PyMissingConstructor
|
|
21
|
+
def __init__(self, sess, username="", password="", **kwargs):
|
|
22
|
+
"""Init."""
|
|
23
|
+
super().__init__(session=sess, username=username, password=password)
|
|
24
|
+
self._jarCookie = MagicMock()
|
|
25
|
+
|
|
26
|
+
async def doLogin(self, tries=1):
|
|
27
|
+
"""No-op update."""
|
|
28
|
+
return True
|
|
29
|
+
|
|
30
|
+
async def update(self):
|
|
31
|
+
"""No-op update."""
|
|
32
|
+
return True
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def vehicles(self):
|
|
36
|
+
"""Return the vehicles."""
|
|
37
|
+
vehicle1 = vw_connection.Vehicle(None, "vin1")
|
|
38
|
+
vehicle2 = vw_connection.Vehicle(None, "vin2")
|
|
39
|
+
return [vehicle1, vehicle2]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@pytest.mark.skipif(
|
|
43
|
+
condition=sys.version_info < (3, 11), reason="Test incompatible with Python < 3.11"
|
|
44
|
+
)
|
|
45
|
+
def test_clear_cookies(connection) -> None:
|
|
46
|
+
"""Check that we can clear old cookies."""
|
|
47
|
+
assert len(connection._session._cookie_jar._cookies) > 0
|
|
48
|
+
connection._clear_cookies()
|
|
49
|
+
assert len(connection._session._cookie_jar._cookies) == 0
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class SendCommandsTest(IsolatedAsyncioTestCase):
|
|
53
|
+
"""Test command sending."""
|
|
54
|
+
|
|
55
|
+
async def test_set_schedule(self):
|
|
56
|
+
"""Test set schedule."""
|
|
57
|
+
pass
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class RateLimitTest(IsolatedAsyncioTestCase):
|
|
61
|
+
"""Test that rate limiting towards VW works."""
|
|
62
|
+
|
|
63
|
+
invocations = 0
|
|
64
|
+
|
|
65
|
+
async def rateLimitedFunction(self, url, vin=""):
|
|
66
|
+
"""Limit calls test function."""
|
|
67
|
+
ri = MagicMock(aiohttp.RequestInfo)
|
|
68
|
+
e = client_exceptions.ClientResponseError(request_info=ri, history=tuple([]))
|
|
69
|
+
e.status = 429
|
|
70
|
+
self.invocations = self.invocations + 1
|
|
71
|
+
raise e
|
|
72
|
+
|
|
73
|
+
@pytest.mark.asyncio
|
|
74
|
+
@pytest.mark.skipif(
|
|
75
|
+
condition=sys.version_info < (3, 11),
|
|
76
|
+
reason="Test incompatible with Python < 3.11",
|
|
77
|
+
)
|
|
78
|
+
@patch(
|
|
79
|
+
"volkswagencarnet.vw_connection.Connection",
|
|
80
|
+
spec_set=vw_connection.Connection,
|
|
81
|
+
new=TwoVehiclesConnection,
|
|
82
|
+
)
|
|
83
|
+
@patch("volkswagencarnet.vw_connection.MAX_RETRIES_ON_RATE_LIMIT", 1)
|
|
84
|
+
async def test_rate_limit(self):
|
|
85
|
+
"""Test rate limiting functionality."""
|
|
86
|
+
|
|
87
|
+
from unittest.mock import AsyncMock
|
|
88
|
+
|
|
89
|
+
sess = AsyncMock()
|
|
90
|
+
|
|
91
|
+
# noinspection PyArgumentList
|
|
92
|
+
conn = vw_connection.Connection(sess, "", "")
|
|
93
|
+
|
|
94
|
+
self.invocations = 0
|
|
95
|
+
with patch.object(conn, "_request", self.rateLimitedFunction):
|
|
96
|
+
res = await conn.get("foo")
|
|
97
|
+
assert res == {"status_code": 429}
|
|
98
|
+
assert self.invocations == vw_connection.MAX_RETRIES_ON_RATE_LIMIT + 1
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""Utilities class tests."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime, timedelta, timezone
|
|
4
|
+
from json import JSONDecodeError
|
|
5
|
+
from unittest import TestCase
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
from volkswagencarnet.vw_utilities import (
|
|
9
|
+
camel2slug,
|
|
10
|
+
is_valid_path,
|
|
11
|
+
json_loads,
|
|
12
|
+
make_url,
|
|
13
|
+
obj_parser,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class UtilitiesTest(TestCase):
|
|
18
|
+
"""Test methods in utilities."""
|
|
19
|
+
|
|
20
|
+
def test_camel_to_slug(self):
|
|
21
|
+
"""Test camel_to_slug conversion."""
|
|
22
|
+
data = {
|
|
23
|
+
"foo": "foo",
|
|
24
|
+
"fooBar": "foo_bar",
|
|
25
|
+
"XYZ": "x_y_z",
|
|
26
|
+
"B4R": "b4_r", # Should this actually be "b_4_r"? =)
|
|
27
|
+
"Foo_Bar": "foo_bar",
|
|
28
|
+
"_removeExtra_Underscores__": "remove_extra_underscores",
|
|
29
|
+
"preserve___existing": "preserve___existing",
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
for key, expected in data.items():
|
|
33
|
+
with self.subTest(msg=key, v=key):
|
|
34
|
+
res = camel2slug(key)
|
|
35
|
+
assert expected == res
|
|
36
|
+
|
|
37
|
+
def test_is_valid_path(self):
|
|
38
|
+
"""Test that is_valid_path works as expected."""
|
|
39
|
+
data = {
|
|
40
|
+
"None": [None, None, True],
|
|
41
|
+
"a in a": [{"a": 1}, "a", True],
|
|
42
|
+
"b in a": [{"a": 1}, "b", False],
|
|
43
|
+
"a.b in a.b": [{"a": {"b": 7}}, "a.b", True],
|
|
44
|
+
"false path": [{"a": {"b": 7}}, False, True],
|
|
45
|
+
"dict path": [{1, "a", "[[ :) ]]"}, {"crash": "me"}, False],
|
|
46
|
+
"": [{"a": []}, datetime.now(), TypeError],
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
for test_name, test_case in data.items():
|
|
50
|
+
with self.subTest(msg=test_name):
|
|
51
|
+
source, path, expected = test_case
|
|
52
|
+
|
|
53
|
+
if isinstance(expected, bool):
|
|
54
|
+
# If expected is a boolean, assert the result of is_valid_path
|
|
55
|
+
assert (
|
|
56
|
+
is_valid_path(source, path) == expected
|
|
57
|
+
), f"Path validation error for '{path}' in '{source}'."
|
|
58
|
+
else:
|
|
59
|
+
# If expected is an exception, assert it is raised
|
|
60
|
+
with pytest.raises(expected) as exc_info:
|
|
61
|
+
is_valid_path(source, path)
|
|
62
|
+
assert isinstance(
|
|
63
|
+
exc_info.value, expected
|
|
64
|
+
), f"Expected {expected.__name__}, but got {type(exc_info.value).__name__}. Exception: {str(exc_info.value)}"
|
|
65
|
+
|
|
66
|
+
def test_is_valid_path_with_lists(self):
|
|
67
|
+
"""Test that is_valid_path can process lists."""
|
|
68
|
+
assert is_valid_path({"a": [{"b": True}, {"c": True}]}, "a.0.b")
|
|
69
|
+
assert not is_valid_path({"a": [{"b": True}, {"c": True}]}, "a.2")
|
|
70
|
+
|
|
71
|
+
def test_obj_parser(self):
|
|
72
|
+
"""Test that the object parser works."""
|
|
73
|
+
data = {
|
|
74
|
+
"int": [0, AttributeError],
|
|
75
|
+
"dict": [{"foo": "bar"}, {"foo": "bar"}],
|
|
76
|
+
"dict with time": [
|
|
77
|
+
{"foo": "2001-01-01T23:59:59Z"},
|
|
78
|
+
{"foo": datetime(2001, 1, 1, 23, 59, 59, tzinfo=timezone.utc)},
|
|
79
|
+
],
|
|
80
|
+
"dict with timezone": [
|
|
81
|
+
{"foo": "2001-01-01T23:59:59+0200"},
|
|
82
|
+
{
|
|
83
|
+
"foo": datetime(
|
|
84
|
+
2001, 1, 1, 23, 59, 59, tzinfo=timezone(timedelta(hours=2))
|
|
85
|
+
)
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
for test_name, (input_data, expected_output) in data.items():
|
|
91
|
+
with self.subTest(test_name=test_name):
|
|
92
|
+
if isinstance(expected_output, dict):
|
|
93
|
+
res = obj_parser(input_data)
|
|
94
|
+
assert res == expected_output
|
|
95
|
+
else:
|
|
96
|
+
with pytest.raises(expected_output):
|
|
97
|
+
obj_parser(input_data)
|
|
98
|
+
|
|
99
|
+
def test_json_loads(self):
|
|
100
|
+
"""Test that json_loads works."""
|
|
101
|
+
expected = {"foo": {"bar": "baz"}}
|
|
102
|
+
actual = json_loads('{"foo": {\n"bar":\t"baz"}}')
|
|
103
|
+
assert expected == actual
|
|
104
|
+
|
|
105
|
+
assert json_loads("42") == 42
|
|
106
|
+
|
|
107
|
+
with pytest.raises(JSONDecodeError):
|
|
108
|
+
json_loads("{[}")
|
|
109
|
+
|
|
110
|
+
with pytest.raises(TypeError):
|
|
111
|
+
json_loads(42)
|
|
112
|
+
|
|
113
|
+
def test_make_url(self):
|
|
114
|
+
"""Test placeholder replacements."""
|
|
115
|
+
assert make_url("foo/{bar}/baz{baz}", bar=2, baz="") == "foo/2/baz"
|
|
116
|
+
assert make_url("foo/{baz}/$bar", bar=2, baz="asd") == "foo/asd/2"
|