Skip to content

Commit

Permalink
Increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
StegSchreck committed Mar 23, 2019
1 parent 955ebfb commit e057af3
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/unit/plex/test_plex_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,56 @@ def test_determine_server_id(self, init_browser_mock, browser_mock, configuratio
result = site._determine_server_id() # pylint: disable=protected-access

self.assertEqual('ThisIsAMockUUID', result)

@patch('RatS.base.base_site.Site._insert_login_credentials')
@patch('RatS.plex.plex_site.Plex._parse_configuration')
@patch('RatS.utils.browser_handler.Firefox')
@patch('RatS.base.base_site.Site._init_browser')
def test_insert_login_credentials(self, init_browser_mock, browser_mock, configuration_mock, base_site_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'

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

self.assertTrue(base_site_mock.called)

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

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

self.assertTrue(server_id_mock.called)
self.assertTrue(plex_token_mock.called)
self.assertEqual(
'http://localhost/library/all?type=1&userRating!=0'
'&X-Plex-Container-Start=0&X-Plex-Container-Size=100'
'&X-Plex-Token=ThisIsAMockToken',
site.MY_RATINGS_URL
)

@patch('re.findall')
@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_plex_token(self, init_browser_mock, browser_mock, configuration_mock, regex_mock):
browser_mock.current_url = 'http://localhost/web/index.html#!/settings/server/ThisIsAMockUUID/general'
site = Plex(None)
site.browser = browser_mock
site.SERVER_ID = 'ThisIsAMockUUID'
site.BASE_URL = 'localhost'
regex_mock.return_value = ['ThisIsAMockToken']

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

self.assertEqual('ThisIsAMockToken', result)

0 comments on commit e057af3

Please sign in to comment.