-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CDF-23800] 👁️🗨️ Improved error messages (#1475)
* refactor; stipulate solution * refactor; finished scaffolding * tests; added test for new case * feat; improved error message
- Loading branch information
Showing
5 changed files
with
115 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pytest | ||
from cognite.client.data_classes import ClientCredentials, OidcCredentials | ||
|
||
from cognite_toolkit._cdf_tk.utils.cdf import try_find_error | ||
|
||
|
||
class TestTryFindError: | ||
@pytest.mark.parametrize( | ||
"credentials, expected", | ||
[ | ||
pytest.param( | ||
ClientCredentials("${ENVIRONMENT_VAR}", "1234"), | ||
"The environment variable is not set: ENVIRONMENT_VAR.", | ||
id="Missing environment variable", | ||
), | ||
pytest.param( | ||
ClientCredentials("${ENV1}", "${ENV2}"), | ||
"The environment variables are not set: ENV1 and ENV2.", | ||
id="Missing environment variable", | ||
), | ||
pytest.param( | ||
OidcCredentials("my-client-id", "123", ["https://cognite.com"], "not-valid-uri", "my-project"), | ||
"The tokenUri 'not-valid-uri' is not a valid URI.", | ||
), | ||
pytest.param(None, None, id="empty"), | ||
], | ||
) | ||
def test_try_find_error(self, credentials: OidcCredentials | ClientCredentials | None, expected: str | None): | ||
assert try_find_error(credentials) == expected |