-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move test * fix cos delay * move test * Update http.py * update version
- Loading branch information
1 parent
8409951
commit e157f3d
Showing
7 changed files
with
164 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "swanlab", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "", | ||
"python": "true", | ||
"host": { | ||
|
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
r""" | ||
@DATE: 2024/5/31 12:47 | ||
@File: pytest_cos.py | ||
@IDE: pycharm | ||
@Description: | ||
测试http的api | ||
开发环境下存储凭证过期时间为3s | ||
""" | ||
import os | ||
import time | ||
import nanoid | ||
from swanlab.api.http import create_http, HTTP, CosClient | ||
from swanlab.api.auth.login import login_by_key | ||
from tutils import KEY, TEMP_PATH | ||
|
||
alphabet = "abcdefghijklmnopqrstuvwxyz" | ||
|
||
|
||
class TestCosSuite: | ||
http: HTTP = None | ||
project_name = nanoid.generate(alphabet) | ||
experiment_name = nanoid.generate(alphabet) | ||
file_path = os.path.join(TEMP_PATH, nanoid.generate(alphabet)) | ||
now_refresh_time = 1 | ||
pre_refresh_time = CosClient.REFRESH_TIME | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
CosClient.REFRESH_TIME = cls.now_refresh_time | ||
# 这里不测试保存token的功能 | ||
login_info = login_by_key(KEY, save=False) | ||
cls.http = create_http(login_info) | ||
cls.http.mount_project(cls.project_name) | ||
cls.http.mount_exp(cls.experiment_name, ('#ffffff', '#ffffff')) | ||
# temp路径写一个文件上传 | ||
with open(cls.file_path, "w") as f: | ||
f.write("test") | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
CosClient.REFRESH_TIME = cls.pre_refresh_time | ||
|
||
def test_cos_ok(self): | ||
assert self.http is not None | ||
assert self.http.cos is not None | ||
|
||
def test_cos_upload(self): | ||
self.http.upload("/key", self.file_path) | ||
# 开发版本设置的过期时间为3s,等待过期 | ||
time.sleep(3) | ||
# 重新上传,测试刷新 | ||
assert self.http.cos.should_refresh is True | ||
self.http.upload("/key", self.file_path) |
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 was deleted.
Oops, something went wrong.