gva/gnuviechadmin/hostingpackages/tests/test_models.py

29 lines
843 B
Python
Raw Normal View History

"""
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 ** 3)
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))