import os
from unittest import TestCase
from unittest.mock import patch

from RatS.plex.plex_site import Plex

TESTDATA_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 'assets'))


class PlexSiteTest(TestCase):
    def setUp(self):
        if not os.path.exists(os.path.join(TESTDATA_PATH, 'exports')):
            os.makedirs(os.path.join(TESTDATA_PATH, 'exports'))

    @patch('RatS.plex.plex_site.Plex._parse_configuration')
    @patch('RatS.utils.browser_handler.Firefox')
    @patch('RatS.base.base_site.Site._init_browser')
    def test_determine_server_id(self, init_browser_mock, browser_mock, configuration_mock):
        browser_mock.current_url = 'http://localhost/web/index.html#!/settings/server/ThisIsAMockUUID/general'
        site = Plex(None)
        site.browser = browser_mock
        site.BASE_URL = 'localhost'

        result = site._determine_server_id()  # pylint: disable=protected-access

        self.assertEqual('ThisIsAMockUUID', result)

@@ -997,8 +997,2489 @@
 result)%0A
+%0A    @patch('RatS.base.base_site.Site._insert_login_credentials')%0A    @patch('RatS.plex.plex_site.Plex._parse_configuration')%0A    @patch('RatS.utils.browser_handler.Firefox')%0A    @patch('RatS.base.base_site.Site._init_browser')%0A    def test_insert_login_credentials(self, init_browser_mock, browser_mock, configuration_mock, base_site_mock):%0A        browser_mock.current_url = 'http://localhost/web/index.html#!/settings/server/ThisIsAMockUUID/general'%0A        site = Plex(None)%0A        site.browser = browser_mock%0A        site.BASE_URL = 'localhost'%0A%0A        site._insert_login_credentials()  # pylint: disable=protected-access%0A%0A        self.assertTrue(base_site_mock.called)%0A%0A    @patch('RatS.plex.plex_site.Plex._determine_plex_token')%0A    @patch('RatS.plex.plex_site.Plex._determine_server_id')%0A    @patch('RatS.utils.browser_handler.Firefox')%0A    @patch('RatS.base.base_site.Site._init_browser')%0A    def test_parse_configuration(self, init_browser_mock, browser_mock, server_id_mock, plex_token_mock):%0A        browser_mock.current_url = 'http://localhost/web/index.html#!/settings/server/ThisIsAMockUUID/general'%0A        site = Plex(None)%0A        site.browser = browser_mock%0A        server_id_mock.return_value = 'ThisIsAMockUUID'%0A        plex_token_mock.return_value = 'ThisIsAMockToken'%0A        site.BASE_URL = 'localhost'%0A%0A        site._parse_configuration()  # pylint: disable=protected-access%0A%0A        self.assertTrue(server_id_mock.called)%0A        self.assertTrue(plex_token_mock.called)%0A        self.assertEqual(%0A            'http://localhost/library/all?type=1&userRating!=0'%0A            '&X-Plex-Container-Start=0&X-Plex-Container-Size=100'%0A            '&X-Plex-Token=ThisIsAMockToken',%0A            site.MY_RATINGS_URL%0A        )%0A%0A    @patch('re.findall')%0A    @patch('RatS.plex.plex_site.Plex._parse_configuration')%0A    @patch('RatS.utils.browser_handler.Firefox')%0A    @patch('RatS.base.base_site.Site._init_browser')%0A    def test_determine_plex_token(self, init_browser_mock, browser_mock, configuration_mock, regex_mock):%0A        browser_mock.current_url = 'http://localhost/web/index.html#!/settings/server/ThisIsAMockUUID/general'%0A        site = Plex(None)%0A        site.browser = browser_mock%0A        site.SERVER_ID = 'ThisIsAMockUUID'%0A        site.BASE_URL = 'localhost'%0A        regex_mock.return_value = %5B'ThisIsAMockToken'%5D%0A%0A        result = site._determine_plex_token()  # pylint: disable=protected-access%0A%0A        self.assertEqual('ThisIsAMockToken', result)%0A

Increase test coverage