add sample products and improve testing for Product

This commit is contained in:
Nico Schottelius 2020-08-09 11:02:45 +02:00
commit 0dd1093812
4 changed files with 156 additions and 17 deletions

View file

@ -5,6 +5,7 @@ from datetime import datetime, date, timedelta
from .models import *
from uncloud_service.models import GenericServiceProduct
class ProductOrderTestCase(TestCase):
"""
Test products and products <-> order interaction
@ -15,12 +16,53 @@ class ProductOrderTestCase(TestCase):
username='random_user',
email='jane.random@domain.tld')
def test_update_one_time_product(self):
ba = BillingAddress.objects.create(
owner=self.user,
organization = 'Test org',
street="unknown",
city="unknown",
postal_code="somewhere else",
active=True)
def test_create_one_time_product(self):
"""
One time payment products cannot be updated - can they?
"""
pass
p = SampleOneTimeProduct.objects.create(owner=self.user)
self.assertEqual(p.one_time_price, 5)
self.assertEqual(p.recurring_price, 0)
def test_create_order_creates_correct_order_count(self):
"""
Ensure creating orders from product only creates 1 order
"""
# One order
p = SampleOneTimeProduct(owner=self.user)
p.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
p.save()
order_count = Order.objects.filter(owner=self.user).count()
self.assertEqual(order_count, 1)
# One more order
p = SampleRecurringProduct(owner=self.user)
p.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
p.save()
order_count = Order.objects.filter(owner=self.user).count()
self.assertEqual(order_count, 2)
# Should create 2 orders
p = SampleRecurringProductOneTimeFee(owner=self.user)
p.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
p.save()
order_count = Order.objects.filter(owner=self.user).count()
self.assertEqual(order_count, 4)
class BillingAddressTestCase(TestCase):