-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from FocoosAI/feat/add-user-info
feat: add user and quota models to enhance user info retrieval Introduce `User` and `Quotas` models to provide structured user information, including API key and usage quotas. This change improves the clarity and usability of user data, facilitating better resource management and integration.
- Loading branch information
Showing
6 changed files
with
108 additions
and
14 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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import pathlib | ||
import tempfile | ||
from datetime import datetime | ||
from unittest.mock import MagicMock | ||
|
||
import pytest | ||
|
@@ -16,7 +17,23 @@ | |
def focoos_instance(mock_http_client) -> Focoos: | ||
"""Fixture to provide a Focoos instance with a mocked HttpClient.""" | ||
mock_http_client.get.return_value.status_code = 200 | ||
mock_http_client.get.return_value.json.return_value = {"email": "[email protected]"} | ||
mock_http_client.get.return_value.json.return_value = { | ||
"email": "[email protected]", | ||
"created_at": "2024-01-01", | ||
"updated_at": "2025-01-01", | ||
"company": "test_company", | ||
"api_key": {"key": "test_api_key"}, | ||
"quotas": { | ||
"total_inferences": 10, | ||
"max_inferences": 1000, | ||
"used_storage_gb": 10, | ||
"max_storage_gb": 1000, | ||
"active_training_jobs": ["job1"], | ||
"max_active_training_jobs": 1, | ||
"used_mlg4dnxlarge_training_jobs_hours": 10, | ||
"max_mlg4dnxlarge_training_jobs_hours": 1000, | ||
}, | ||
} | ||
return Focoos(api_key="test_api_key", host_url="http://mock-host-url.com") | ||
|
||
|
||
|
@@ -98,7 +115,18 @@ def test_focoos_initialization_fail_to_fetch_user_info(focoos_instance: Focoos): | |
|
||
def test_focoos_initialization(focoos_instance: Focoos): | ||
assert focoos_instance.api_key == "test_api_key" | ||
assert focoos_instance.user_info["email"] == "[email protected]" | ||
assert focoos_instance.user_info.email == "[email protected]" | ||
assert focoos_instance.user_info.company == "test_company" | ||
assert focoos_instance.user_info.created_at == datetime(2024, 1, 1) | ||
assert focoos_instance.user_info.updated_at == datetime(2025, 1, 1) | ||
assert focoos_instance.user_info.quotas.total_inferences == 10 | ||
assert focoos_instance.user_info.quotas.max_inferences == 1000 | ||
assert focoos_instance.user_info.quotas.used_storage_gb == 10 | ||
assert focoos_instance.user_info.quotas.max_storage_gb == 1000 | ||
assert focoos_instance.user_info.quotas.active_training_jobs == ["job1"] | ||
assert focoos_instance.user_info.quotas.max_active_training_jobs == 1 | ||
assert focoos_instance.user_info.quotas.used_mlg4dnxlarge_training_jobs_hours == 10 | ||
assert focoos_instance.user_info.quotas.max_mlg4dnxlarge_training_jobs_hours == 1000 | ||
|
||
|
||
def test_get_model_info(focoos_instance: Focoos): | ||
|