File: test_credential.py

package info (click to toggle)
python-renault-api 0.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 1,680 kB
  • sloc: python: 7,679; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 803 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""Tests for Credential models."""

import time
from unittest import mock

from tests.fixtures import get_jwt

from renault_api.credential import Credential
from renault_api.credential import JWTCredential

TEST_VALUE = "test-value"


def test_simple_credential() -> None:
    """Test for Credential class."""
    credential = Credential(TEST_VALUE)

    assert credential.value == TEST_VALUE
    assert not credential.has_expired()


def test_jwt() -> None:
    """Test for Credential class."""
    jwt_token = get_jwt()

    credential = JWTCredential(jwt_token)

    assert credential.value == jwt_token
    assert not credential.has_expired()

    expired_time = time.time() + 3600
    with mock.patch("time.time", mock.MagicMock(return_value=expired_time)):
        assert credential.has_expired()