Test that creating products w/o correct billing address fails

This commit is contained in:
Nico Schottelius 2020-08-25 21:31:12 +02:00
commit ab412cb877
3 changed files with 89 additions and 13 deletions

View file

@ -16,7 +16,7 @@ class ProductTestCase(TestCase):
username='random_user',
email='jane.random@domain.tld')
ba = BillingAddress.objects.create(
self.ba = BillingAddress.objects.create(
owner=self.user,
organization = 'Test org',
street="unknown",
@ -34,6 +34,29 @@ class ProductTestCase(TestCase):
self.assertEqual(p.one_time_price, 5)
self.assertEqual(p.recurring_price, 0)
def test_create_product_without_active_billing_address(self):
"""
Fail to create a product without an active billing address
"""
self.ba.active = False
self.ba.save()
with self.assertRaises(ValidationError):
p = SampleOneTimeProduct.objects.create(owner=self.user)
def test_create_product_without_billing_address(self):
"""
Fail to create a product without a billing address
"""
user2 = get_user_model().objects.create(
username='random_user2',
email='jane.randomly@domain.tld')
with self.assertRaises(ValidationError):
p = SampleOneTimeProduct.objects.create(owner=user2)
def test_create_order_creates_correct_order_count(self):
"""
@ -329,6 +352,7 @@ class BillTestCase(TestCase):
class ModifyProductTestCase(TestCase):
def setUp(self):
self.user = get_user_model().objects.create(
username='random_user',
@ -340,23 +364,15 @@ class ModifyProductTestCase(TestCase):
street="unknown",
city="unknown",
postal_code="somewhere else",
active=False)
active=True)
def test_user_no_address(self):
"""
Raise an error, when there is no address
def test_modify_recurring_product(self):
"""
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
"""
product = SampleRecurringProduct.objects.create(owner=self.user)
# class NotABillingTC(TestCase):