31 lines
861 B
Python
31 lines
861 B
Python
"""
|
|
Test for models.
|
|
|
|
"""
|
|
|
|
from django.test import TestCase
|
|
|
|
from hostingpackages.models import (
|
|
DISK_SPACE_UNITS,
|
|
CustomerHostingPackage,
|
|
)
|
|
|
|
|
|
class CustomerHostingPackageTest(TestCase):
|
|
def test_get_disk_space_bytes(self):
|
|
package = CustomerHostingPackage(
|
|
diskspace=10, diskspace_unit=DISK_SPACE_UNITS.G
|
|
)
|
|
self.assertEqual(package.get_disk_space(), 10 * 1024 * 1024**2)
|
|
|
|
def test_get_disk_space_mib(self):
|
|
package = CustomerHostingPackage(
|
|
diskspace=10, diskspace_unit=DISK_SPACE_UNITS.G
|
|
)
|
|
self.assertEqual(package.get_disk_space(DISK_SPACE_UNITS.M), 10 * 1024)
|
|
|
|
def test_get_quota(self):
|
|
package = CustomerHostingPackage(
|
|
diskspace=256, diskspace_unit=DISK_SPACE_UNITS.M
|
|
)
|
|
self.assertEqual(package.get_quota(), (262144, 275251))
|