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
|
|
|
|
|
|
|
|
_LOGGER = logging.getLogger('test-auth')
|
|
|
|
|
|
|
|
|
|
|
|
class TestAuth(unittest.TestCase):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(TestAuth, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
def test_login(self):
|
|
|
|
# Clear any cache we have
|
2020-03-22 15:37:15 +01:00
|
|
|
AuthApi.clear_tokens()
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
# We should get a token by logging in
|
2020-03-22 15:37:15 +01:00
|
|
|
auth = AuthApi(kodiutils.get_setting('username'), kodiutils.get_setting('password'))
|
|
|
|
token = auth.get_token()
|
2020-03-19 16:45:31 +01:00
|
|
|
self.assertTrue(token)
|
|
|
|
|
|
|
|
# Test it a second time, it should go from memory now
|
2020-03-22 15:37:15 +01:00
|
|
|
auth = AuthApi(kodiutils.get_setting('username'), kodiutils.get_setting('password'))
|
|
|
|
token = auth.get_token()
|
2020-03-19 16:45:31 +01:00
|
|
|
self.assertTrue(token)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|