<commit_before>from decimal import Decimal
from django.core import mail

from corehq.apps.accounting.tests.test_invoicing import BaseInvoiceTestCase
from corehq.apps.accounting import utils, tasks
from corehq.apps.accounting.invoicing import DomainWireInvoiceFactory
from corehq.apps.accounting.models import Invoice


class TestWireInvoice(BaseInvoiceTestCase):

    def setUp(self):
        super(TestWireInvoice, self).setUp()
        invoice_date = utils.months_from_date(self.subscription.date_start, 2)
        tasks.generate_invoices(invoice_date)

        invoice_date = utils.months_from_date(self.subscription.date_start, 3)
        tasks.generate_invoices(invoice_date)

        self.invoices = Invoice.objects.all()
        self.domain_name = self.invoices[0].get_domain()

    def tearDown(self):
        super(TestWireInvoice, self).tearDown()

    def test_factory(self):
        factory = DomainWireInvoiceFactory(self.domain_name)
        balance = Decimal(100)

        mail.outbox = []
        wi = factory.create_wire_invoice(balance)

        self.assertEqual(wi.balance, balance)
        self.assertEqual(wi.domain, self.domain.name)
        self.assertEqual(len(mail.outbox), 1)<commit_msg>update test<commit_after>from decimal import Decimal
from django.core import mail

from corehq.apps.accounting.tests.test_invoicing import BaseInvoiceTestCase
from corehq.apps.accounting import utils, tasks
from corehq.apps.accounting.invoicing import DomainWireInvoiceFactory
from corehq.apps.accounting.models import Invoice


class TestWireInvoice(BaseInvoiceTestCase):

    def setUp(self):
        super(TestWireInvoice, self).setUp()
        invoice_date = utils.months_from_date(self.subscription.date_start, 2)
        tasks.generate_invoices(invoice_date)

        invoice_date = utils.months_from_date(self.subscription.date_start, 3)
        tasks.generate_invoices(invoice_date)

        self.invoices = Invoice.objects.all()
        self.domain_name = self.invoices[0].get_domain()

    def tearDown(self):
        super(TestWireInvoice, self).tearDown()

    def test_factory(self):
        factory = DomainWireInvoiceFactory(
            self.domain_name,
            contact_emails=[self.dimagi_user.username],
        )
        balance = Decimal(100)

        mail.outbox = []
        wi = factory.create_wire_invoice(balance)

        self.assertEqual(wi.balance, balance)
        self.assertEqual(wi.domain, self.domain.name)
        self.assertEqual(len(mail.outbox), 1)
{'fraction_non_alphanumeric': 0.0898921294446664, 'fraction_numerical': 0.005593288054334798, 'mean_word_length': 3.6114180478821365, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '819300', 'n_tokens_mistral': 801, 'n_tokens_neox': 759, 'n_words': 126}