Test Full cycle and fix some issues
This commit is contained in:
parent
1aeb757e22
commit
2e05ebbf67
19 changed files with 131 additions and 98 deletions
|
|
@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model
|
|||
from django.utils import timezone
|
||||
|
||||
from .models import VMInstance
|
||||
from uncloud_pay.models import Order, PricingPlan, BillingAddress, Product, RecurringPeriod
|
||||
from uncloud_pay.models import Order, PricingPlan, BillingAddress, Product, RecurringPeriod, Bill, BillRecord
|
||||
|
||||
|
||||
vm_product_config = {
|
||||
|
|
@ -54,6 +54,26 @@ class VMInstanceTestCase(TestCase):
|
|||
self.product.recurring_periods.add(self.default_recurring_period,
|
||||
through_defaults= { 'is_default': True })
|
||||
|
||||
def test_delete_matrix_vm_related_to_bill(self):
|
||||
order = Order.objects.create(owner=self.user,
|
||||
recurring_period=self.default_recurring_period,
|
||||
billing_address=self.ba,
|
||||
pricing_plan = self.pricing_plan,
|
||||
product=self.product,
|
||||
config=self.config)
|
||||
VMInstance.create_instance(order)
|
||||
instances = VMInstance.objects.filter(order=order)
|
||||
self.assertEqual(len(instances), 1)
|
||||
bill = Bill.create_next_bill_for_order(order, ending_date=order.next_cancel_or_downgrade_date(order.starting_date))
|
||||
bill_records = BillRecord.objects.filter(bill=bill)
|
||||
self.assertEqual(len(bill_records), 1)
|
||||
self.assertEqual(bill_records[0].order, order)
|
||||
|
||||
VMInstance.delete_for_bill(bill)
|
||||
instances = VMInstance.objects.filter(order=order)
|
||||
self.assertEqual(len(instances), 0)
|
||||
|
||||
|
||||
def test_create_matrix_vm(self):
|
||||
order = Order.objects.create(owner=self.user,
|
||||
recurring_period=self.default_recurring_period,
|
||||
|
|
@ -61,6 +81,7 @@ class VMInstanceTestCase(TestCase):
|
|||
pricing_plan = self.pricing_plan,
|
||||
product=self.product,
|
||||
config=self.config)
|
||||
VMInstance.create_instance(order)
|
||||
instances = VMInstance.objects.filter(order=order)
|
||||
self.assertEqual(len(instances), 1)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue