Initial commit
This commit is contained in:
26
core/tests.py
Normal file
26
core/tests.py
Normal file
@@ -0,0 +1,26 @@
|
||||
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_url,GoEdgeClient 构造将抛错,此处仅断言不会引发测试崩溃
|
||||
self.assertIsNone(client)
|
||||
Reference in New Issue
Block a user