예제 #1
0
    def test_full_header_table(self, mocker):
        expected_date = date(2020, 12, 15)
        mock_date = mocker.patch("src.offer.date", autospec=True)
        mock_date.today.return_value = expected_date

        vars = {"order email": "*****@*****.**", "HQ": "lorem<br />ipsum"}
        mocker.patch("src.offer.get_var",
                     autospce=True,
                     side_effect=lambda key: vars[key])

        expected_symbol = "X2012N08"
        user = mocker.create_autospec(User(), spec_set=True)
        user.new_offer_symbol.return_value = expected_symbol
        user.name = "Author Name"
        user.mail = "*****@*****.**"
        user.gender_suffix = "a"
        user.phone = "123 456 789"

        offer = Offer.create_empty(user)

        customer = mocker.create_autospec(Customer(), spec_set=True)
        customer.id = 1
        customer.company_name = "Full business name"
        customer.concated_name = "Mr John Doe"
        customer.html_address = "255 Some street<br />\nIn some town"
        offer.customer = customer

        header_table = offer.header_table()
        expected_header_table = """
    <table>
    <tr>
        <td valign=top width=315>
            Oferta nr: <b>X2012N08</b><br />
            Z dnia: 15.12.2020<br />
            Dla:<br />
            <b>Full business name</b><br />
            255 Some street<br />
In some town<br />
            Mr John Doe
        </td>
        <td width=315>
            lorem<br />ipsum<br />
            <b>Author Name</b><br />
            [email protected]<br />
            Tel.: 123 456 789
        </td>
        <td width=115 align=right>
            <img src=:/logos width=114 valign=top>
        </td>
    </tr>
    <tr>
        <td colspan=3>
            <hr width=100%>
        </td>
    </tr>
    </table>
"""
        assert_that(header_table,
                    is_(equal_to_ignoring_whitespace(expected_header_table)))
예제 #2
0
    def test_create_empty(self, mocker):
        expected_symbol = "X2012N08"
        user = mocker.create_autospec(User, instance=True)
        user.new_offer_symbol.return_value = expected_symbol

        expected_date = date(2020, 12, 15)
        mock_date = mocker.patch("src.offer.date", autospec=True)
        mock_date.today.return_value = expected_date

        vars = {"order email": "*****@*****.**", "HQ": "lorem<br />ipsum"}
        mocker.patch("src.offer.get_var",
                     autospce=True,
                     side_effect=lambda key: vars[key])

        offer = Offer.create_empty(user)

        assert_that(offer.merchandise_list,
                    is_(instance_of(MerchandiseListModel)))
        assert_that(offer.customer, is_(instance_of(Customer)))
        assert_that(offer.date, is_(expected_date))
        assert_that(offer.author, is_(user))
        assert_that(offer.symbol, is_(expected_symbol))
        assert_that(offer.company_address, is_(vars["HQ"]))
        assert_that(offer.order_email, is_(vars["order email"]))
예제 #3
0
    def test_whole_printout(self, mocker):
        expected_date = date(2020, 12, 15)
        mock_date = mocker.patch("src.offer.date", autospec=True)
        mock_date.today.return_value = expected_date

        vars = {"order email": "*****@*****.**", "HQ": "lorem<br />ipsum"}
        mocker.patch("src.offer.get_var",
                     autospce=True,
                     side_effect=lambda key: vars[key])

        expected_symbol = "X2012N08"
        user = mocker.create_autospec(User(), spec_set=True)
        user.new_offer_symbol.return_value = expected_symbol
        user.name = "Author Name"
        user.mail = "*****@*****.**"
        user.gender_suffix = "a"
        user.phone = "123 456 789"

        offer = Offer.create_empty(user)

        customer = mocker.create_autospec(Customer(), spec_set=True)
        customer.id = 1
        customer.company_name = "Full business name"
        customer.concated_name = "Mr John Doe"
        customer.html_address = "255 Some street<br />\nIn some town"
        offer.customer = customer

        offer.merchandise_list.add_item(create_merch())
        offer.remarks = "Some remarks"

        expected_document = """<html>
<head>
<title>Oferta</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<style>
    .spec { font-size: 6pt; }
    .row0 { background: #efefef; }
    .row1 { background: #dadada; }
</style>
</head>
<body>
<table>
<thead>
<tr><td>
    <table>
    <tr>
        <td valign=top width=315>
            Oferta nr: <b>X2012N08</b><br />
            Z dnia: 15.12.2020<br />
            Dla:<br />
            <b>Full business name</b><br />
            255 Some street<br />
In some town<br />
            Mr John Doe
        </td>
        <td width=315>
            lorem<br />ipsum<br />
            <b>Author Name</b><br />
            [email protected]<br />
            Tel.: 123 456 789
        </td>
        <td width=115 align=right>
            <img src=:/logos width=114 valign=top>
        </td>
    </tr>
    <tr>
        <td colspan=3>
            <hr width=100%>
        </td>
    </tr>
    </table>
</td></tr>
</thead>
<tbody>
<tr><td>
    W odpowiedzi na zapytanie, przedstawiamy ofertę na dostawę następujących produktów:
</td></tr>
<tr><td>
    
    <table cellspacing=0>
        <thead><tr class="header">
            <td width=40 align=left><b>Lp.</b></td>
            <td width=285 align=left><b>Towar</b></td>
            <td width=90 align=right><b>Cena kat.</b></td>
            <td width=75 align=right><b>Rabat</b></td>
            <td width=90 align=right><b>Cena</b></td>
            <td width=75 align=right><b>Ilość</b></td>
            <td width=90 align=right><b>Wartość</b></td>
        </tr></thead>

        <tr class="row1">
            <td align=right style="padding-right: 5">1</td>
            <td>CODE</td>
            <td align=right>9.99 zł</td>
            <td align=right>10.0%</td>
            <td align=right>8.99 zł</td>
            <td align=right>1 szt.</td>
            <td align=right>8.99 zł</td>
        </tr>
        <tr class="row1 spec">
            <td></td>
            <td colspan=6>DESCR</td>
        </tr>

        <tr style="font-weight:bold;">
            <td align=right colspan=6>Razem:</td>
            <td align=right>8.99 zł</td>
        </tr>
    </table>

</td></tr>
<tr><td>
    Podane ceny nie zawierają podatku VAT<br />
</td></tr>
<tr><td>
<table cellspacing=3>
    <tr>
        <td width=140>Uwagi:</td>
        <td width=602>Some remarks</td>
    </tr>
</table>

</td></tr>
<tr><td>
    <p>
    <b>Zamówienia prosimy kierować na adres:</b> [email protected] z kopią do autora oferty.<br />
    <br />
    Łączymy pozdrowienia.
    </p>
    <p align=center style="margin-left: 500">
        Ofertę przygotowała<br /><br /><br />
        Author Name
    </p>
</td></tr>
</tbody>
</table>
</body>
</html>
"""

        document = offer.printout()
        assert_that(document,
                    is_(equal_to_ignoring_whitespace(expected_document)))
예제 #4
0
 def new_offer(self) -> None:
     self.offer = Offer.create_empty(self.user, self)
     self.set_offer_ui_enabled(True)
     self.setWindowTitle(f"pyOffer - {self.offer.symbol}")
     self.ui.tableView.setModel(self.offer.merchandise_list)
     self.update_inquiry_text()