File: requests_test.py

package info (click to toggle)
python-mypermobil 0.1.8-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 168 kB
  • sloc: python: 1,172; makefile: 3
file content (54 lines) | stat: -rw-r--r-- 1,491 bytes parent folder | download | duplicates (2)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
""" test auth control flow """

import aiounittest
import datetime
import unittest
import aiohttp
import asyncio
from unittest.mock import AsyncMock
from mypermobil import MyPermobil



# pylint: disable=missing-docstring
class TestRequest(aiounittest.AsyncTestCase):
    def setUp(self):
        ttl = datetime.datetime.now() + datetime.timedelta(days=1)
        self.api = MyPermobil(
            "test",
            AsyncMock(),
            email="valid@email.com",
            region="http://example.com",
            code="123456",
            token="a" * 256,
            expiration_date=ttl.strftime("%Y-%m-%d"),
        )
        self.api.self_authenticate()

    async def test_battery_info(self) -> dict:
        """ test battery info """
        self.api.request_endpoint = AsyncMock(return_value={})

        return await self.api.get_battery_info()

    async def test_daily_usage(self) -> dict:
        """ test daily usage info """
        self.api.request_endpoint = AsyncMock(return_value={})

        return await self.api.get_daily_usage()

    async def test_records_info(self) -> dict:
        """ test records info """
        self.api.request_endpoint = AsyncMock(return_value={})

        return await self.api.get_usage_records()

    async def test_gps_info(self) -> dict:
        """ test gps info """
        self.api.request_endpoint = AsyncMock(return_value={})

        return await self.api.get_gps_position()


if __name__ == "__main__":
    unittest.main()