File: test_auth.py

package info (click to toggle)
tessie-api 0.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 308 kB
  • sloc: python: 1,308; sh: 6; makefile: 3
file content (14 lines) | stat: -rw-r--r-- 617 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import os
from dotenv import load_dotenv
import aiohttp
import pytest

from tessie_api import get_state_of_all_vehicles

@pytest.mark.asyncio
async def test_can_get_vehicles():
    load_dotenv()  # take environment variables from .env.
    async with aiohttp.ClientSession() as session:  # ClientSession is created here and will be closed when exiting the block
        data = await get_state_of_all_vehicles(session=session, api_key=os.getenv("TESSIE_KEY"), only_active=True)
        vin_to_check = os.getenv("TESLA_VIN")
        assert any(result["vin"] == vin_to_check for result in data["results"])