def test_gen_for_non_consolidated_billing_without_consumed_units(self):
        billing_date = '2015-03-01'

        customer = CustomerFactory.create(consolidated_billing=False)
        metered_feature = MeteredFeatureFactory(included_units=Decimal('0.00'))
        plan = PlanFactory.create(interval='month', interval_count=1,
                                  generate_after=120, enabled=True,
                                  amount=Decimal('200.00'),
                                  metered_features=[metered_feature])
        start_date = dt.date(2015, 1, 3)

        # Create 3 subscriptions for the same customer
        SubscriptionFactory.create_batch(
            size=3, plan=plan, start_date=start_date, customer=customer)

        for subscription in Subscription.objects.all():
            subscription.activate()
            subscription.save()

        mocked_on_trial = MagicMock(return_value=False)
        mocked_last_billing_date = PropertyMock(
            return_value=dt.date(2015, 2, 1))
        mocked_is_billed_first_time = PropertyMock(return_value=False)
        with patch.multiple('silver.models.Subscription',
                            on_trial=mocked_on_trial,
                            last_billing_date=mocked_last_billing_date,
                            is_billed_first_time=mocked_is_billed_first_time):
            call_command('generate_docs', billing_date=billing_date,
                         stdout=self.output)

            assert Proforma.objects.all().count() == 3
            assert Invoice.objects.all().count() == 0

            for proforma in Proforma.objects.all():
                entries = proforma.proforma_entries.all()
                assert entries.count() == 2
                assert entries[1].quantity == 1
                assert entries[1].unit_price == plan.amount
Generate a URL at which the user will login and be redirected back.
dataset/ETHPy150Open PressLabs/silver/silver/tests/commands/test_generate_docs.py/TestInvoiceGenerationCommand.test_gen_for_non_consolidated_billing_without_consumed_units--crossover with--dataset/ETHPy150Open acil-bwh/SlicerCIP/Scripted/attic/PicasaSnap/gdata/auth.py/GenerateAuthSubUrl