Test the authentication flow using the AgentOps client.
(mock_api_key)
| 16 | |
| 17 | @pytest.mark.vcr() |
| 18 | def test_auth_flow(mock_api_key): |
| 19 | """Test the authentication flow using the AgentOps client.""" |
| 20 | with patch("agentops.client.client.ApiClient") as mock_api_client: |
| 21 | # Create mock API instance |
| 22 | mock_api = MagicMock() |
| 23 | mock_api.v3.fetch_auth_token.return_value = {"token": "mock_token", "project_id": "mock_project_id"} |
| 24 | mock_api_client.return_value = mock_api |
| 25 | |
| 26 | # Initialize the client |
| 27 | client = Client() |
| 28 | session = client.init(api_key=mock_api_key) |
| 29 | |
| 30 | # Verify client is initialized |
| 31 | assert client.initialized |
| 32 | assert client.api is not None |
| 33 | |
| 34 | # Verify session is created if auto_start_session is True |
| 35 | if client.config.auto_start_session: |
| 36 | assert session is not None |
| 37 | |
| 38 | |
| 39 | @pytest.mark.vcr() |