|
3 | 3 | from firebolt.async_db import Connection, connect |
4 | 4 | from firebolt.client.auth import ClientCredentials |
5 | 5 | from firebolt.utils.exception import ( |
6 | | - AccountNotFoundError, |
| 6 | + AccountNotFoundOrNoAccessError, |
7 | 7 | EngineNotRunningError, |
8 | 8 | FireboltEngineError, |
9 | 9 | InterfaceError, |
|
13 | 13 |
|
14 | 14 | async def test_invalid_account( |
15 | 15 | database_name: str, |
16 | | - engine_name: str, |
| 16 | + invalid_account_name: str, |
17 | 17 | auth: ClientCredentials, |
18 | 18 | api_endpoint: str, |
19 | 19 | ) -> None: |
20 | 20 | """Connection properly reacts to invalid account error.""" |
21 | | - account_name = "--" |
22 | | - with raises(AccountNotFoundError) as exc_info: |
| 21 | + with raises(AccountNotFoundOrNoAccessError) as exc_info: |
23 | 22 | async with await connect( |
24 | 23 | database=database_name, |
25 | | - engine_name=engine_name, |
26 | 24 | auth=auth, |
| 25 | + account_name=invalid_account_name, |
| 26 | + api_endpoint=api_endpoint, |
| 27 | + ) as connection: |
| 28 | + await connection.cursor().execute("show tables") |
| 29 | + |
| 30 | + assert str(exc_info.value).startswith( |
| 31 | + f"Account '{invalid_account_name}' does not exist" |
| 32 | + ), "Invalid account error message." |
| 33 | + |
| 34 | + |
| 35 | +async def test_account_no_user( |
| 36 | + database_name: str, |
| 37 | + account_name: str, |
| 38 | + auth_no_user: ClientCredentials, |
| 39 | + api_endpoint: str, |
| 40 | +) -> None: |
| 41 | + """Connection properly reacts to account that doesn't have |
| 42 | + a user attached to it.""" |
| 43 | + with raises(AccountNotFoundOrNoAccessError) as exc_info: |
| 44 | + async with await connect( |
| 45 | + database=database_name, |
| 46 | + auth=auth_no_user, |
27 | 47 | account_name=account_name, |
28 | 48 | api_endpoint=api_endpoint, |
29 | 49 | ) as connection: |
30 | 50 | await connection.cursor().execute("show tables") |
31 | 51 |
|
32 | | - assert str(exc_info.value).startswith( |
33 | | - f'Account "{account_name}" does not exist' |
34 | | - ), "Invalid account error message." |
| 52 | + assert str(exc_info.value).startswith( |
| 53 | + f"Account '{account_name}' does not exist" |
| 54 | + ), "Invalid account error message." |
35 | 55 |
|
36 | 56 |
|
37 | 57 | async def test_engine_name_not_exists( |
|
0 commit comments