当前位置: 首页>>代码示例>>Python>>正文


Python InvoiceFactory.reset_sequence方法代码示例

本文整理汇总了Python中silver.tests.factories.InvoiceFactory.reset_sequence方法的典型用法代码示例。如果您正苦于以下问题:Python InvoiceFactory.reset_sequence方法的具体用法?Python InvoiceFactory.reset_sequence怎么用?Python InvoiceFactory.reset_sequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在silver.tests.factories.InvoiceFactory的用法示例。


在下文中一共展示了InvoiceFactory.reset_sequence方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_invoice

# 需要导入模块: from silver.tests.factories import InvoiceFactory [as 别名]
# 或者: from silver.tests.factories.InvoiceFactory import reset_sequence [as 别名]
    def test_get_invoice(self):
        InvoiceFactory.reset_sequence(1)
        InvoiceFactory.create()

        url = reverse('invoice-detail', kwargs={'pk': 1})
        response = self.client.get(url)

        assert response.status_code == status.HTTP_200_OK
        assert response.data == {
            "id": 1,
            "series": "InvoiceSeries",
            "number": 1,
            "provider": "http://testserver/providers/1/",
            "customer": "http://testserver/customers/1/",
            "archived_provider": {},
            "archived_customer": {},
            "due_date": None,
            "issue_date": None,
            "paid_date": None,
            "cancel_date": None,
            "sales_tax_name": "VAT",
            "sales_tax_percent": '1.00',
            "currency": "RON",
            "state": "draft",
            "proforma": None,
            "invoice_entries": [],
            "pdf_url": None,
            "total": Decimal('0.00'),
        }
开发者ID:MaxMorais,项目名称:silver,代码行数:31,代码来源:test_invoice.py

示例2: test_get_invoice

# 需要导入模块: from silver.tests.factories import InvoiceFactory [as 别名]
# 或者: from silver.tests.factories.InvoiceFactory import reset_sequence [as 别名]
    def test_get_invoice(self, mocked_settings):
        InvoiceFactory.reset_sequence(1)
        TransactionFactory.reset_sequence(1)

        customer = CustomerFactory.create()
        invoice = InvoiceFactory.create(customer=customer, state=Invoice.STATES.ISSUED)

        invoice.generate_pdf()

        with mute_signals(pre_save):
            transactions = [
                TransactionFactory.create(
                    state=state, invoice=invoice,
                    payment_method=PaymentMethodFactory(customer=customer)
                )
                for state in Transaction.States.as_list()
                if state not in [Transaction.States.Canceled,
                                 Transaction.States.Refunded,
                                 Transaction.States.Failed]
            ]
        expected_transactions = [{
            "id": str(transaction.uuid),
            "url": build_absolute_test_url(reverse('transaction-detail',
                                                   [transaction.customer.pk, transaction.uuid])),
            "customer": build_absolute_test_url(reverse('customer-detail',
                                                        [transaction.customer.id])),
            "provider": build_absolute_test_url(reverse('provider-detail',
                                                        [transaction.provider.id])),
            "amount": "%.2f" % transaction.amount,
            "currency": "RON",
            "state": transaction.state,
            "proforma": build_absolute_test_url(reverse('proforma-detail',
                                                        [transaction.proforma.id])),
            "invoice": build_absolute_test_url(reverse('invoice-detail',
                                                       [transaction.invoice.id])),
            "can_be_consumed": transaction.can_be_consumed,
            "payment_processor": transaction.payment_processor,
            "payment_method": build_absolute_test_url(reverse('payment-method-detail',
                                                              [transaction.customer.pk,
                                                               transaction.payment_method.pk])),
            "pay_url": (build_absolute_test_url(reverse('payment', ['token']))
                        if transaction.state == Transaction.States.Initial else None),
        } for transaction in transactions]

        with patch('silver.utils.payments._get_jwt_token') as mocked_token:
            mocked_token.return_value = 'token'
            url = reverse('invoice-detail', kwargs={'pk': invoice.pk})

            for show_pdf_storage_url, pdf_url in [
                (True, build_absolute_test_url(invoice.pdf.url)),
                (False, build_absolute_test_url(reverse('pdf', args=[invoice.pdf.pk])))
            ]:
                mocked_settings.SILVER_SHOW_PDF_STORAGE_URL = show_pdf_storage_url

                response = self.client.get(url)

                self.assertEqual(response.status_code, status.HTTP_200_OK)
                expected_response = {
                    "id": invoice.pk,
                    "series": "InvoiceSeries",
                    "number": 1,
                    "provider": build_absolute_test_url(reverse('provider-detail',
                                                                [invoice.provider.pk])),
                    "customer": build_absolute_test_url(reverse('customer-detail',
                                                                [invoice.customer.pk])),
                    "archived_provider": '{}',
                    "archived_customer": '{}',
                    "due_date": None,
                    "issue_date": invoice.issue_date.strftime('%Y-%m-%d'),
                    "paid_date": None,
                    "cancel_date": None,
                    "sales_tax_name": "VAT",
                    "sales_tax_percent": '1.00',
                    "currency": "RON",
                    "transaction_currency": invoice.transaction_currency,
                    "transaction_xe_rate": ("%.4f" % invoice.transaction_xe_rate
                                            if invoice.transaction_xe_rate else None),
                    "transaction_xe_date": invoice.transaction_xe_date,
                    "state": "issued",
                    "proforma": build_absolute_test_url(reverse('proforma-detail',
                                                                [invoice.related_document.pk])),
                    "invoice_entries": [],
                    "pdf_url": pdf_url,
                    "total": 0
                }
                for field in expected_response:
                    self.assertEqual(expected_response[field], response.data[field],
                                     msg=("Expected %s, actual %s for field %s" % (
                                          expected_response[field], response.data[field],
                                          field)))

                self.assertEqual(len(response.data["transactions"]),
                                 len(expected_transactions))

                for actual_transaction in response.data["transactions"]:
                    expected_transaction = [
                        transaction for transaction in expected_transactions if
                        transaction["id"] == actual_transaction["id"]
                    ]
                    self.assertTrue(expected_transaction)
#.........这里部分代码省略.........
开发者ID:PressLabs,项目名称:silver,代码行数:103,代码来源:test_invoice.py


注:本文中的silver.tests.factories.InvoiceFactory.reset_sequence方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。