Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
WorkspaceClient
and AccountClient
more friendly with autospe…
…ccing (#480) ## Changes We cannot `create_autospec(WorkspaceClient)`, because all public properties are created within the constructor: ``` >>> WorkspaceClient <class 'databricks.sdk.WorkspaceClient'> >>> ws = create_autospec(WorkspaceClient) >>> ws <MagicMock spec='WorkspaceClient' id='4394200816'> >>> ws.workspace.list() Traceback (most recent call last): File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydevd_bundle/pydevd_exec2.py", line 3, in Exec exec(exp, global_vars, local_vars) File "<input>", line 1, in <module> File "/opt/homebrew/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/unittest/mock.py", line 643, in __getattr__ raise AttributeError("Mock object has no attribute %r" % name) AttributeError: Mock object has no attribute 'workspace' ``` This PR makes it easier to introspect the class instances and makes mocks more reliable. All existing behavior stays the same. See: - https://docs.python.org/3/library/unittest.mock.html#autospeccing - https://stackoverflow.com/a/35921144/277035 ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] `make test` run locally - [x] `make fmt` applied - [x] relevant integration tests applied
- Loading branch information