Hello,
is it possible to test the CogniteAuthError using monkeypatch context manager ?
Regards ,
Hakim Arezki
Best answer by Dilini Fernando
View originalHello,
is it possible to test the CogniteAuthError using monkeypatch context manager ?
Regards ,
Hakim Arezki
Best answer by Dilini Fernando
View originalHello Hakim,
You can test for this error as follows. You will need to adapt the Pytest fixture to your needs.
import pytest
from cognite.client import CogniteClient
from cognite.client.exceptions import CogniteAuthError
from cognite.client.testing import monkeypatch_cognite_client
@pytest.fixture
def cognite_client():
with monkeypatch_cognite_client() as client:
client.assets.list.side_effect = CogniteAuthError
yield client
def test_auth_error(cognite_client: CogniteClient):
with pytest.raises(CogniteAuthError):
cognite_client.assets.list()
Please let us know if you need more info.
Pierre
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.