Skip to content

Commit

Permalink
feat: add overriding workspace test
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmbmb committed Aug 21, 2023
1 parent 4e719cf commit 74ca678
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/integration/client/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,26 @@ def test_init_with_stored_credentials(mock_init_ok, mocker):
)


def test_init_with_stored_credentials_overriding_workspace(mock_init_ok, mocker):
mocker.patch(
"builtins.open",
mocker.mock_open(
read_data='{"api_url": "http://integration-test.com:6900", "api_key": "integration.test", "workspace": "my_workspace", "extra_headers": {"X-Integration-Test": "true"}}'
),
)
path_mock = mocker.patch.object(Path, "exists")
path_mock.return_value = True

init(workspace="mock_workspace")

assert active_client()._client == AuthenticatedClient(
base_url="http://integration-test.com:6900",
token="integration.test",
timeout=60,
headers={WORKSPACE_HEADER_NAME: "mock_workspace", "X-Integration-Test": "true"},
)


@pytest.mark.asyncio
async def test_init_with_workspace(owner: User) -> None:
workspace = await WorkspaceFactory.create(name="test_workspace")
Expand Down

0 comments on commit 74ca678

Please sign in to comment.