Beispiel #1
0
 def test_subscription_extend(self):
     self.truncate_table("regions")
     self.truncate_table("items")
     self.truncate_table("item_types")
     self.truncate_table("payment_types")
     self.truncate_table("products")
     self.truncate_table("subscriptions")
     region_ref = db.region_create(self.context, {'name': 'a_region'})
     item_ref = db.item_create(self.context, {'name': 'an_item'})
     item_type_ref = db.item_type_create(self.context,
                                         {'name': 'an_item_type'})
     payment_type_ref = db.payment_type_create(
         self.context, {
             'name': 'a_payment_type',
             'interval_unit': 'days',
             'interval_size': 12345,
             'is_prepaid': False
         })
     values = {
         'region_id': region_ref.id,
         'item_id': item_ref.id,
         'item_type_id': item_type_ref.id,
         'payment_type_id': payment_type_ref.id,
         'order_unit': 'some_measure',
         'order_size': 1,
         'price': 11.24,
         'currency': 'CNY',
     }
     product_ref = db.product_create(self.context, values)
     values = {
         'project_id': self.context.project_id,
         'product_id': product_ref.id,
         'resource_uuid': self.resource_uuid,
         'resource_name': self.resource_name,
     }
     expect = db.subscription_create(self.context, values)
     datetime_to = datetime.datetime.now() + datetime.timedelta(days=1)
     db.subscription_extend(self.context, expect.id, datetime_to)
     actual = db.subscription_get(self.context, expect.id)
     self.assertEqual(datetime_to.day, actual['expires_at'].day)
Beispiel #2
0
 def test_subscription_error(self):
     self.truncate_table("regions")
     self.truncate_table("items")
     self.truncate_table("item_types")
     self.truncate_table("payment_types")
     self.truncate_table("products")
     self.truncate_table("subscriptions")
     region_ref = db.region_create(self.context, {'name': 'a_region'})
     item_ref = db.item_create(self.context, {'name': 'an_item'})
     item_type_ref = db.item_type_create(self.context,
                                         {'name': 'an_item_type'})
     payment_type_ref = db.payment_type_create(
         self.context, {
             'name': 'a_payment_type',
             'interval_unit': 'days',
             'interval_size': 12345,
             'is_prepaid': False
         })
     values = {
         'region_id': region_ref.id,
         'item_id': item_ref.id,
         'item_type_id': item_type_ref.id,
         'payment_type_id': payment_type_ref.id,
         'order_unit': 'some_measure',
         'order_size': 1,
         'price': 11.24,
         'currency': 'CNY',
     }
     product_ref = db.product_create(self.context, values)
     values = {
         'project_id': self.context.project_id,
         'product_id': product_ref.id,
         'resource_uuid': self.resource_uuid,
         'resource_name': self.resource_name,
     }
     expect = db.subscription_create(self.context, values)
     db.subscription_error(self.context, expect.id)
     actual = db.subscription_get(self.context, expect.id)
     expect.status = "error"
     self.compare_records(expect, actual)
Beispiel #3
0
 def test_subscription_extend(self):
     self.truncate_table("regions")
     self.truncate_table("items")
     self.truncate_table("item_types")
     self.truncate_table("payment_types")
     self.truncate_table("products")
     self.truncate_table("subscriptions")
     region_ref = db.region_create(self.context, {'name': 'a_region'})
     item_ref = db.item_create(self.context, {'name': 'an_item'})
     item_type_ref = db.item_type_create(self.context,
                                         {'name': 'an_item_type'})
     payment_type_ref = db.payment_type_create(self.context,
                                               {'name': 'a_payment_type',
                                                'interval_unit': 'days',
                                                'interval_size': 12345,
                                                'is_prepaid': False})
     values = {
         'region_id': region_ref.id,
         'item_id': item_ref.id,
         'item_type_id': item_type_ref.id,
         'payment_type_id': payment_type_ref.id,
         'order_unit': 'some_measure',
         'order_size': 1,
         'price': 11.24,
         'currency': 'CNY',
         }
     product_ref = db.product_create(self.context, values)
     values = {
         'project_id': self.context.project_id,
         'product_id': product_ref.id,
         'resource_uuid': self.resource_uuid,
         'resource_name': self.resource_name,
         }
     expect = db.subscription_create(self.context, values)
     datetime_to = datetime.datetime.now() + datetime.timedelta(days=1)
     db.subscription_extend(self.context, expect.id, datetime_to)
     actual = db.subscription_get(self.context, expect.id)
     self.assertEqual(datetime_to.day, actual['expires_at'].day)
Beispiel #4
0
 def test_subscription_error(self):
     self.truncate_table("regions")
     self.truncate_table("items")
     self.truncate_table("item_types")
     self.truncate_table("payment_types")
     self.truncate_table("products")
     self.truncate_table("subscriptions")
     region_ref = db.region_create(self.context, {'name': 'a_region'})
     item_ref = db.item_create(self.context, {'name': 'an_item'})
     item_type_ref = db.item_type_create(self.context,
                                         {'name': 'an_item_type'})
     payment_type_ref = db.payment_type_create(self.context,
                                               {'name': 'a_payment_type',
                                                'interval_unit': 'days',
                                                'interval_size': 12345,
                                                'is_prepaid': False})
     values = {
         'region_id': region_ref.id,
         'item_id': item_ref.id,
         'item_type_id': item_type_ref.id,
         'payment_type_id': payment_type_ref.id,
         'order_unit': 'some_measure',
         'order_size': 1,
         'price': 11.24,
         'currency': 'CNY',
         }
     product_ref = db.product_create(self.context, values)
     values = {
         'project_id': self.context.project_id,
         'product_id': product_ref.id,
         'resource_uuid': self.resource_uuid,
         'resource_name': self.resource_name,
         }
     expect = db.subscription_create(self.context, values)
     db.subscription_error(self.context, expect.id)
     actual = db.subscription_get(self.context, expect.id)
     expect.status = "error"
     self.compare_records(expect, actual)