repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import pytest |
| #2 | |
| #3 | from embedchain import Client |
| #4 | |
| #5 | |
| #6 | class TestClient: |
| #7 | @pytest.fixture |
| #8 | def mock_requests_post(self, mocker): |
| #9 | return mocker.patch("embedchain.client.requests.post") |
| #10 | |
| #11 | def test_valid_api_key(self, mock_requests_post): |
| #12 | mock_requests_post.return_value.status_code = 200 |
| #13 | client = Client(api_key="valid_api_key") |
| #14 | assert client.check("valid_api_key") is True |
| #15 | |
| #16 | def test_invalid_api_key(self, mock_requests_post): |
| #17 | mock_requests_post.return_value.status_code = 401 |
| #18 | with pytest.raises(ValueError): |
| #19 | Client(api_key="invalid_api_key") |
| #20 | |
| #21 | def test_update_valid_api_key(self, mock_requests_post): |
| #22 | mock_requests_post.return_value.status_code = 200 |
| #23 | client = Client(api_key="valid_api_key") |
| #24 | client.update("new_valid_api_key") |
| #25 | assert client.get() == "new_valid_api_key" |
| #26 | |
| #27 | def test_clear_api_key(self, mock_requests_post): |
| #28 | mock_requests_post.return_value.status_code = 200 |
| #29 | client = Client(api_key="valid_api_key") |
| #30 | client.clear() |
| #31 | assert client.get() is None |
| #32 | |
| #33 | def test_save_api_key(self, mock_requests_post): |
| #34 | mock_requests_post.return_value.status_code = 200 |
| #35 | api_key_to_save = "valid_api_key" |
| #36 | client = Client(api_key=api_key_to_save) |
| #37 | client.save() |
| #38 | assert client.get() == api_key_to_save |
| #39 | |
| #40 | def test_load_api_key_from_config(self, mocker): |
| #41 | mocker.patch("embedchain.Client.load_config", return_value={"api_key": "test_api_key"}) |
| #42 | client = Client() |
| #43 | assert client.get() == "test_api_key" |
| #44 | |
| #45 | def test_load_invalid_api_key_from_config(self, mocker): |
| #46 | mocker.patch("embedchain.Client.load_config", return_value={}) |
| #47 | with pytest.raises(ValueError): |
| #48 | Client() |
| #49 | |
| #50 | def test_load_missing_api_key_from_config(self, mocker): |
| #51 | mocker.patch("embedchain.Client.load_config", return_value={}) |
| #52 | with pytest.raises(ValueError): |
| #53 | Client() |
| #54 |