From 9bbe3b3b5672f775da978e1e339301010f485e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Sat, 18 Apr 2020 09:26:34 +0200 Subject: [PATCH] Adapt uncloud_pay tests to support billing addresses --- .../uncloud/uncloud_pay/tests.py | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/uncloud_django_based/uncloud/uncloud_pay/tests.py b/uncloud_django_based/uncloud/uncloud_pay/tests.py index 9e8728d..5236c8a 100644 --- a/uncloud_django_based/uncloud/uncloud_pay/tests.py +++ b/uncloud_django_based/uncloud/uncloud_pay/tests.py @@ -10,6 +10,11 @@ class BillingTestCase(TestCase): self.user = get_user_model().objects.create( username='jdoe', email='john.doe@domain.tld') + self.billing_address = BillingAddress.objects.create( + owner=self.user, + street="unknown", + city="unknown", + postal_code="unknown") def test_basic_monthly_billing(self): one_time_price = 10 @@ -25,7 +30,8 @@ class BillingTestCase(TestCase): owner=self.user, starting_date=starting_date, ending_date=ending_date, - recurring_period=RecurringPeriod.PER_MONTH) + recurring_period=RecurringPeriod.PER_MONTH, + billing_address=self.billing_address) order.add_record(one_time_price, recurring_price, description) # Generate & check bill for first month: full recurring_price + setup. @@ -59,7 +65,8 @@ class BillingTestCase(TestCase): order = Order.objects.create( owner=self.user, starting_date=starting_date, - recurring_period=RecurringPeriod.PER_YEAR) + recurring_period=RecurringPeriod.PER_YEAR, + billing_address=self.billing_address) order.add_record(one_time_price, recurring_price, description) # Generate & check bill for first year: recurring_price + setup. @@ -100,7 +107,8 @@ class BillingTestCase(TestCase): owner=self.user, starting_date=starting_date, ending_date=ending_date, - recurring_period=RecurringPeriod.PER_HOUR) + recurring_period=RecurringPeriod.PER_HOUR, + billing_address=self.billing_address) order.add_record(one_time_price, recurring_price, description) # Generate & check bill for first month: recurring_price + setup. @@ -121,13 +129,20 @@ class ProductActivationTestCase(TestCase): username='jdoe', email='john.doe@domain.tld') + self.billing_address = BillingAddress.objects.create( + owner=self.user, + street="unknown", + city="unknown", + postal_code="unknown") + def test_product_activation(self): starting_date = datetime.fromisoformat('2020-03-01') order = Order.objects.create( owner=self.user, starting_date=starting_date, - recurring_period=RecurringPeriod.PER_MONTH) + recurring_period=RecurringPeriod.PER_MONTH, + billing_address=self.billing_address) order.save() product = GenericServiceProduct(