Add Plex config flow support (#26548)
* Add config flow support * Log error on failed connection * Review comments * Unused errors * Move form to step * Use instance var instead of passing argument * Only share servers created by component * Return errors early to avoid try:else * Separate debug for validation vs setup * Unnecessary * Unnecessary checks * Combine import flows, move logic to component * Use config entry discovery handler * Temporary lint fix * Filter out servers already configured * Remove manual config flow * Skip discovery if a config exists * Swap conditional to reduce indenting * Only discover when no configs created or creating * Un-nest function * Proper async use * Move legacy file import to discovery * Fix, bad else * Separate validate step * Unused without manual setup step * Async oops * First attempt at tests * Test cleanup * Full test coverage for config_flow, enable tests * Lint * Fix lint vs black * Add test init * Add test package requirement * Actually run script * Use 'not None' convention * Group exceptions by result * Improve logic, add new error and test * Test cleanup * Add more asserts
This commit is contained in:
1 parent
246a611a7c
commit
2d12bac0e2
17 files changed
+836
-172
No files matched your search
@@ -0,0 +1,35 @@
|
||||
"""Mock classes used in tests."""
|
||||
|
||||
MOCK_HOST_1 = "1.2.3.4"
|
||||
MOCK_PORT_1 = "32400"
|
||||
MOCK_HOST_2 = "4.3.2.1"
|
||||
MOCK_PORT_2 = "32400"
|
||||
|
||||
|
||||
class MockAvailableServer: # pylint: disable=too-few-public-methods
|
||||
"""Mock avilable server objects."""
|
||||
|
||||
def __init__(self, name, client_id):
|
||||
"""Initialize the object."""
|
||||
self.name = name
|
||||
self.clientIdentifier = client_id # pylint: disable=invalid-name
|
||||
self.provides = ["server"]
|
||||
|
||||
|
||||
class MockConnection: # pylint: disable=too-few-public-methods
|
||||
"""Mock a single account resource connection object."""
|
||||
|
||||
def __init__(self, ssl):
|
||||
"""Initialize the object."""
|
||||
prefix = "https" if ssl else "http"
|
||||
self.httpuri = f"{prefix}://{MOCK_HOST_1}:{MOCK_PORT_1}"
|
||||
self.uri = "{prefix}://{MOCK_HOST_2}:{MOCK_PORT_2}"
|
||||
self.local = True
|
||||
|
||||
|
||||
class MockConnections: # pylint: disable=too-few-public-methods
|
||||
"""Mock a list of resource connections."""
|
||||
|
||||
def __init__(self, ssl=False):
|
||||
"""Initialize the object."""
|
||||
self.connections = [MockConnection(ssl)]
|
||||
Reference in new issue
Block a user