forked from uncloud/uncloud
[pay] make sample products more modular
This commit is contained in:
parent
4d5ca58b2a
commit
7b83efe995
2 changed files with 43 additions and 4 deletions
|
@ -794,24 +794,31 @@ class SampleOneTimeProduct(Product):
|
||||||
|
|
||||||
default_recurring_period = RecurringPeriod.ONE_TIME
|
default_recurring_period = RecurringPeriod.ONE_TIME
|
||||||
|
|
||||||
|
ot_price = models.IntegerField(default=5)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def one_time_price(self):
|
def one_time_price(self):
|
||||||
return 5
|
return self.ot_price
|
||||||
|
|
||||||
class SampleRecurringProduct(Product):
|
class SampleRecurringProduct(Product):
|
||||||
default_recurring_period = RecurringPeriod.PER_30D
|
default_recurring_period = RecurringPeriod.PER_30D
|
||||||
|
|
||||||
|
rc_price = models.IntegerField(default=10)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def recurring_price(self):
|
def recurring_price(self):
|
||||||
return 10
|
return self.rc_price
|
||||||
|
|
||||||
class SampleRecurringProductOneTimeFee(Product):
|
class SampleRecurringProductOneTimeFee(Product):
|
||||||
default_recurring_period = RecurringPeriod.PER_30D
|
default_recurring_period = RecurringPeriod.PER_30D
|
||||||
|
|
||||||
|
ot_price = models.IntegerField(default=5)
|
||||||
|
rc_price = models.IntegerField(default=10)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def one_time_price(self):
|
def one_time_price(self):
|
||||||
return 5
|
return self.ot_price
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def recurring_price(self):
|
def recurring_price(self):
|
||||||
return 1
|
return self.rc_price
|
||||||
|
|
|
@ -327,6 +327,38 @@ class BillTestCase(TestCase):
|
||||||
|
|
||||||
self.assertEqual(len(bills), 2)
|
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 NotABillingTC(TestCase):
|
||||||
# #class BillingTestCase(TestCase):
|
# #class BillingTestCase(TestCase):
|
||||||
# def setUp(self):
|
# def setUp(self):
|
||||||
|
|
Loading…
Reference in a new issue