File: test_client.py

package info (click to toggle)
pytraccar 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 456 kB
  • sloc: python: 786; makefile: 3
file content (27 lines) | stat: -rw-r--r-- 741 bytes parent folder | download
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
"""Base client tests."""

import pytest
from aiohttp import ClientSession

from pytraccar import ApiClient


@pytest.mark.asyncio
async def test_client_init(client_session: ClientSession) -> None:
    """Test client init."""
    client_params = {
        "host": "127.0.0.1",
        "token": "test",
        "port": 8080,
        "client_session": client_session,
    }

    assert ApiClient(**client_params)._base_url == "http://127.0.0.1:8080/api"  # noqa: SLF001
    assert (
        ApiClient(**{**client_params, "port": None})._base_url  # noqa: SLF001
        == "http://127.0.0.1:8082/api"
    )
    assert (
        ApiClient(**{**client_params, "ssl": True})._base_url  # noqa: SLF001
        == "https://127.0.0.1:8080/api"
    )