Beispiel #1
0
 def test_version_check_disabled(self, rsps_with_login_mock):
     rsps_with_login_mock.assert_all_requests_are_fired = False
     with unset_env_var("COGNITE_PROJECT"):
         with set_env_var("COGNITE_DISABLE_PYPI_VERSION_CHECK", "1"):
             CogniteClient()
     assert len(rsps_with_login_mock.calls) == 1
     assert rsps_with_login_mock.calls[0].request.url.startswith("https://greenfield.cognitedata.com")
Beispiel #2
0
 def test_client_debug_mode(self, rsps_with_login_mock):
     with unset_env_var("COGNITE_PROJECT"):
         CogniteClient(debug=True)
     log = logging.getLogger("cognite-sdk")
     assert isinstance(log.handlers[0].formatter, DebugLogFormatter)
     log.handlers = []
     log.propagate = False
Beispiel #3
0
 def test_invalid_api_key(self, rsps):
     rsps.add(rsps.GET, _PYPI_ADDRESS, status=200, body="")
     rsps.add(
         rsps.GET,
         BASE_URL + "/login/status",
         status=200,
         json={"data": {"project": "", "loggedIn": False, "user": "", "projectId": -1}},
     )
     with unset_env_var("COGNITE_PROJECT"):
         with pytest.raises(CogniteAPIKeyError):
             CogniteClient()
Beispiel #4
0
 def test_no_client_name(self):
     with unset_env_var("COGNITE_CLIENT_NAME"):
         with pytest.raises(ValueError, match="No client name has been specified"):
             CogniteClient()
Beispiel #5
0
 def test_no_api_key_set(self):
     with unset_env_var("COGNITE_API_KEY"):
         with pytest.raises(CogniteAPIKeyError, match="No API key has been specified"):
             CogniteClient()
Beispiel #6
0
 def test_project_is_correct(self, rsps_with_login_mock):
     with unset_env_var("COGNITE_PROJECT"):
         c = CogniteClient()
     assert c.config.project == "test"
Beispiel #7
0
 def test_version_check_enabled(self, rsps_with_login_mock):
     with unset_env_var("COGNITE_PROJECT"):
         CogniteClient()
     assert len(rsps_with_login_mock.calls) == 2
Beispiel #8
0
 def test_default_config(self, rsps_with_login_mock, default_client_config):
     with unset_env_var("COGNITE_PROJECT"):
         client = CogniteClient()
     self.assert_config_is_correct(client.config, *default_client_config)