-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(output): add test for OutputModel
- Loading branch information
1 parent
0bf58f9
commit e9a0504
Showing
1 changed file
with
39 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
r""" | ||
@DATE: 9/6/24 3:37 PM | ||
@File: test_cli_task.py | ||
@IDE: pycharm | ||
@Description: | ||
测试 swanlab task 相关函数 | ||
""" | ||
import pytest | ||
|
||
import tutils | ||
from swanlab.cli.commands.task.utils import OutputModel | ||
|
||
|
||
@pytest.mark.skipif(tutils.is_skip_cloud_test, reason="skip cloud test") | ||
def test_output_model_none(): | ||
om = OutputModel("123456", {}) | ||
assert om.cuid == "123456" | ||
assert om.path is None | ||
assert om.size is None | ||
assert om.output_url is None | ||
|
||
|
||
@pytest.mark.skipif(tutils.is_skip_cloud_test, reason="skip cloud test") | ||
def test_output_model_ok(): | ||
om = OutputModel("123456", {"path": "nothing.zip", "size": 123}) | ||
assert om.cuid == "123456" | ||
assert om.path == "nothing.zip" | ||
assert om.size == OutputModel.fmt_size(123) | ||
|
||
|
||
@pytest.mark.skipif(tutils.is_skip_cloud_test, reason="skip cloud test") | ||
def test_output_model_fmt_size(): | ||
assert OutputModel.fmt_size(1) == "1.00 Byte" | ||
assert OutputModel.fmt_size(1024) == "1.00 KB" | ||
assert OutputModel.fmt_size(1024 * 1024) == "1.00 MB" | ||
assert OutputModel.fmt_size(1024 * 1024 * 1024) == "1.00 GB" | ||
assert OutputModel.fmt_size(1024 * 1024 * 1024 * 1024) == "1.00 TB" |