Can order a generic product now

This commit is contained in:
Nico Schottelius 2020-09-28 21:59:35 +02:00
commit 8d8c4d660c
4 changed files with 135 additions and 46 deletions

View file

@ -8,33 +8,29 @@ from uncloud_service.models import GenericServiceProduct
import json
# class OrderTestCase(TestCase):
# """
# The heart of ordering products
# """
vm_sample_product_config = {
'features': {
'cores':
{ 'min': 1,
'max': 48,
'one_time_price': 0,
'recurring_price': 4
},
'ram_gb':
{ 'min': 1,
'max': 256,
'one_time_price': 0,
'recurring_price': 4
},
},
}
# 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=True)
# def test_create_one_time_product(self):
# """
# One time payment products cannot be updated - can they?
# """
# p = SampleOneTimeProduct.objects.create(owner=self.user)
# self.assertEqual(p.one_time_price, 5)
# self.assertEqual(p.recurring_price, 0)
vm_sample_order_config = {
'features': {
'cores': 2,
'ram_gb': 2
}
}
class ProductTestCase(TestCase):
@ -60,29 +56,45 @@ class ProductTestCase(TestCase):
Create a sample product
"""
config = {
'features': {
'cores':
{ 'min': 1,
'max': 48,
'one_time_price': 0,
'recurring_price': 4
},
'ram_gb':
{ 'min': 1,
'max': 256,
'one_time_price': 0,
'recurring_price': 3
},
},
}
p = Product.objects.create(name="Testproduct",
description="Only for testing",
config=vm_sample_product_config)
class OrderTestCase(TestCase):
"""
The heart of ordering products
"""
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=True)
def test_order_product(self):
"""
Order a product, ensure the order has correct price setup
"""
p = Product.objects.create(name="Testproduct",
description="Only for testing",
config=config)
config=vm_sample_product_config)
# self.assertEqual(p.one_time_price, 5)
# self.assertEqual(p.recurring_price, 0)
o = Order.objects.create(owner=self.user,
billing_address=self.ba,
product=p,
config=vm_sample_order_config)
self.assertEqual(o.one_time_price, 0)
self.assertEqual(o.recurring_price, 16)
# class ProductTestCase(TestCase):