File: misc_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 (32 lines) | stat: -rw-r--r-- 784 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
""" test auth control flow """

import aiounittest
import datetime
import unittest
from unittest.mock import MagicMock, AsyncMock
from mypermobil import MyPermobil, MyPermobilClientException, MyPermobilAPIException


# pylint: disable=missing-docstring
class TestAuth(aiounittest.AsyncTestCase):
    def setUp(self):
        self.api = MyPermobil(
            "test",
            AsyncMock(),
            region="http://example.com",
        )

    def test_str(self):
        x = str(self.api)
        assert x

    async def test_close_session(self):
        await self.api.close_session()
        assert self.api.session is None

        with self.assertRaises(MyPermobilClientException):
            await self.api.close_session()


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