[pay] make sample products more modular

This commit is contained in:
Nico Schottelius 2020-08-25 21:11:28 +02:00
parent 4d5ca58b2a
commit 7b83efe995
2 changed files with 43 additions and 4 deletions

View file

@ -794,24 +794,31 @@ class SampleOneTimeProduct(Product):
default_recurring_period = RecurringPeriod.ONE_TIME
ot_price = models.IntegerField(default=5)
@property
def one_time_price(self):
return 5
return self.ot_price
class SampleRecurringProduct(Product):
default_recurring_period = RecurringPeriod.PER_30D
rc_price = models.IntegerField(default=10)
@property
def recurring_price(self):
return 10
return self.rc_price
class SampleRecurringProductOneTimeFee(Product):
default_recurring_period = RecurringPeriod.PER_30D
ot_price = models.IntegerField(default=5)
rc_price = models.IntegerField(default=10)
@property
def one_time_price(self):
return 5
return self.ot_price
@property
def recurring_price(self):
return 1
return self.rc_price

View file

@ -327,6 +327,38 @@ class BillTestCase(TestCase):
self.assertEqual(len(bills), 2)
class ModifyProductTestCase(TestCase):
def setUp(self):
self.user = get_user_model().objects.create(
username='random_user',
email='jane.random@domain.tld')
self.ba = BillingAddress.objects.create(
owner=self.user,
organization = 'Test org',
street="unknown",
city="unknown",
postal_code="somewhere else",
active=False)
def test_user_no_address(self):
"""
Raise an error, when there is no address
"""
self.assertRaises(uncloud_pay.models.BillingAddress.DoesNotExist,
BillingAddress.get_address_for,
self.user)
def test_user_only_inactive_address(self):
"""
Raise an error, when there is no active address
"""
# class NotABillingTC(TestCase):
# #class BillingTestCase(TestCase):
# def setUp(self):