Skip to content

Commit

Permalink
test(output): add test for OutputModel
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaikaikaifang committed Sep 6, 2024
1 parent 0bf58f9 commit e9a0504
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/unit/cli/test_cli_task.py
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"

0 comments on commit e9a0504

Please sign in to comment.