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.

Files changed (72) hide show
  1. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/codeql-analysis.yml +1 -1
  2. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/release.yaml +1 -1
  3. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/testrelease.yaml +3 -3
  4. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/validate.yml +7 -25
  5. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.pre-commit-config.yaml +1 -12
  6. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/PKG-INFO +5 -5
  7. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/README.md +2 -2
  8. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/pyproject.toml +0 -13
  9. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/requirements-test.txt +0 -3
  10. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/setup.cfg +2 -28
  11. volkswagencarnet-5.0.0b5/tests/conftest.py +4 -0
  12. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/dummy_test.py +4 -3
  13. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/connection.py +10 -3
  14. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/integration_test.py +11 -12
  15. volkswagencarnet-5.0.0b5/tests/vw_connection_test.py +98 -0
  16. volkswagencarnet-5.0.0b5/tests/vw_utilities_test.py +116 -0
  17. volkswagencarnet-5.0.0b5/tests/vw_vehicle_test.py +245 -0
  18. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/version.py +1 -1
  19. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/vw_connection.py +489 -398
  20. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/vw_const.py +1 -1
  21. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/vw_dashboard.py +548 -139
  22. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/vw_utilities.py +24 -40
  23. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/vw_vehicle.py +1712 -687
  24. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet.egg-info/PKG-INFO +5 -5
  25. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet.egg-info/SOURCES.txt +0 -4
  26. volkswagencarnet-5.0.0b4/.github/workflows/codecov.yaml +0 -35
  27. volkswagencarnet-5.0.0b4/tests/conftest.py +0 -8
  28. volkswagencarnet-5.0.0b4/tests/vw_connection_test.py +0 -178
  29. volkswagencarnet-5.0.0b4/tests/vw_exceptions_test.py +0 -14
  30. volkswagencarnet-5.0.0b4/tests/vw_utilities_test.py +0 -168
  31. volkswagencarnet-5.0.0b4/tests/vw_vehicle_test.py +0 -300
  32. volkswagencarnet-5.0.0b4/volkswagencarnet/vw_exceptions.py +0 -7
  33. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/CODEOWNERS +0 -0
  34. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/dependabot.yml +0 -0
  35. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/release-drafter.yml +0 -0
  36. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/renovate.json +0 -0
  37. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/publish.yaml +0 -0
  38. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/snyk.yaml +0 -0
  39. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.github/workflows/validate_pr.yaml +0 -0
  40. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/.gitignore +0 -0
  41. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/LICENSE.txt +0 -0
  42. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/requirements.txt +0 -0
  43. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/__init__.py +0 -0
  44. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/credentials.py.sample +0 -0
  45. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/__init__.py +0 -0
  46. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/constants.py +0 -0
  47. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/mock_server.py +1 -1
  48. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/dummy_cookies.pickle +0 -0
  49. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/README.md +0 -0
  50. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/arteon_2023_diesel/capabilities.json +0 -0
  51. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/arteon_2023_diesel/last_trip.json +0 -0
  52. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/arteon_2023_diesel/parkingposition.json +0 -0
  53. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/arteon_2023_diesel/selectivestatus_by_app.json +0 -0
  54. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/egolf/README.md +0 -0
  55. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/egolf/capabilities.json +0 -0
  56. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/egolf/last_trip.json +0 -0
  57. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/egolf/parkingposition.json +0 -0
  58. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/egolf/selectivestatus_by_app.json +0 -0
  59. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/eup_electric/capabilities.json +0 -0
  60. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/eup_electric/last_trip.json +0 -0
  61. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/eup_electric/parkingposition.json +0 -0
  62. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/eup_electric/selectivestatus_by_app.json +0 -0
  63. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/golf_gte_hybrid/capabilities.json +0 -0
  64. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/golf_gte_hybrid/last_trip.json +0 -0
  65. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/golf_gte_hybrid/selectivestatus_by_app.json +0 -0
  66. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/status.json +0 -0
  67. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/timer.json +0 -0
  68. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/tests/fixtures/resources/responses/timer_without_settings.json +0 -0
  69. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet/__init__.py +0 -0
  70. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet.egg-info/dependency_links.txt +0 -0
  71. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet.egg-info/requires.txt +0 -0
  72. {volkswagencarnet-5.0.0b4 → volkswagencarnet-5.0.0b5}/volkswagencarnet.egg-info/top_level.txt +0 -0
@@ -22,7 +22,7 @@ jobs:
22
22
  fail-fast: false
23
23
  matrix:
24
24
  language: ["python"]
25
- python-version: ["3.8", "3.9", "3.10", "3.11"]
25
+ python-version: ["3.11", "3.12"]
26
26
 
27
27
  steps:
28
28
  - name: Checkout repository
@@ -37,4 +37,4 @@ jobs:
37
37
  if: startsWith(github.ref, 'refs/tags')
38
38
  uses: pypa/gh-action-pypi-publish@release/v1
39
39
  with:
40
- print_hash: true
40
+ print-hash: true
@@ -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
- repository_url: https://test.pypi.org/legacy/
40
- print_hash: true
41
- skip_existing: true
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 lint with a variety of Python versions
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
- lint:
18
- name: Lint
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: Set up Python 3.11
26
- uses: actions/setup-python@v5
25
+ - name: Check ruff
26
+ uses: chartboost/ruff-action@v1
27
27
  with:
28
- python-version: "3.11"
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.7", "3.8", "3.9", "3.10", "3.11"]
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.9
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.0b4
4
- Summary: Communicate with Volkswagen WeConnect
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.7
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
  ![Release](https://img.shields.io/github/workflow/status/robinostlund/volkswagencarnet/Release)
26
26
  ![PyPi](https://img.shields.io/pypi/v/volkswagencarnet)
27
27
  ![Version](https://img.shields.io/github/v/release/robinostlund/volkswagencarnet)
28
- ![CodeStyle](https://img.shields.io/badge/code%20style-black-black)
28
+ ![CodeStyle](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)
29
29
  ![Known Vulnerabilities](https://snyk.io/test/github/robinostlund/volkswagencarnet/badge.svg)
30
30
  [![CodeQL](https://github.com/robinostlund/volkswagencarnet/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/robinostlund/volkswagencarnet/actions/workflows/codeql-analysis.yml)
31
31
  [![codecov](https://codecov.io/gh/robinostlund/volkswagencarnet/branch/master/graph/badge.svg?token=NH1Q1GH4I3)](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 we 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
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
  ![Release](https://img.shields.io/github/workflow/status/robinostlund/volkswagencarnet/Release)
6
6
  ![PyPi](https://img.shields.io/pypi/v/volkswagencarnet)
7
7
  ![Version](https://img.shields.io/github/v/release/robinostlund/volkswagencarnet)
8
- ![CodeStyle](https://img.shields.io/badge/code%20style-black-black)
8
+ ![CodeStyle](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)
9
9
  ![Known Vulnerabilities](https://snyk.io/test/github/robinostlund/volkswagencarnet/badge.svg)
10
10
  [![CodeQL](https://github.com/robinostlund/volkswagencarnet/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/robinostlund/volkswagencarnet/actions/workflows/codeql-analysis.yml)
11
11
  [![codecov](https://codecov.io/gh/robinostlund/volkswagencarnet/branch/master/graph/badge.svg?token=NH1Q1GH4I3)](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 we 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
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"
@@ -1,7 +1,4 @@
1
1
  -r requirements.txt
2
- black
3
- flake8
4
- flake8-docstrings
5
2
  freezegun>=1.0.0
6
3
  pre-commit
7
4
  pytest>=7.0.0
@@ -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 WeConnect
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.7
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
@@ -0,0 +1,4 @@
1
+ """Configure tests."""
2
+
3
+ pytest_plugins = ["pytest_cov"]
4
+ pytest_plugins.append("tests.fixtures.connection")
@@ -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(session, "test@example.com", "test_password")
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(session=session, username="", password="", country="DE", interval=999, fulldebug=True)
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 username, password, spin, vin
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, reason="Username or password is not set. Check credentials.py.sample"
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, reason="Username or password is not set. Check credentials.py.sample"
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(f"using vin: {vin} and s-pin: {spin}")
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"