本文整理汇总了Python中silver.tests.factories.InvoiceFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python InvoiceFactory.create_batch方法的具体用法?Python InvoiceFactory.create_batch怎么用?Python InvoiceFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silver.tests.factories.InvoiceFactory
的用法示例。
在下文中一共展示了InvoiceFactory.create_batch方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_invoices
# 需要导入模块: from silver.tests.factories import InvoiceFactory [as 别名]
# 或者: from silver.tests.factories.InvoiceFactory import create_batch [as 别名]
def test_get_invoices(self):
batch_size = 50
InvoiceFactory.create_batch(batch_size)
url = reverse('invoice-list')
response = self.client.get(url)
assert response.status_code == status.HTTP_200_OK
response = self.client.get(url + '?page=2')
assert response.status_code == status.HTTP_200_OK
示例2: test_invoice_due_today_queryset
# 需要导入模块: from silver.tests.factories import InvoiceFactory [as 别名]
# 或者: from silver.tests.factories.InvoiceFactory import create_batch [as 别名]
def test_invoice_due_today_queryset(self):
invoices = InvoiceFactory.create_batch(5)
invoices[0].state = Invoice.STATES.DRAFT
invoices[0].due_date = date.today()
invoices[0].save()
invoices[1].state = Invoice.STATES.ISSUED
invoices[1].due_date = date.today()
invoices[1].save()
invoices[2].state = Invoice.STATES.PAID
invoices[2].due_date = date.today() - timedelta(days=1)
invoices[2].save()
invoices[3].state = Invoice.STATES.CANCELED
invoices[3].due_date = date.today()
invoices[3].save()
invoices[4].state = Invoice.STATES.ISSUED
invoices[4].due_date = date.today() + timedelta(days=1)
invoices[4].save()
queryset = Invoice.objects.due_today()
assert queryset.count() == 1
assert invoices[1] in queryset
示例3: test_add_single_invoice_entry
# 需要导入模块: from silver.tests.factories import InvoiceFactory [as 别名]
# 或者: from silver.tests.factories.InvoiceFactory import create_batch [as 别名]
def test_add_single_invoice_entry(self):
InvoiceFactory.create_batch(10)
url = reverse('invoice-entry-create', kwargs={'document_pk': 1})
entry_data = {
"description": "Page views",
"unit_price": 10.0,
"quantity": 20
}
response = self.client.post(url, data=json.dumps(entry_data),
content_type='application/json')
invoice = Invoice.objects.get(pk=1)
total = Decimal(200.0) * Decimal(1 + invoice.sales_tax_percent / 100)
assert response.status_code == status.HTTP_201_CREATED
assert response.data == {
'description': 'Page views',
'unit': None,
'quantity': '20.0000',
'unit_price': '10.0000',
'start_date': None,
'end_date': None,
'prorated': False,
'product_code': None,
'total': total,
'total_before_tax': Decimal(200.0)
}
url = reverse('invoice-detail', kwargs={'pk': 1})
response = self.client.get(url)
invoice_entries = response.data.get('invoice_entries', None)
assert len(invoice_entries) == 1
assert invoice_entries[0] == {
'description': 'Page views',
'unit': None,
'quantity': '20.0000',
'unit_price': '10.0000',
'start_date': None,
'end_date': None,
'prorated': False,
'product_code': None,
'total': total,
'total_before_tax': Decimal(200.0)
}
示例4: handle
# 需要导入模块: from silver.tests.factories import InvoiceFactory [as 别名]
# 或者: from silver.tests.factories.InvoiceFactory import create_batch [as 别名]
def handle(self, *args, **options):
proforma = ProformaFactory.create(proforma_entries=[DocumentEntryFactory.create()],
state=Proforma.STATES.ISSUED)
proforma.create_invoice()
invoice = InvoiceFactory.create(invoice_entries=[DocumentEntryFactory.create()],
state=Invoice.STATES.ISSUED,
related_document=None)
TransactionFactory.create(state=Transaction.States.Settled,
invoice=invoice,
payment_method__customer=invoice.customer,
proforma=None)
InvoiceFactory.create_batch(size=3,
invoice_entries=[DocumentEntryFactory.create()],
state=Invoice.STATES.PAID,
related_document=None)
InvoiceFactory.create_batch(size=3,
invoice_entries=[DocumentEntryFactory.create()],
state=Invoice.STATES.DRAFT,
related_document=None)
InvoiceFactory.create_batch(size=3,
invoice_entries=[DocumentEntryFactory.create()],
state=Invoice.STATES.CANCELED,
related_document=None)
示例5: test_invoice_overdue_since_last_month_queryset
# 需要导入模块: from silver.tests.factories import InvoiceFactory [as 别名]
# 或者: from silver.tests.factories.InvoiceFactory import create_batch [as 别名]
def test_invoice_overdue_since_last_month_queryset(self):
invoices = InvoiceFactory.create_batch(3)
invoices[0].due_date = date.today().replace(day=1)
invoices[0].issue()
invoices[1].due_date = date.today() - timedelta(days=31)
invoices[1].issue()
queryset = Invoice.objects.overdue_since_last_month()
assert queryset.count() == 1
assert invoices[1] in queryset
示例6: test_invoice_overdue_queryset
# 需要导入模块: from silver.tests.factories import InvoiceFactory [as 别名]
# 或者: from silver.tests.factories.InvoiceFactory import create_batch [as 别名]
def test_invoice_overdue_queryset(self):
invoices = InvoiceFactory.create_batch(3)
invoices[0].due_date = date.today() - timedelta(days=1)
invoices[0].issue()
invoices[1].due_date = date.today() - timedelta(days=3)
invoices[1].issue()
invoices[2].due_date = date.today() - timedelta(days=31)
invoices[2].issue()
invoices[2].pay()
queryset = Invoice.objects.overdue()
assert queryset.count() == 2
for invoice in invoices[:2]:
assert invoice in queryset
示例7: test_invoice_due_this_month_queryset
# 需要导入模块: from silver.tests.factories import InvoiceFactory [as 别名]
# 或者: from silver.tests.factories.InvoiceFactory import create_batch [as 别名]
def test_invoice_due_this_month_queryset(self):
invoices = InvoiceFactory.create_batch(4)
invoices[0].due_date = date.today().replace(day=20)
invoices[0].issue()
invoices[1].due_date = date.today().replace(day=1)
invoices[1].issue()
invoices[2].due_date = date.today() - timedelta(days=31)
invoices[2].issue()
invoices[3].issue()
invoices[3].cancel()
queryset = Invoice.objects.due_this_month()
assert queryset.count() == 2
for invoice in invoices[:2]:
assert invoice in queryset
示例8: test_invoice_due_today_queryset
# 需要导入模块: from silver.tests.factories import InvoiceFactory [as 别名]
# 或者: from silver.tests.factories.InvoiceFactory import create_batch [as 别名]
def test_invoice_due_today_queryset(self):
invoices = InvoiceFactory.create_batch(5)
invoices[0].due_date = date.today()
invoices[0].save()
invoices[1].due_date = date.today()
invoices[1].issue()
invoices[2].due_date = date.today() - timedelta(days=1)
invoices[2].issue()
invoices[2].pay()
invoices[3].due_date = date.today()
invoices[3].issue()
invoices[3].cancel()
invoices[4].due_date = date.today() + timedelta(days=1)
invoices[4].issue()
queryset = Invoice.objects.due_today()
assert queryset.count() == 1
assert invoices[1] in queryset