2017-01-09 04:40:39 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
|
|
|
|
def test_myplex_accounts(account, plex):
|
2017-01-09 04:40:39 +00:00
|
|
|
assert account, 'Must specify username, password & resource to run this test.'
|
2017-02-02 04:10:12 +00:00
|
|
|
print('MyPlexAccount:')
|
|
|
|
print('username: %s' % account.username)
|
|
|
|
print('email: %s' % account.email)
|
|
|
|
print('home: %s' % account.home)
|
|
|
|
print('queueEmail: %s' % account.queueEmail)
|
2017-01-09 04:40:39 +00:00
|
|
|
assert account.username, 'Account has no username'
|
|
|
|
assert account.authenticationToken, 'Account has no authenticationToken'
|
|
|
|
assert account.email, 'Account has no email'
|
|
|
|
assert account.home is not None, 'Account has no home'
|
|
|
|
assert account.queueEmail, 'Account has no queueEmail'
|
2017-04-15 00:47:59 +00:00
|
|
|
account = plex.account()
|
2017-02-02 04:10:12 +00:00
|
|
|
print('Local PlexServer.account():')
|
|
|
|
print('username: %s' % account.username)
|
|
|
|
print('authToken: %s' % account.authToken)
|
|
|
|
print('signInState: %s' % account.signInState)
|
2017-01-09 04:40:39 +00:00
|
|
|
assert account.username, 'Account has no username'
|
|
|
|
assert account.authToken, 'Account has no authToken'
|
|
|
|
assert account.signInState, 'Account has no signInState'
|
|
|
|
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def test_myplex_resources(account):
|
2017-01-09 04:40:39 +00:00
|
|
|
assert account, 'Must specify username, password & resource to run this test.'
|
|
|
|
resources = account.resources()
|
|
|
|
for resource in resources:
|
|
|
|
name = resource.name or 'Unknown'
|
|
|
|
connections = [c.uri for c in resource.connections]
|
|
|
|
connections = ', '.join(connections) if connections else 'None'
|
2017-02-02 04:10:12 +00:00
|
|
|
print('%s (%s): %s' % (name, resource.product, connections))
|
2017-01-09 04:40:39 +00:00
|
|
|
assert resources, 'No resources found for account: %s' % account.name
|
|
|
|
|
2017-02-02 04:10:12 +00:00
|
|
|
|
2017-04-24 02:59:22 +00:00
|
|
|
def test_myplex_connect_to_resource(plex, account):
|
|
|
|
servername = plex.friendlyName
|
2017-04-15 00:47:59 +00:00
|
|
|
for resource in account.resources():
|
2017-04-24 02:59:22 +00:00
|
|
|
if resource.name == servername:
|
2017-02-02 04:10:12 +00:00
|
|
|
break
|
2017-04-24 02:59:22 +00:00
|
|
|
assert resource.connect(timeout=10)
|
2017-02-02 04:10:12 +00:00
|
|
|
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def test_myplex_devices(account):
|
2017-01-09 04:40:39 +00:00
|
|
|
devices = account.devices()
|
|
|
|
for device in devices:
|
|
|
|
name = device.name or 'Unknown'
|
|
|
|
connections = ', '.join(device.connections) if device.connections else 'None'
|
2017-02-02 04:10:12 +00:00
|
|
|
print('%s (%s): %s' % (name, device.product, connections))
|
2017-01-09 04:40:39 +00:00
|
|
|
assert devices, 'No devices found for account: %s' % account.name
|
|
|
|
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def _test_myplex_connect_to_device(account):
|
2017-01-09 04:40:39 +00:00
|
|
|
devices = account.devices()
|
|
|
|
for device in devices:
|
2017-02-02 04:10:12 +00:00
|
|
|
if device.name == 'some client name' and len(device.connections):
|
2017-01-09 04:40:39 +00:00
|
|
|
break
|
|
|
|
client = device.connect()
|
|
|
|
assert client, 'Unable to connect to device'
|
2017-02-02 04:10:12 +00:00
|
|
|
|
|
|
|
|
2017-04-15 00:47:59 +00:00
|
|
|
def test_myplex_users(account):
|
2017-02-02 04:10:12 +00:00
|
|
|
users = account.users()
|
|
|
|
assert users, 'Found no users on account: %s' % account.name
|
|
|
|
print('Found %s users.' % len(users))
|
2017-04-15 00:47:59 +00:00
|
|
|
user = account.user(users[0].title)
|
2017-02-02 04:10:12 +00:00
|
|
|
print('Found user: %s' % user)
|
2017-04-15 00:47:59 +00:00
|
|
|
assert user, 'Could not find user %s' % users[0].title
|