Adapt uncloud_pay tests to support billing addresses

This commit is contained in:
fnux 2020-04-18 09:26:34 +02:00
parent e6eba7542b
commit 9bbe3b3b56

View file

@ -10,6 +10,11 @@ class BillingTestCase(TestCase):
self.user = get_user_model().objects.create( self.user = get_user_model().objects.create(
username='jdoe', username='jdoe',
email='john.doe@domain.tld') 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): def test_basic_monthly_billing(self):
one_time_price = 10 one_time_price = 10
@ -25,7 +30,8 @@ class BillingTestCase(TestCase):
owner=self.user, owner=self.user,
starting_date=starting_date, starting_date=starting_date,
ending_date=ending_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) order.add_record(one_time_price, recurring_price, description)
# Generate & check bill for first month: full recurring_price + setup. # Generate & check bill for first month: full recurring_price + setup.
@ -59,7 +65,8 @@ class BillingTestCase(TestCase):
order = Order.objects.create( order = Order.objects.create(
owner=self.user, owner=self.user,
starting_date=starting_date, 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) order.add_record(one_time_price, recurring_price, description)
# Generate & check bill for first year: recurring_price + setup. # Generate & check bill for first year: recurring_price + setup.
@ -100,7 +107,8 @@ class BillingTestCase(TestCase):
owner=self.user, owner=self.user,
starting_date=starting_date, starting_date=starting_date,
ending_date=ending_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) order.add_record(one_time_price, recurring_price, description)
# Generate & check bill for first month: recurring_price + setup. # Generate & check bill for first month: recurring_price + setup.
@ -121,13 +129,20 @@ class ProductActivationTestCase(TestCase):
username='jdoe', username='jdoe',
email='john.doe@domain.tld') 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): def test_product_activation(self):
starting_date = datetime.fromisoformat('2020-03-01') starting_date = datetime.fromisoformat('2020-03-01')
order = Order.objects.create( order = Order.objects.create(
owner=self.user, owner=self.user,
starting_date=starting_date, starting_date=starting_date,
recurring_period=RecurringPeriod.PER_MONTH) recurring_period=RecurringPeriod.PER_MONTH,
billing_address=self.billing_address)
order.save() order.save()
product = GenericServiceProduct( product = GenericServiceProduct(