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


Python ProformaFactory.create方法代码示例

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


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

示例1: test_get_proforma

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

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

        assert response.status_code == status.HTTP_200_OK
        assert response.data == {
            "id": 1,
            "series": "ProformaSeries",
            "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",
            'pdf_url': None,
            "state": "draft",
            "invoice": None,
            "proforma_entries": [],
            'total': Decimal('0.00'),
        }
开发者ID:Athenolabs,项目名称:silver,代码行数:31,代码来源:test_proforma.py

示例2: test_issue_proforma_with_custom_issue_date_and_due_date

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_issue_proforma_with_custom_issue_date_and_due_date(self):
        provider = ProviderFactory.create()
        customer = CustomerFactory.create()
        ProformaFactory.create(provider=provider, customer=customer)

        url = reverse('proforma-state', kwargs={'pk': 1})
        data = {
            'state': 'issued',
            'issue_date': '2014-01-01',
            'due_date': '2014-01-20'
        }

        response = self.client.put(url, data=json.dumps(data),
                                     content_type='application/json')

        assert response.status_code == status.HTTP_200_OK
        mandatory_content = {
            'issue_date': '2014-01-01',
            'due_date': '2014-01-20',
            'state': 'issued'
        }
        assert response.status_code == status.HTTP_200_OK
        assert all(item in response.data.items()
                   for item in mandatory_content.iteritems())
        assert response.data.get('archived_provider', {}) != {}
        assert response.data.get('archived_customer', {}) != {}
        assert Invoice.objects.count() == 0

        proforma = get_object_or_None(Proforma, pk=1)
开发者ID:Athenolabs,项目名称:silver,代码行数:31,代码来源:test_proforma.py

示例3: test_actions_failed_no_log_entries

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

        url = reverse('admin:silver_proforma_changelist')

        mock_log_entry = MagicMock()
        mock_log_action = MagicMock()
        mock_log_entry.objects.log_action = mock_log_action

        exceptions = cycle([ValueError, TransitionNotAllowed])

        def _exception_thrower(*args):
            raise exceptions.next()

        mock_action = MagicMock(side_effect=_exception_thrower)

        mock_proforma = MagicMock()
        mock_proforma.issue = mock_action
        mock_proforma.cancel = mock_action
        mock_proforma.pay = mock_action
        mock_proforma.clone_into_draft = mock_action
        mock_proforma.create_invoice = mock_action

        with patch.multiple('silver.admin',
                            LogEntry=mock_log_entry,
                            Proforma=mock_proforma):
            actions = ['issue', 'pay', 'cancel', 'clone', 'create_invoice']

            for action in actions:
                self.admin.post(url, {
                    'action': action,
                    '_selected_action': [u'1']
                })

                assert not mock_log_action.call_count
开发者ID:MaxMorais,项目名称:silver,代码行数:37,代码来源:test_proforma.py

示例4: test_pay_proforma_when_in_draft_state

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_pay_proforma_when_in_draft_state(self):
        provider = ProviderFactory.create()
        customer = CustomerFactory.create()
        ProformaFactory.create(provider=provider, customer=customer)

        url = reverse('proforma-state', kwargs={'pk': 1})
        data = {'state': 'paid'}
        response = self.client.put(url, data=json.dumps(data),
                                     content_type='application/json')
        assert response.status_code == status.HTTP_403_FORBIDDEN
        assert response.data == {'detail': 'A proforma can be paid only if it is in issued state.'}
        assert Invoice.objects.count() == 0
开发者ID:Athenolabs,项目名称:silver,代码行数:14,代码来源:test_proforma.py

示例5: test_illegal_state_change_when_in_draft_state

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_illegal_state_change_when_in_draft_state(self):
        provider = ProviderFactory.create()
        customer = CustomerFactory.create()
        ProformaFactory.create(provider=provider, customer=customer)

        url = reverse('proforma-state', kwargs={'pk': 1})
        data = {'state': 'illegal-state'}

        response = self.client.put(url, data=json.dumps(data),
                                     content_type='application/json')

        assert response.status_code == status.HTTP_403_FORBIDDEN
        assert response.data == {'detail': 'Illegal state value.'}
        assert Invoice.objects.count() == 0
开发者ID:Athenolabs,项目名称:silver,代码行数:16,代码来源:test_proforma.py

示例6: test_documents_list_case_1

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_documents_list_case_1(self):
        """
            One proforma, one invoice, without related documents
        """
        proforma = ProformaFactory.create()
        invoice_entries = DocumentEntryFactory.create_batch(3)
        invoice = InvoiceFactory.create(invoice_entries=invoice_entries)
        invoice.issue()
        payment_method = PaymentMethodFactory.create(customer=invoice.customer)
        transaction = TransactionFactory.create(payment_method=payment_method,
                                                invoice=invoice)

        url = reverse('document-list')

        with patch('silver.utils.payments._get_jwt_token',
                   new=self._jwt_token):
            response = self.client.get(url)

        # ^ there's a bug where specifying format='json' doesn't work
        response_data = response.data

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(len(response_data), 2)

        self.assertIn(self._get_expected_data(invoice, [transaction]),
                      response_data)

        self.assertIn(self._get_expected_data(proforma), response_data)
开发者ID:PressLabs,项目名称:silver,代码行数:30,代码来源:test_documents.py

示例7: test_patch_transaction_documents

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_patch_transaction_documents(self):
        payment_method = PaymentMethodFactory.create(
            payment_processor='someprocessor'
        )
        transaction = TransactionFactory.create(payment_method=payment_method)
        proforma = ProformaFactory.create()
        invoice = InvoiceFactory.create(proforma=proforma)
        proforma.invoice = invoice
        proforma.save()

        invoice_url = reverse('invoice-detail', args=[invoice.pk])
        proforma_url = reverse('proforma-detail', args=[proforma.pk])
        url = reverse('transaction-detail', args=[transaction.customer.pk,
                                                  transaction.uuid])

        data = {
            'proforma': proforma_url,
            'invoice': invoice_url
        }

        response = self.client.patch(url, format='json', data=data)

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

        self.assertEqual(response.data, {
            'proforma': [u'This field may not be modified.'],
            'invoice': [u'This field may not be modified.']
        })
开发者ID:oucsaw,项目名称:silver,代码行数:30,代码来源:test_transactions.py

示例8: test_add_transaction_with_documents_for_a_different_customer

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_add_transaction_with_documents_for_a_different_customer(self):
        customer = CustomerFactory.create()
        payment_method = PaymentMethodFactory.create(customer=customer)

        proforma = ProformaFactory.create()
        proforma.state = proforma.STATES.ISSUED
        proforma.create_invoice()
        proforma.refresh_from_db()
        invoice = proforma.invoice

        valid_until = datetime.now()
        url = reverse('payment-method-transaction-list',
                      kwargs={'customer_pk': customer.pk, 'payment_method_id': payment_method.pk})
        invoice_url = reverse('invoice-detail', args=[invoice.pk])
        proforma_url = reverse('proforma-detail', args=[proforma.pk])
        data = {
            'payment_method': reverse('payment-method-detail', kwargs={'customer_pk': customer.pk,
                                                                       'payment_method_id': payment_method.id}),
            'valid_until': valid_until,
            'amount': 200.0,
            'invoice': invoice_url,
            'proforma': proforma_url
        }

        response = self.client.post(url, format='json', data=data)

        expected_data = {
            'non_field_errors': [u"Customer doesn't match with the one in documents."]
        }
        self.assertEqual(response.data, expected_data)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
开发者ID:oucsaw,项目名称:silver,代码行数:33,代码来源:test_transactions.py

示例9: test_add_transaction_with_unrelated_documents

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_add_transaction_with_unrelated_documents(self):
        customer = CustomerFactory.create()
        payment_method = PaymentMethodFactory.create(customer=customer)

        invoice = InvoiceFactory.create(customer=customer)
        proforma = ProformaFactory.create(customer=customer)
        valid_until = datetime.now()
        url = reverse('payment-method-transaction-list',
                      kwargs={'customer_pk': customer.pk, 'payment_method_id': payment_method.pk})
        invoice_url = reverse('invoice-detail', args=[invoice.pk])
        proforma_url = reverse('proforma-detail', args=[proforma.pk])
        data = {
            'payment_method': reverse('payment-method-detail', kwargs={'customer_pk': customer.pk,
                                                                       'payment_method_id': payment_method.id}),
            'valid_until': valid_until,
            'amount': 200.0,
            'invoice': invoice_url,
            'proforma': proforma_url
        }

        response = self.client.post(url, format='json', data=data)

        expected_data = {
            'non_field_errors': [u'Invoice and proforma are not related.']
        }
        self.assertEqual(response.data, expected_data)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
开发者ID:oucsaw,项目名称:silver,代码行数:29,代码来源:test_transactions.py

示例10: test_pay_proforma_with_provided_date

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_pay_proforma_with_provided_date(self):
        provider = ProviderFactory.create()
        customer = CustomerFactory.create()
        proforma = ProformaFactory.create(provider=provider, customer=customer)
        proforma.issue()

        url = reverse('proforma-state', kwargs={'pk': proforma.pk})
        data = {
            'state': 'paid',
            'paid_date': '2014-05-05'
        }
        response = self.client.put(url, data=json.dumps(data), content_type='application/json')

        proforma.refresh_from_db()
        assert response.status_code == status.HTTP_200_OK
        due_date = timezone.now().date() + timedelta(days=PAYMENT_DUE_DAYS)

        invoice_url = build_absolute_test_url(reverse('invoice-detail',
                                                      [proforma.related_document.pk]))
        mandatory_content = {
            'issue_date': timezone.now().date().strftime('%Y-%m-%d'),
            'due_date': due_date.strftime('%Y-%m-%d'),
            'paid_date': '2014-05-05',
            'state': 'paid',
            'invoice': invoice_url
        }
        assert response.status_code == status.HTTP_200_OK
        assert all(item in list(response.data.items())
                   for item in mandatory_content.items())

        invoice = Invoice.objects.all()[0]
        assert proforma.related_document == invoice
        assert invoice.related_document == proforma
开发者ID:PressLabs,项目名称:silver,代码行数:35,代码来源:test_proforma.py

示例11: test_no_transaction_settle_with_only_related_proforma

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_no_transaction_settle_with_only_related_proforma(self):
        proforma = ProformaFactory.create(related_document=None)

        customer = proforma.customer
        PaymentMethodFactory.create(
            payment_processor=triggered_processor, customer=customer,
            canceled=False,
            verified=True,
        )

        proforma.issue()

        transaction = proforma.transactions[0]
        # here transaction.proforma is the same object as the proforma from the
        # DB due to the way transition callbacks and saves are called

        transaction.settle()
        transaction.save()

        self.assertEqual(proforma.state, proforma.STATES.PAID)

        invoice = proforma.related_document
        self.assertEqual(invoice.state, invoice.STATES.PAID)

        self.assertEqual(list(proforma.transactions),
                         list(invoice.transactions))

        self.assertEqual(len(proforma.transactions), 1)
开发者ID:PressLabs,项目名称:silver,代码行数:30,代码来源:test_documents_transactions.py

示例12: test_proforma_total_with_tax_integrity

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_proforma_total_with_tax_integrity(self):
        proforma_entries = DocumentEntryFactory.create_batch(5)
        proforma = ProformaFactory.create(proforma_entries=proforma_entries)

        proforma.sales_tax_percent = Decimal('20.00')

        assert proforma.total == proforma.total_before_tax + proforma.tax_value
开发者ID:PressLabs,项目名称:silver,代码行数:9,代码来源:test_proforma.py

示例13: test_proforma_tax_value_decimal_places

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_proforma_tax_value_decimal_places(self):
        proforma_entries = DocumentEntryFactory.create_batch(3)
        proforma = ProformaFactory.create(proforma_entries=proforma_entries)

        proforma.sales_tax_percent = Decimal('20.00')

        assert self._get_decimal_places(proforma.tax_value) == 2
开发者ID:PressLabs,项目名称:silver,代码行数:9,代码来源:test_proforma.py

示例14: handle

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [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)
开发者ID:PressLabs,项目名称:silver,代码行数:27,代码来源:seed.py

示例15: test_proforma_currency_used_for_transaction_currency

# 需要导入模块: from silver.tests.factories import ProformaFactory [as 别名]
# 或者: from silver.tests.factories.ProformaFactory import create [as 别名]
    def test_proforma_currency_used_for_transaction_currency(self):
        customer = CustomerFactory.create(currency=None)
        proforma = ProformaFactory.create(customer=customer,
                                          currency='EUR',
                                          transaction_currency=None)

        self.assertEqual(proforma.transaction_currency, 'EUR')
开发者ID:PressLabs,项目名称:silver,代码行数:9,代码来源:test_proforma.py


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