Files
pyGoEdge-UserPanel/core/tests.py
2025-11-18 03:36:49 +08:00

27 lines
777 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from django.test import TestCase
# Create your tests here.
from django.test import TestCase
from django.utils import timezone
from core.utils import bytes_to_gb
from core.goedge_client import GoEdgeClient
class UtilsTests(TestCase):
def test_bytes_to_gb(self):
self.assertEqual(bytes_to_gb(0), 0)
self.assertEqual(bytes_to_gb(1024 ** 3), 1)
self.assertEqual(bytes_to_gb(5 * (1024 ** 3)), 5)
class GoEdgeClientTests(TestCase):
def test_validate_base_url_invalid(self):
client = None
try:
client = GoEdgeClient()
except RuntimeError:
client = None
# 若环境未配置 base_urlGoEdgeClient 构造将抛错,此处仅断言不会引发测试崩溃
self.assertIsNone(client)