volkswagencarnet 5.0.0b2__tar.gz → 5.0.0b4__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/.github/workflows/codecov.yaml +35 -0
  2. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.github/workflows/codeql-analysis.yml +1 -1
  3. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.github/workflows/release.yaml +1 -1
  4. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.github/workflows/testrelease.yaml +3 -3
  5. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.github/workflows/validate.yml +25 -7
  6. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.pre-commit-config.yaml +12 -1
  7. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/PKG-INFO +5 -5
  8. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/README.md +2 -2
  9. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/pyproject.toml +13 -0
  10. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/requirements-test.txt +3 -0
  11. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/setup.cfg +28 -2
  12. volkswagencarnet-5.0.0b4/tests/conftest.py +8 -0
  13. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/dummy_test.py +3 -4
  14. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/connection.py +3 -10
  15. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/integration_test.py +12 -11
  16. volkswagencarnet-5.0.0b4/tests/vw_connection_test.py +178 -0
  17. volkswagencarnet-5.0.0b4/tests/vw_exceptions_test.py +14 -0
  18. volkswagencarnet-5.0.0b4/tests/vw_utilities_test.py +168 -0
  19. volkswagencarnet-5.0.0b4/tests/vw_vehicle_test.py +300 -0
  20. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet/version.py +1 -1
  21. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet/vw_connection.py +398 -489
  22. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet/vw_const.py +1 -1
  23. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet/vw_dashboard.py +139 -450
  24. volkswagencarnet-5.0.0b4/volkswagencarnet/vw_exceptions.py +7 -0
  25. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet/vw_utilities.py +40 -24
  26. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet/vw_vehicle.py +678 -1646
  27. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet.egg-info/PKG-INFO +5 -5
  28. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet.egg-info/SOURCES.txt +4 -0
  29. volkswagencarnet-5.0.0b2/tests/conftest.py +0 -4
  30. volkswagencarnet-5.0.0b2/tests/vw_connection_test.py +0 -98
  31. volkswagencarnet-5.0.0b2/tests/vw_utilities_test.py +0 -116
  32. volkswagencarnet-5.0.0b2/tests/vw_vehicle_test.py +0 -245
  33. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.github/CODEOWNERS +0 -0
  34. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.github/dependabot.yml +0 -0
  35. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.github/release-drafter.yml +0 -0
  36. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.github/renovate.json +0 -0
  37. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.github/workflows/publish.yaml +0 -0
  38. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.github/workflows/snyk.yaml +0 -0
  39. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.github/workflows/validate_pr.yaml +0 -0
  40. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/.gitignore +0 -0
  41. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/LICENSE.txt +0 -0
  42. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/requirements.txt +0 -0
  43. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/__init__.py +0 -0
  44. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/credentials.py.sample +0 -0
  45. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/__init__.py +0 -0
  46. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/constants.py +0 -0
  47. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/mock_server.py +1 -1
  48. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/dummy_cookies.pickle +0 -0
  49. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/README.md +0 -0
  50. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/arteon_2023_diesel/capabilities.json +0 -0
  51. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/arteon_2023_diesel/last_trip.json +0 -0
  52. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/arteon_2023_diesel/parkingposition.json +0 -0
  53. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/arteon_2023_diesel/selectivestatus_by_app.json +0 -0
  54. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/egolf/README.md +0 -0
  55. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/egolf/capabilities.json +0 -0
  56. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/egolf/last_trip.json +0 -0
  57. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/egolf/parkingposition.json +0 -0
  58. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/egolf/selectivestatus_by_app.json +0 -0
  59. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/eup_electric/capabilities.json +0 -0
  60. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/eup_electric/last_trip.json +0 -0
  61. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/eup_electric/parkingposition.json +0 -0
  62. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/eup_electric/selectivestatus_by_app.json +0 -0
  63. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/golf_gte_hybrid/capabilities.json +0 -0
  64. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/golf_gte_hybrid/last_trip.json +0 -0
  65. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/golf_gte_hybrid/selectivestatus_by_app.json +0 -0
  66. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/status.json +0 -0
  67. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/timer.json +0 -0
  68. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/tests/fixtures/resources/responses/timer_without_settings.json +0 -0
  69. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet/__init__.py +0 -0
  70. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet.egg-info/dependency_links.txt +0 -0
  71. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet.egg-info/requires.txt +0 -0
  72. {volkswagencarnet-5.0.0b2 → volkswagencarnet-5.0.0b4}/volkswagencarnet.egg-info/top_level.txt +0 -0
@@ -0,0 +1,35 @@
1
+ name: "CodeCov"
2
+ on: [push]
3
+ jobs:
4
+ analyze:
5
+ name: Analyze
6
+ runs-on: ubuntu-latest
7
+ env:
8
+ OS: ubuntu-latest
9
+ PYTHON: '3.11'
10
+
11
+ steps:
12
+ - name: Checkout repository
13
+ uses: actions/checkout@v4
14
+
15
+ - name: Setup Python
16
+ uses: actions/setup-python@v5
17
+ with:
18
+ python-version: 3.11
19
+
20
+ - name: Generate coverage report
21
+ run: |
22
+ pip install -r requirements-test.txt
23
+ pytest --cov=./ --cov-report=xml
24
+
25
+ # documentation: https://github.com/codecov/codecov-action
26
+ - name: Upload Coverage to Codecov
27
+ uses: codecov/codecov-action@v4
28
+ with:
29
+ directory: ./coverage/reports/
30
+ env_vars: OS,PYTHON
31
+ fail_ci_if_error: true
32
+ files: ./coverage.xml
33
+ flags: unittests
34
+ name: codecov-volkswagencarnet
35
+ verbose: true
@@ -22,7 +22,7 @@ jobs:
22
22
  fail-fast: false
23
23
  matrix:
24
24
  language: ["python"]
25
- python-version: ["3.11", "3.12"]
25
+ python-version: ["3.8", "3.9", "3.10", "3.11"]
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 ruff with a variety of Python versions
1
+ # This workflow will install Python dependencies, run tests and lint 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,25 +14,43 @@ on:
14
14
  - master
15
15
 
16
16
  jobs:
17
- ruff:
18
- name: Ruff
17
+ lint:
18
+ name: Lint
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: Check ruff
26
- uses: chartboost/ruff-action@v1
25
+ - name: Set up Python 3.11
26
+ uses: actions/setup-python@v5
27
27
  with:
28
- args: 'format --diff'
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 .
29
47
 
30
48
  test-n-build:
31
49
  name: Test and Build
32
50
  runs-on: ubuntu-latest
33
51
  strategy:
34
52
  matrix:
35
- python-version: ["3.11", "3.12"]
53
+ python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
36
54
 
37
55
  steps:
38
56
  - 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.11
4
+ python: python3.9
5
5
 
6
6
  repos:
7
7
  - repo: https://github.com/pre-commit/pre-commit-hooks
@@ -18,6 +18,17 @@ 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
+
21
32
  - repo: https://github.com/asottile/pyupgrade
22
33
  rev: v2.31.0
23
34
  hooks:
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: volkswagencarnet
3
- Version: 5.0.0b2
4
- Summary: Communicate with Volkswagen Connect
3
+ Version: 5.0.0b4
4
+ Summary: Communicate with Volkswagen WeConnect
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.11
13
+ Requires-Python: >=3.7
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/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)
28
+ ![CodeStyle](https://img.shields.io/badge/code%20style-black-black)
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 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
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
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/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)
8
+ ![CodeStyle](https://img.shields.io/badge/code%20style-black-black)
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 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
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
21
21
 
22
22
  ## Information
23
23
 
@@ -10,6 +10,19 @@ 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
+
13
26
  [tool.pytest.ini_options]
14
27
  minversion = "6.0"
15
28
  addopts = "-ra"
@@ -1,4 +1,7 @@
1
1
  -r requirements.txt
2
+ black
3
+ flake8
4
+ flake8-docstrings
2
5
  freezegun>=1.0.0
3
6
  pre-commit
4
7
  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 Connect
5
+ description = Communicate with Volkswagen WeConnect
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.11
26
+ python_requires = >= 3.7
27
27
 
28
28
  [options.packages.find]
29
29
  where = .
@@ -31,6 +31,32 @@ 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
+
34
60
  [pycodestyle]
35
61
  max_line_length = 120
36
62
  statistics = True
@@ -0,0 +1,8 @@
1
+ """Configure tests."""
2
+
3
+ import sys
4
+
5
+ pytest_plugins = ["pytest_cov"]
6
+
7
+ if sys.version_info >= (3, 8):
8
+ pytest_plugins.append("tests.fixtures.connection")
@@ -1,7 +1,8 @@
1
1
  """Dummy tests. Might be removed once there are proper ones."""
2
2
 
3
- from aiohttp import ClientSession
4
3
  import pytest
4
+ from aiohttp import ClientSession
5
+
5
6
  from volkswagencarnet import vw_connection
6
7
 
7
8
 
@@ -9,8 +10,6 @@ from volkswagencarnet import vw_connection
9
10
  async def test_volkswagencarnet():
10
11
  """Dummy test to ensure logged in status is false by default."""
11
12
  async with ClientSession() as session:
12
- connection = vw_connection.Connection(
13
- session, "test@example.com", "test_password"
14
- )
13
+ connection = vw_connection.Connection(session, "test@example.com", "test_password")
15
14
  # if await connection._login():
16
15
  assert connection.logged_in is False
@@ -2,11 +2,11 @@
2
2
 
3
3
  import os
4
4
 
5
- from aiohttp import ClientSession, CookieJar
6
5
  import pytest
7
6
  import pytest_asyncio
8
- from volkswagencarnet.vw_connection import Connection
7
+ from aiohttp import CookieJar, ClientSession
9
8
 
9
+ from volkswagencarnet.vw_connection import Connection
10
10
  from .constants import resource_path
11
11
 
12
12
 
@@ -23,11 +23,4 @@ async def session():
23
23
  @pytest.fixture
24
24
  def connection(session):
25
25
  """Real connection for integration tests."""
26
- return Connection(
27
- session=session,
28
- username="",
29
- password="",
30
- country="DE",
31
- interval=999,
32
- fulldebug=True,
33
- )
26
+ return Connection(session=session, username="", password="", country="DE", interval=999, fulldebug=True)
@@ -1,4 +1,5 @@
1
- """Integration tests.
1
+ """
2
+ Integration tests.
2
3
 
3
4
  These tests use actual credentials, and should thus be used with care.
4
5
  Credentials have to be specified in credentials.py.
@@ -6,22 +7,22 @@ Credentials have to be specified in credentials.py.
6
7
 
7
8
  import logging
8
9
 
9
- from aiohttp import ClientSession
10
10
  import pytest
11
+ from aiohttp import ClientSession
12
+
11
13
  from volkswagencarnet import vw_connection
12
14
 
13
15
  try:
14
- from credentials import password, spin, username, vin
16
+ from credentials import username, password, spin, vin
15
17
  except ImportError:
16
18
  username = password = spin = vin = None
17
19
 
18
20
 
19
21
  @pytest.mark.skipif(
20
- username is None or password is None,
21
- reason="Username or password is not set. Check credentials.py.sample",
22
+ username is None or password is None, reason="Username or password is not set. Check credentials.py.sample"
22
23
  )
23
24
  @pytest.mark.asyncio
24
- async def test_successful_login() -> None:
25
+ async def test_successful_login():
25
26
  """Test that login succeeds."""
26
27
  async with ClientSession() as session:
27
28
  connection = vw_connection.Connection(session, username, password)
@@ -30,14 +31,14 @@ async def test_successful_login() -> None:
30
31
 
31
32
 
32
33
  @pytest.mark.skipif(
33
- username is None or password is None,
34
- reason="Username or password is not set. Check credentials.py.sample",
34
+ username is None or password is None, 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() -> None:
39
- """Test something that uses s-pin.
38
+ async def test_spin_action():
39
+ """
40
+ Test something that uses s-pin.
40
41
 
41
42
  Not yet implemented...
42
43
  """
43
- logging.getLogger().debug("using vin: %s and s-pin: %s", vin, spin)
44
+ logging.getLogger().debug(f"using vin: {vin} and s-pin: {spin}")
@@ -0,0 +1,178 @@
1
+ """Tests for main connection class."""
2
+
3
+ import sys
4
+
5
+ import aiohttp
6
+ from aiohttp import client_exceptions
7
+
8
+ from volkswagencarnet import vw_connection
9
+ from volkswagencarnet.vw_connection import Connection
10
+
11
+ if sys.version_info >= (3, 8):
12
+ # This won't work on python versions less than 3.8
13
+ from unittest import IsolatedAsyncioTestCase
14
+ else:
15
+ from unittest import TestCase
16
+
17
+ class IsolatedAsyncioTestCase(TestCase):
18
+ """Dummy class to use instead (tests might need to skipped separately also)."""
19
+
20
+ pass
21
+
22
+
23
+ from io import StringIO
24
+ from unittest.mock import patch, MagicMock
25
+
26
+ import pytest
27
+
28
+
29
+ class TwoVehiclesConnection(Connection):
30
+ """Connection that return two vehicles."""
31
+
32
+ ALLOW_RATE_LIMIT_DELAY = False
33
+
34
+ # noinspection PyUnusedLocal
35
+ # noinspection PyMissingConstructor
36
+ def __init__(self, sess, username="", password="", **kwargs):
37
+ """Init."""
38
+ super().__init__(session=sess, username=username, password=password)
39
+ self._jarCookie = MagicMock()
40
+
41
+ async def doLogin(self, tries=1):
42
+ """No-op update."""
43
+ return True
44
+
45
+ async def update(self):
46
+ """No-op update."""
47
+ return True
48
+
49
+ @property
50
+ def vehicles(self):
51
+ """Return the vehicles."""
52
+ vehicle1 = vw_connection.Vehicle(None, "vin1")
53
+ vehicle2 = vw_connection.Vehicle(None, "vin2")
54
+ return [vehicle1, vehicle2]
55
+
56
+
57
+ @pytest.mark.skipif(condition=sys.version_info < (3, 8), reason="Test incompatible with Python < 3.8")
58
+ def test_clear_cookies(connection):
59
+ """Check that we can clear old cookies."""
60
+ assert len(connection._session._cookie_jar._cookies) > 0
61
+ connection._clear_cookies()
62
+ assert len(connection._session._cookie_jar._cookies) == 0
63
+
64
+
65
+ class CmdLineTest(IsolatedAsyncioTestCase):
66
+ """Tests mostly for testing how to test..."""
67
+
68
+ class FailingLoginConnection:
69
+ """This connection always fails login."""
70
+
71
+ # noinspection PyUnusedLocal
72
+ def __init__(self, sess, **kwargs):
73
+ """Init."""
74
+ self._session = sess
75
+
76
+ # noinspection PyPep8Naming,PyMethodMayBeStatic
77
+ async def doLogin(self):
78
+ """Failed login attempt."""
79
+ return False
80
+
81
+ @pytest.mark.asyncio
82
+ @patch.object(vw_connection.logging, "basicConfig")
83
+ @patch("volkswagencarnet.vw_connection.Connection", spec_set=vw_connection.Connection, new=FailingLoginConnection)
84
+ @pytest.mark.skipif(condition=sys.version_info < (3, 8), reason="Test incompatible with Python < 3.8")
85
+ async def test_main_argv(self, logger_config):
86
+ """Test verbosity flags."""
87
+ from logging import ERROR
88
+ from logging import INFO
89
+ from logging import DEBUG
90
+
91
+ cases = [
92
+ ["none", [], ERROR],
93
+ ["-v", ["-v"], INFO],
94
+ ["-v2", ["-v2"], ERROR],
95
+ ["-vv", ["-vv"], DEBUG],
96
+ ]
97
+ for c in cases:
98
+ args = ["dummy"]
99
+ args.extend(c[1])
100
+ with patch.object(vw_connection.sys, "argv", args), self.subTest(msg=c[0]):
101
+ await vw_connection.main()
102
+ logger_config.assert_called_with(level=c[2])
103
+ logger_config.reset()
104
+
105
+ @pytest.mark.asyncio
106
+ @patch("sys.stdout", new_callable=StringIO)
107
+ @patch("volkswagencarnet.vw_connection.Connection", spec_set=vw_connection.Connection, new=FailingLoginConnection)
108
+ @pytest.mark.skipif(condition=sys.version_info < (3, 8), reason="Test incompatible with Python < 3.8")
109
+ async def test_main_output_failed(self, stdout: StringIO):
110
+ """Verify empty stdout on failed login."""
111
+ await vw_connection.main()
112
+ assert stdout.getvalue() == ""
113
+
114
+ @pytest.mark.asyncio
115
+ @patch("sys.stdout", new_callable=StringIO)
116
+ @patch("volkswagencarnet.vw_connection.Connection", spec_set=vw_connection.Connection, new=TwoVehiclesConnection)
117
+ @pytest.mark.skipif(condition=sys.version_info < (3, 8), reason="Test incompatible with Python < 3.8")
118
+ async def test_main_output_two_vehicles(self, stdout: StringIO):
119
+ """Get console output for two vehicles."""
120
+ await vw_connection.main()
121
+ assert (
122
+ stdout.getvalue()
123
+ == """Vehicle id: vin1
124
+ Supported sensors:
125
+ - Force data refresh (domain:switch) - Off
126
+ - Request results (domain:sensor) - Unknown
127
+ - Requests remaining (domain:sensor) - -1
128
+ - Request in progress (domain:binary_sensor) - Off
129
+ Vehicle id: vin2
130
+ Supported sensors:
131
+ - Force data refresh (domain:switch) - Off
132
+ - Request results (domain:sensor) - Unknown
133
+ - Requests remaining (domain:sensor) - -1
134
+ - Request in progress (domain:binary_sensor) - Off
135
+ """
136
+ )
137
+
138
+
139
+ class SendCommandsTest(IsolatedAsyncioTestCase):
140
+ """Test command sending."""
141
+
142
+ async def test_set_schedule(self):
143
+ """Test set schedule."""
144
+ pass
145
+
146
+
147
+ class RateLimitTest(IsolatedAsyncioTestCase):
148
+ """Test that rate limiting towards VW works."""
149
+
150
+ invocations = 0
151
+
152
+ async def rateLimitedFunction(self, url, vin=""):
153
+ """Limit calls test function."""
154
+ ri = MagicMock(aiohttp.RequestInfo)
155
+ e = client_exceptions.ClientResponseError(request_info=ri, history=tuple([]))
156
+ e.status = 429
157
+ self.invocations = self.invocations + 1
158
+ raise e
159
+
160
+ @pytest.mark.asyncio
161
+ @pytest.mark.skipif(condition=sys.version_info < (3, 9), reason="Test incompatible with Python < 3.9")
162
+ @patch("volkswagencarnet.vw_connection.Connection", spec_set=vw_connection.Connection, new=TwoVehiclesConnection)
163
+ @patch("volkswagencarnet.vw_connection.MAX_RETRIES_ON_RATE_LIMIT", 1)
164
+ async def test_rate_limit(self):
165
+ """Test rate limiting functionality."""
166
+
167
+ from unittest.mock import AsyncMock
168
+
169
+ sess = AsyncMock()
170
+
171
+ # noinspection PyArgumentList
172
+ conn = vw_connection.Connection(sess, "", "")
173
+
174
+ self.invocations = 0
175
+ with patch.object(conn, "_request", self.rateLimitedFunction):
176
+ res = await conn.get("foo")
177
+ assert res == {"status_code": 429}
178
+ assert self.invocations == vw_connection.MAX_RETRIES_ON_RATE_LIMIT + 1
@@ -0,0 +1,14 @@
1
+ """Misc tests for exception and their handling."""
2
+
3
+ from unittest import TestCase
4
+
5
+ from volkswagencarnet.vw_exceptions import AuthenticationException
6
+
7
+
8
+ class ExceptionTests(TestCase):
9
+ """Unit tests for exceptions."""
10
+
11
+ def test_auth_exception(self):
12
+ """Test that message matches. Dummy test."""
13
+ ex = AuthenticationException("foo failed")
14
+ self.assertEqual("foo failed", ex.__str__())