|
@@ -92,6 +92,30 @@ class ServiceTests(TestCase):
|
|
|
})
|
|
|
|
|
|
|
|
|
+ def test_compare_service(self):
|
|
|
+ s_first = Service.objects.create(
|
|
|
+ name='Foo', document=self.doc, subscriptions_count=3)
|
|
|
+
|
|
|
+ # The first service has no cost/goods associated
|
|
|
+
|
|
|
+ s_second = Service.objects.create(
|
|
|
+ name='Bar', document=self.doc, subscriptions_count=2)
|
|
|
+
|
|
|
+ GoodUse.objects.create(
|
|
|
+ service=s_second, resource=self.server, share=0.4)
|
|
|
+
|
|
|
+ total_recurring_price = 10/(365*3)*365.25/12
|
|
|
+ self.assertEqual(s_second.compare(s_first), {
|
|
|
+ 'total_recurring_price': total_recurring_price,
|
|
|
+ 'total_goods_value_share': 10,
|
|
|
+ 'unit_recurring_price': total_recurring_price/2,
|
|
|
+ 'unit_goods_value_share': 5,
|
|
|
+ 'unit_staggered_goods_share': 5/36,
|
|
|
+ 'unit_consolidated_cost': total_recurring_price/2 + 5/36,
|
|
|
+ 'subscriptions_count': -1,
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
class AbstractUseTests(TestCase):
|
|
|
""" Testing AbstractUseTests through CostUse
|
|
|
"""
|