Added based view test, Added billing address form test, payment view test , Added test for hetzner pricing calculation, Added test for bern pricing calculation, Fixed script to load initial pricing data
This commit is contained in:
parent
36de71441a
commit
bf17e80df4
11 changed files with 360 additions and 19 deletions
75
hosting/test_models.py
Normal file
75
hosting/test_models.py
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
from django.test import TestCase
|
||||
|
||||
from model_mommy import mommy
|
||||
from django.core.management import call_command
|
||||
|
||||
|
||||
from .models import VirtualMachineType
|
||||
|
||||
|
||||
class VirtualMachineTypeModelTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.HETZNER_NUG_NAME = 'hetzner_nug'
|
||||
self.HETZNER_NAME = 'hetzner'
|
||||
self.HETZNER_RAID6_NAME = 'hetzner_raid6'
|
||||
self.HETZNER_GLUSTERFS_NAME = 'hetzner_glusterfs'
|
||||
self.BERN_NAME = 'bern'
|
||||
self.HETZNER_NUG_EXPECTED_PRICE = 79
|
||||
self.HETZNER_EXPECTED_PRICE = 180
|
||||
self.HETZNER_RAID6_EXPECTED_PRICE = 216
|
||||
self.HETZNER_GLUSTERFS_EXPECTED_PRICE = 252
|
||||
self.BERN_EXPECTED_PRICE = 202
|
||||
call_command('create_vm_types')
|
||||
|
||||
def test_calculate_price(self):
|
||||
|
||||
# hetzner_nug
|
||||
specifications = {
|
||||
'cores': 2,
|
||||
'memory': 10,
|
||||
'disk_size': 100
|
||||
}
|
||||
vm_type = VirtualMachineType.objects.get(hosting_company=self.HETZNER_NUG_NAME)
|
||||
calculated_price = vm_type.calculate_price(specifications)
|
||||
self.assertEqual(calculated_price, self.HETZNER_NUG_EXPECTED_PRICE)
|
||||
|
||||
# hetzner
|
||||
specifications = {
|
||||
'cores': 2,
|
||||
'memory': 10,
|
||||
'disk_size': 100
|
||||
}
|
||||
vm_type = VirtualMachineType.objects.get(hosting_company=self.HETZNER_NAME)
|
||||
calculated_price = vm_type.calculate_price(specifications)
|
||||
self.assertEqual(calculated_price, self.HETZNER_EXPECTED_PRICE)
|
||||
|
||||
# hetzner_raid6
|
||||
specifications = {
|
||||
'cores': 2,
|
||||
'memory': 10,
|
||||
'disk_size': 100
|
||||
}
|
||||
vm_type = VirtualMachineType.objects.get(hosting_company=self.HETZNER_RAID6_NAME)
|
||||
calculated_price = vm_type.calculate_price(specifications)
|
||||
self.assertEqual(calculated_price, self.HETZNER_RAID6_EXPECTED_PRICE)
|
||||
|
||||
# hetzner_glusterfs
|
||||
specifications = {
|
||||
'cores': 2,
|
||||
'memory': 10,
|
||||
'disk_size': 100
|
||||
}
|
||||
vm_type = VirtualMachineType.objects.get(hosting_company=self.HETZNER_GLUSTERFS_NAME)
|
||||
calculated_price = vm_type.calculate_price(specifications)
|
||||
self.assertEqual(calculated_price, self.HETZNER_GLUSTERFS_EXPECTED_PRICE)
|
||||
|
||||
# bern
|
||||
specifications = {
|
||||
'cores': 2,
|
||||
'memory': 10,
|
||||
'disk_size': 100
|
||||
}
|
||||
vm_type = VirtualMachineType.objects.get(hosting_company=self.BERN_NAME)
|
||||
calculated_price = vm_type.calculate_price(specifications)
|
||||
self.assertEqual(calculated_price, self.BERN_EXPECTED_PRICE)
|
||||
Loading…
Add table
Add a link
Reference in a new issue