plugin.video.viervijfzes/tests/test_auth.py

39 lines
1.1 KiB
Python
Raw Normal View History

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)
@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):
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
auth.clear_tokens()
2020-03-19 16:45:31 +01:00
# We should get a token by logging in
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
id_token = auth.get_token()
self.assertTrue(id_token)
2020-03-19 16:45:31 +01:00
if __name__ == '__main__':
unittest.main()