def test_patchy_coverage(self):
     some_plan = generator.subscribable_plan()
     middle_date = self.invoice_end - datetime.timedelta(days=15)
     Subscription.new_domain_subscription(self.account,
                                          self.domain.name,
                                          some_plan,
                                          date_start=self.invoice_start +
                                          datetime.timedelta(days=1),
                                          date_end=middle_date)
     next_start = middle_date + datetime.timedelta(days=2)
     next_end = next_start + datetime.timedelta(days=2)
     Subscription.new_domain_subscription(
         self.account,
         self.domain.name,
         some_plan,
         date_start=next_start,
         date_end=next_end,
     )
     final_start = next_end + datetime.timedelta(days=2)
     Subscription.new_domain_subscription(
         self.account,
         self.domain.name,
         some_plan,
         date_start=final_start,
         date_end=self.invoice_end - datetime.timedelta(days=1),
     )
     subscriptions = self.invoice_factory._get_subscriptions()
     self.assertEqual(len(subscriptions), 3)
     community_ranges = self.invoice_factory._get_community_ranges(
         subscriptions)
     self.assertEqual(len(community_ranges), 4)
     self._clean_subs()
    def test_clean(self):
        account = BillingAccount.objects.create(
            name='Test Account',
            created_by='*****@*****.**',
            currency=generator.init_default_currency(),
        )
        subscription = Subscription.objects.create(
            account=account,
            date_start=date.today(),
            plan_version=generator.subscribable_plan(),
            subscriber=Subscriber.objects.create(domain='test'))
        invoice = Invoice.objects.create(
            date_start=date.today(),
            date_end=date.today(),
            subscription=subscription,
        )
        line_item = LineItem.objects.create(invoice=invoice, )

        with self.assertRaises(ValidationError):
            try:
                CreditAdjustment(
                    invoice=invoice,
                    line_item=line_item,
                ).save()
            except ValidationError as e:
                self.assertIn('__all__', e.error_dict)
                raise e
 def test_patchy_coverage(self):
     some_plan = generator.subscribable_plan()
     middle_date = self.invoice_end - datetime.timedelta(days=15)
     Subscription.new_domain_subscription(
         self.account, self.domain.name, some_plan,
         date_start=self.invoice_start + datetime.timedelta(days=1),
         date_end=middle_date
     )
     next_start = middle_date + datetime.timedelta(days=2)
     next_end = next_start + datetime.timedelta(days=2)
     Subscription.new_domain_subscription(
         self.account, self.domain.name, some_plan,
         date_start=next_start,
         date_end=next_end,
     )
     final_start = next_end + datetime.timedelta(days=2)
     Subscription.new_domain_subscription(
         self.account, self.domain.name, some_plan,
         date_start=final_start,
         date_end=self.invoice_end - datetime.timedelta(days=1),
     )
     subscriptions = self.invoice_factory._get_subscriptions()
     self.assertEqual(len(subscriptions), 3)
     community_ranges = self.invoice_factory._get_community_ranges(subscriptions)
     self.assertEqual(len(community_ranges), 4)
     self._clean_subs()
Exemple #4
0
    def test_clean(self):
        account = BillingAccount.objects.create(
            name='Test Account',
            created_by='*****@*****.**',
            currency=generator.init_default_currency(),
        )
        subscription = Subscription.objects.create(
            account=account,
            date_start=date.today(),
            plan_version=generator.subscribable_plan(),
            subscriber=Subscriber.objects.create(domain='test')
        )
        invoice = Invoice.objects.create(
            date_start=date.today(),
            date_end=date.today(),
            subscription=subscription,
        )
        line_item = LineItem.objects.create(
            invoice=invoice,
        )

        with self.assertRaises(ValidationError):
            try:
                CreditAdjustment(
                    invoice=invoice,
                    line_item=line_item,
                ).save()
            except ValidationError as e:
                self.assertIn('__all__', e.error_dict)
                raise e
 def test_full_coverage(self):
     some_plan = generator.subscribable_plan()
     Subscription.new_domain_subscription(
         self.account, self.domain.name, some_plan,
         date_start=self.invoice_start,
         date_end=self.invoice_end + datetime.timedelta(days=1),
     )
     subscriptions = self.invoice_factory._get_subscriptions()
     community_ranges = self.invoice_factory._get_community_ranges(subscriptions)
     self.assertEqual(len(community_ranges), 0)
     self._clean_subs()
 def test_incomplete_starting_coverage(self):
     some_plan = generator.subscribable_plan()
     subscription = Subscription.new_domain_subscription(
         self.account, self.domain.name, some_plan,
         date_start=self.invoice_start + datetime.timedelta(days=3)
     )
     subscriptions = self.invoice_factory._get_subscriptions()
     community_ranges = self.invoice_factory._get_community_ranges(subscriptions)
     self.assertEqual(len(community_ranges), 1)
     self.assertEqual(community_ranges[0][0], self.invoice_start)
     self.assertEqual(community_ranges[0][1], subscription.date_start)
     self._clean_subs()
 def test_incomplete_starting_coverage(self):
     some_plan = generator.subscribable_plan()
     subscription = Subscription.new_domain_subscription(
         self.account,
         self.domain.name,
         some_plan,
         date_start=self.invoice_start + datetime.timedelta(days=3))
     subscriptions = self.invoice_factory._get_subscriptions()
     community_ranges = self.invoice_factory._get_community_ranges(
         subscriptions)
     self.assertEqual(len(community_ranges), 1)
     self.assertEqual(community_ranges[0][0], self.invoice_start)
     self.assertEqual(community_ranges[0][1], subscription.date_start)
     self._clean_subs()
 def test_full_coverage(self):
     some_plan = generator.subscribable_plan()
     Subscription.new_domain_subscription(
         self.account,
         self.domain.name,
         some_plan,
         date_start=self.invoice_start,
         date_end=self.invoice_end + datetime.timedelta(days=1),
     )
     subscriptions = self.invoice_factory._get_subscriptions()
     community_ranges = self.invoice_factory._get_community_ranges(
         subscriptions)
     self.assertEqual(len(community_ranges), 0)
     self._clean_subs()