Beispiel #1
0
    def test_create_with_all_items(self):
        deal = self.get_deal()
        user = self.get_user()

        with self.recorder.use_cassette(
                "TestOffer.test_create_with_all_items"):
            gen = OfferItemGenerator()
            items = [
                gen.generate_title("this is the title"),
                gen.generate_description("This is the first description"),
                gen.generate_detail_postion("support", 1, "h", 65),
                gen.generate_lump_position("server hardware", 200),
                gen.generate_subtotal("subtotal position"),
                gen.generate_detail_postion("special support", 3, "h", 90),
                gen.generate_pagebreak()
            ]

            offer_create = self.moco.Offer.create(
                deal.id, None,
                "this is the recipient address", date(2020, 1, 1),
                date(2021, 1, 1), "offer title", 19, "EUR", items)

            assert offer_create.response.status_code == 201

            assert isinstance(offer_create, JsonResponse)

            assert len(offer_create.data.items) == 7
Beispiel #2
0
    def test_create_with_all_items(self):
        deal = self.get_deal()

        with self.recorder.use_cassette("TestOffer.test_create_with_all_items"):
            gen = OfferItemGenerator()
            items = [
                gen.generate_title(
                    title="this is the title"
                ),
                gen.generate_description(
                    description="This is the first description"
                ),
                gen.generate_detail_position(
                    title="support",
                    quantity=1,
                    unit="h",
                    unit_price=65
                ),
                gen.generate_lump_position(
                    title="server hardware",
                    net_total=200
                ),
                gen.generate_subtotal(
                    title="subtotal position"
                ),
                gen.generate_detail_position(
                    title="special support",
                    quantity=3,
                    unit="h",
                    unit_price=90
                ),
                gen.generate_pagebreak()
            ]

            offer_create = self.moco.Offer.create(
                deal_id=deal.id,
                project_id=None,
                recipient_address="My Customer Address 43",
                creation_date=date(2020, 1, 1),
                due_date=date(2021, 1, 1),
                title="TestOffer.test_create_with_all_items",
                tax=19,
                currency="EUR",
                items=items
            )

            assert offer_create.response.status_code == 201

            assert type(offer_create) is ObjectResponse

            assert len(offer_create.data.items) == 7
Beispiel #3
0
class TestOfferItemGenerator(object):
    def setup(self):
        self.generator = OfferItemGenerator()

    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_detail_item(self):
        title = "this is the title"
        unit = "h"
        unit_price = 25
        quantity = 3

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

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

    def test_generate_lump_item(self):
        title = "this is the title"
        net_total = 300

        item = self.generator.generate_lump_position(title, net_total)

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

    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"