class TestInvoiceItemGenerator(object):
    def setup(self):
        self.generator = InvoiceItemGenerator()

    def test_generate_title(self):
        title_text = "this is the content"

        item = self.generator.generate_title(title_text)

        assert item["title"] == title_text
        assert item["type"] == "title"

    def test_generate_description(self):
        description_text = "this is the content"

        item = self.generator.generate_description(description_text)

        assert item["description"] == description_text
        assert item["type"] == "description"

    def test_generate_item(self):
        title = "this is the title"
        unit = "this is the unit"
        unit_price = 55
        net_total = 44
        quantity = 3

        item = self.generator.generate_item(title, quantity=quantity, unit=unit, unit_price=unit_price, net_total=net_total)

        assert item["title"] == title
        assert item["unit"] == unit
        assert item["unit_price"] == unit_price
        assert item["quantity"] == quantity
        assert item["net_total"] == net_total

    def test_generate_separator(self):
        item = self.generator.generate_separator()

        assert item["type"] == "separator"

    def test_generate_separator(self):
        item = self.generator.generate_separator()

        assert item["type"] == "separator"

    def test_generate_subtotal(self):
        title = "zwischensumme"
        item = self.generator.generate_subtotal(title)

        assert item["type"] == "subtotal"
        assert item["title"] == title

    def test_generate_pagebreak(self):
        item = self.generator.generate_pagebreak()

        assert item["type"] == "page-break"
Exemplo n.º 2
0
    def test_create_default_status(self):
        generator = InvoiceItemGenerator()

        default_status = 'created'

        customer_id = 123456
        recipient_address = "My customer..."
        created_date = "2018-09-17"
        due_date = "2018-10-16"
        service_period_from = date(2019, 10, 1)
        service_period_to = date(2019, 10, 31)
        title = "Invoice"
        tax = 8.0
        currency = "CHF"
        items = [
            generator.generate_title("this is the title"),
            generator.generate_separator()
        ]

        response = self.moco.Invoice.create(customer_id, recipient_address,
                                            created_date, due_date,
                                            service_period_from,
                                            service_period_to, title, tax,
                                            currency, items)
        data = response["data"]

        assert data["status"] == default_status
Exemplo n.º 3
0
    def test_create(self):
        generator = InvoiceItemGenerator()

        customer_id = 123456
        recipient_address = "My customer..."
        create_date = "2018-09-17"
        due_date = "2018-10-16"
        service_period_from = date(2019, 10, 1)
        service_period_to = date(2019, 10, 31)
        title = "Invoice"
        tax = 8.0
        currency = "CHF"
        items = [
            generator.generate_title("this is the title"),
            generator.generate_separator()
        ]
        status = "created"
        change_address = "customer"
        salutation = "salute"
        footer = "footer text"
        discount = 10
        cash_discount = 2.5
        cash_discount_days = 5
        project_id = 654321
        tags = ["Hosting", "Europe"]

        response = self.moco.Invoice.create(
            customer_id,
            recipient_address,
            create_date,
            due_date,
            service_period_from,
            service_period_to,
            title,
            tax,
            currency,
            items,
            status=status,
            change_address=change_address,
            salutation=salutation,
            footer=footer,
            discount=discount,
            cash_discount=cash_discount,
            cash_discount_days=cash_discount_days,
            project_id=project_id,
            tags=tags)
        data = response["data"]

        assert data["customer_id"] == customer_id
        assert data["recipient_address"] == recipient_address
        assert data["date"] == create_date
        assert data["due_date"] == due_date
        assert data["service_period_from"] == service_period_from.isoformat()
        assert data["service_period_to"] == service_period_to.isoformat()
        assert data["title"] == title
        assert data["tax"] == tax
        assert data["currency"] == currency
        assert data["items"] == items

        assert data["status"] == status
        assert data["change_address"] == change_address

        assert data["salutation"] == salutation
        assert data["footer"] == footer
        assert data["discount"] == discount
        assert data["cash_discount"] == cash_discount
        assert data["cash_discount_days"] == cash_discount_days
        assert data["project_id"] == project_id
        assert data["tags"] == tags

        assert response["method"] == "POST"