Exemplo n.º 1
0
def test_stacked_tax_taxful_price():
    source = OrderSource()
    source.lines = [
        SourceLine(source=source,
                   type=OrderLineType.OTHER,
                   quantity=1,
                   unit_price=TaxfulPrice(20))
    ]
    with override_provides(
            "tax_module",
        ["shoop_tests.functional.test_tax_system:IrvineCaliforniaTaxation"]):
        with override_settings(SHOOP_TAX_MODULE="irvine"):
            source.billing_address = Address(
                street="16215 Alton Pkwy",
                postal_code="92602",
            )
            line = source.get_final_lines()[0]
            assert isinstance(line, SourceLine)
            assert line.taxes
            assert line.taxful_total_price == TaxfulPrice(20)
            assert abs(line.taxless_total_price.amount -
                       Decimal("18.519")) < Decimal("0.01")
            source.uncache()

            # Let's move out to a taxless location.
            source.billing_address.postal_code = "11111"
            line = source.get_final_lines()[0]
            assert isinstance(line, SourceLine)
            assert not line.taxes
            assert line.taxful_total_price == TaxfulPrice(20)
            assert line.taxless_total_price.amount == Decimal("20")
Exemplo n.º 2
0
def test_home_country_in_address():
    with override("fi"):
        finnish_address = Address(country="FI")
        with override_settings(SHOOP_ADDRESS_HOME_COUNTRY="US"):
            assert "Suomi" in str(finnish_address), "When home is not Finland, Finland appears in address string"
        with override_settings(SHOOP_ADDRESS_HOME_COUNTRY="FI"):
            assert "Suomi" not in str(finnish_address), "When home is Finland, Finland does not appear in address string"
Exemplo n.º 3
0
def test_stacked_tax_taxful_price():
    shop = get_shop(prices_include_tax=True, currency='EUR')
    source = OrderSource(shop)
    assert source.prices_include_tax
    source.add_line(type=OrderLineType.OTHER,
                    quantity=1,
                    base_unit_price=source.create_price(20))
    with override_provides("tax_module", TAX_MODULE_SPEC):
        with override_settings(SHOOP_TAX_MODULE="irvine"):
            source.shipping_address = Address(
                street="16215 Alton Pkwy",
                postal_code="92602",
            )
            line = source.get_final_lines(with_taxes=True)[0]
            assert isinstance(line, SourceLine)
            assert line.taxes
            assert line.taxful_price == TaxfulPrice(20, 'EUR')
            assert_almost_equal(line.taxless_price,
                                TaxlessPrice("18.518518", 'EUR'))
            source.uncache()

            # Let's move out to a taxless location.
            source.shipping_address.postal_code = "11111"
            line = source.get_final_lines(with_taxes=True)[0]
            assert isinstance(line, SourceLine)
            assert not line.taxes
            assert line.taxful_price == TaxfulPrice(20, source.currency)
            assert line.taxless_price.value == Decimal("20")
Exemplo n.º 4
0
def test_stacked_tax_taxless_price():
    source = OrderSource(get_shop(prices_include_tax=False))
    assert source.prices_include_tax is False
    source.add_line(type=OrderLineType.OTHER,
                    quantity=1,
                    base_unit_price=source.create_price(10))
    with override_provides("tax_module", TAX_MODULE_SPEC):
        with override_settings(SHOOP_TAX_MODULE="irvine"):
            source.shipping_address = Address(
                street="16215 Alton Pkwy",
                postal_code="92602",
            )
            line = source.get_final_lines(with_taxes=True)[0]
            assert isinstance(line, SourceLine)
            assert line.taxes
            assert line.taxful_price.value == Decimal("10.800")
            source.uncache()

            # Let's move out to a taxless location.
            source.shipping_address.postal_code = "11111"
            line = source.get_final_lines(with_taxes=True)[0]
            assert isinstance(line, SourceLine)
            assert not line.taxes
            assert line.taxful_price.value == Decimal("10")
Exemplo n.º 5
0
def get_address(**overrides):
    data = dict(DEFAULT_ADDRESS_DATA, **overrides)
    return Address(**data)
Exemplo n.º 6
0
def test_partial_address_fails():
    address = Address(
        name=u"Dog Hello"
    )
    with pytest.raises(ValidationError):
        address.full_clean()