Esempio n. 1
0
    def test_empty_merchandise_table(self):
        offer = Offer()
        offer.merchandise_list = MerchandiseListModel(offer)

        merchandise_table = offer.merchanidse_table()

        expected_merchandise_table = """
    <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 style="font-weight:bold;">
            <td align=right colspan=6>Razem:</td>
            <td align=right>0.00 zł</td>
        </tr>
    </table>
"""
        assert_that(
            merchandise_table,
            is_(equal_to_ignoring_whitespace(expected_merchandise_table)))
Esempio n. 2
0
    def test_merchandise_table_with_minimum_subset(self):
        offer = Offer()
        offer.merchandise_list = MerchandiseListModel(offer)
        offer.merchandise_list.add_item(create_merch())

        merchandise_table = offer.merchanidse_table(
            PrintOptions(False, True, False, False, False, False, False, True))

        expected_merchandise_table = """
    <table cellspacing=0>
        <thead><tr class="header">
            <td width=655 align=left><b>Towar</b></td>
            <td width=90 align=right><b>Wartość</b></td>
        </tr></thead>

        <tr class="row1">
            <td>CODE</td>
            <td align=right>8.99 zł</td>
        </tr>

        <tr style="font-weight:bold;">
            <td align=right colspan=1>Razem:</td>
            <td align=right>8.99 zł</td>
        </tr>
    </table>
"""
        assert_that(
            merchandise_table,
            is_(equal_to_ignoring_whitespace(expected_merchandise_table)))
Esempio n. 3
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)))
Esempio n. 4
0
    def test_empty_terms_table(self):
        offer = Offer()

        terms_table = offer.terms_table()

        expected_terms_table = "<table cellspacing=3></table>"
        assert_that(terms_table,
                    is_(equal_to_ignoring_whitespace(expected_terms_table)))
Esempio n. 5
0
    def test_terms_table_remarks(self, remarks, expected_remarks):
        offer = Offer()
        offer.remarks = remarks

        terms_table = offer.terms_table()

        expected_terms_table = f"""
<table cellspacing=3>
    <tr>
        <td width=140>Uwagi:</td>
        <td width=602>{expected_remarks}</td>
    </tr>
</table>
"""
        assert_that(terms_table,
                    is_(equal_to_ignoring_whitespace(expected_terms_table)))
Esempio n. 6
0
    def test_terms_table(self, term_type, term_type_desc):
        text = "Some terms text"
        offer = Offer()
        offer.terms = {term_type: (TermItem(term_type, text))}

        terms_table = offer.terms_table()

        expected_terms_table = f"""
<table cellspacing=3>
    <tr>
        <td width=140>{term_type_desc}:</td>
        <td width=602>{text}</td>
    </tr>
</table>
"""
        assert_that(terms_table,
                    is_(equal_to_ignoring_whitespace(expected_terms_table)))
Esempio n. 7
0
    def test_merchandise_table_with_all_columns(self):
        offer = Offer()
        offer.merchandise_list = MerchandiseListModel(offer)
        offer.merchandise_list.add_item(create_merch())

        merchandise_table = offer.merchanidse_table()

        expected_merchandise_table = """
    <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>
"""
        assert_that(
            merchandise_table,
            is_(equal_to_ignoring_whitespace(expected_merchandise_table)))
Esempio n. 8
0
    def test_merchandise_table_without_list_price_and_discount(self):
        offer = Offer()
        offer.merchandise_list = MerchandiseListModel(offer)
        offer.merchandise_list.add_item(create_merch())

        merchandise_table = offer.merchanidse_table(
            PrintOptions(print_list_price=False, print_discount=False))

        expected_merchandise_table = """
    <table cellspacing=0>
        <thead><tr class="header">
            <td width=40 align=left><b>Lp.</b></td>
            <td width=450 align=left><b>Towar</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>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=4>DESCR</td>
        </tr>

        <tr style="font-weight:bold;">
            <td align=right colspan=4>Razem:</td>
            <td align=right>8.99 zł</td>
        </tr>
    </table>
"""
        assert_that(
            merchandise_table,
            is_(equal_to_ignoring_whitespace(expected_merchandise_table)))
Esempio n. 9
0
def _equal_to_section_name(expected):
    return all_of(starts_with('['), ends_with(']'),
                  equal_to_ignoring_whitespace(expected))
Esempio n. 10
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)))
Esempio n. 11
0
 def test_basedir(self):
     task, cmd = self.echo('$basedir')
     task.assert_that(cmd.stdout.content,
                      hamcrest.equal_to_ignoring_whitespace('.'))
Esempio n. 12
0
 def test_fulltestdir(self):
     task, cmd = self.echo('$fulltestdir')
     task.assert_that(cmd.stdout.content,
                      hamcrest.equal_to_ignoring_whitespace(TESTDIR))
Esempio n. 13
0
 def test_testfilename(self):
     task, cmd = self.echo('$testfilename')
     expected = os.path.split(__file__)[1].rstrip('c')
     task.assert_that(cmd.stdout.content,
                      hamcrest.equal_to_ignoring_whitespace(expected))
Esempio n. 14
0
 def test_tmp_base(self):
     expected = '/tmp/prego-' + LOGIN
     task, cmd = self.echo('$tmpbase')
     task.assert_that(cmd.stdout.content,
                      hamcrest.equal_to_ignoring_whitespace(expected))
Esempio n. 15
0
def _section_body_matchers(expected):
    return [equal_to_ignoring_whitespace(line) for line in expected]
Esempio n. 16
0
 def test_cwd(self):
     task = prego.Task()
     cmd = task.command('pwd', cwd='$testdir')
     task.assert_that(cmd.stdout.content,
                      hamcrest.equal_to_ignoring_whitespace(TESTDIR))
Esempio n. 17
0
 def test_tmp(self):
     expected = '/tmp/prego-{0}/{1}'.format(LOGIN, PID)
     task, cmd = self.echo('$tmp')
     task.assert_that(cmd.stdout.content,
                      hamcrest.equal_to_ignoring_whitespace(expected))