2020-03-19 16:45:31 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
""" Tests for AUTH API """
|
|
|
|
|
|
|
|
# pylint: disable=missing-docstring,no-self-use
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
from resources.lib import kodiutils
|
|
|
|
from resources.lib.viervijfzes.auth import AuthApi
|
|
|
|
|
2020-07-09 10:16:45 +02:00
|
|
|
_LOGGER = logging.getLogger(__name__)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
class TestAuth(unittest.TestCase):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(TestAuth, self).__init__(*args, **kwargs)
|
|
|
|
|
2020-03-24 22:20:24 +01:00
|
|
|
@unittest.skipUnless(kodiutils.get_setting('username') and kodiutils.get_setting('password'), 'Skipping since we have no credentials.')
|
2020-03-19 16:45:31 +01:00
|
|
|
def test_login(self):
|
2020-04-01 11:01:22 +02:00
|
|
|
auth = AuthApi(kodiutils.get_setting('username'), kodiutils.get_setting('password'), kodiutils.get_tokens_path())
|
|
|
|
|
2020-03-19 16:45:31 +01:00
|
|
|
# Clear any cache we have
|
2020-04-01 11:01:22 +02:00
|
|
|
auth.clear_tokens()
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
# We should get a token by logging in
|
2021-02-09 20:54:40 +01:00
|
|
|
id_token = auth.get_token()
|
|
|
|
self.assertTrue(id_token)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
# Test it a second time, it should go from memory now
|
2021-02-09 20:54:40 +01:00
|
|
|
id_token = auth.get_token()
|
|
|
|
self.assertTrue(id_token)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|