本文整理汇总了Python中silver.tests.factories.ProformaFactory.create_batch方法的典型用法代码示例。如果您正苦于以下问题:Python ProformaFactory.create_batch方法的具体用法?Python ProformaFactory.create_batch怎么用?Python ProformaFactory.create_batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silver.tests.factories.ProformaFactory
的用法示例。
在下文中一共展示了ProformaFactory.create_batch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_proformas
# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create_batch [as 别名]
def test_get_proformas(self):
batch_size = 50
ProformaFactory.create_batch(batch_size)
url = reverse('proforma-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_add_single_proforma_entry
# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create_batch [as 别名]
def test_add_single_proforma_entry(self):
ProformaFactory.create_batch(10)
url = reverse('proforma-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')
proforma = Proforma.objects.get(pk=1)
total = Decimal(200.0) * Decimal(1 + proforma.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('proforma-detail', kwargs={'pk': 1})
response = self.client.get(url)
invoice_entries = response.data.get('proforma_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)
}