actual thing name is replaced by pseudo names

This commit is contained in:
ahmadbilalkhalid 2020-03-02 19:20:12 +05:00
parent 750d8c8cbf
commit 531bfa1768

View file

@ -1,5 +1,7 @@
import datetime
import parsedatetime
from django.test import TestCase
from django.contrib.auth import get_user_model
from django.utils import timezone
@ -9,6 +11,7 @@ from uncloud_vm.models import VMDiskImageProduct, VMDiskProduct, VMProduct, VMHo
from uncloud_pay.models import Order
User = get_user_model()
cal = parsedatetime.Calendar()
# If you want to check the test database using some GUI/cli tool
@ -41,13 +44,14 @@ class VMTestCase(TestCase):
super().setUp()
def create_sample_vm(self, owner):
one_month_later, parse_status = cal.parse("1 month later")
return VMProduct.objects.create(
vmhost=self.vm_host, cores=2, ram_in_gb=4, owner=owner,
order=Order.objects.create(
owner=owner,
creation_date=datetime.datetime.now(tz=timezone.utc),
starting_date=datetime.datetime.now(tz=timezone.utc),
ending_date=datetime.datetime(2020, 4, 2, tzinfo=timezone.utc),
ending_date=datetime.datetime(*one_month_later[:6], tzinfo=timezone.utc),
recurring_price=4.0, one_time_price=5.0, recurring_period='per_month'
)
)
@ -59,7 +63,7 @@ class VMTestCase(TestCase):
vm = self.create_sample_vm(owner=self.user)
pending_disk_image = VMDiskImageProduct.objects.create(
owner=self.user, name='alpine3.11', is_os_image=True, is_public=True, size_in_gb=10,
owner=self.user, name='pending_disk_image', is_os_image=True, is_public=True, size_in_gb=10,
status='pending'
)
try:
@ -78,7 +82,7 @@ class VMTestCase(TestCase):
"""Ensure that a user can only create a VMDiskProduct for an existing VM"""
disk_image = VMDiskImageProduct.objects.create(
owner=self.user, name='alpine3.11', is_os_image=True, is_public=True, size_in_gb=10,
owner=self.user, name='disk_image', is_os_image=True, is_public=True, size_in_gb=10,
status='active'
)
@ -102,7 +106,7 @@ class VMTestCase(TestCase):
owner=self.user, vm=someone_else_vm,
size_in_gb=10,
image=VMDiskImageProduct.objects.create(
owner=self.user, name='alpine3.11', is_os_image=True, is_public=True, size_in_gb=10,
owner=self.user, name='disk_image', is_os_image=True, is_public=True, size_in_gb=10,
status='active'
)
)