@pytest.mark.django_db
@pytest.mark.parametrize(u'address, expected_taxes', EXPECTED_TAXES_BY_ADDRESS)
def test_module(address, expected_taxes):
 shop = get_shop(prices_include_tax=False, currency=u'USD')
 product = create_product(u'PROD', shop=shop, default_price=1000)
 price = product.get_shop_instance(shop).default_price
 for ruledef in shuffled(TAX_RULE_DEFS):
  rule = ruledef.get_tax_rule()
  rule.tax.save()
  rule.tax = rule.tax
  rule.save()
  rule.tax_classes.add(product.tax_class)
 assert (TaxRule.objects.count() == len(TAX_RULE_DEFS))
 with override_settings(SHUUP_TAX_MODULE=u'default_tax'):
  module = get_tax_module()
  assert isinstance(module, DefaultTaxModule)
  context = TaxingContext(location=address)
  taxed_price = module.get_taxed_price_for(context, product, price)
  expected_codes = set(sum([x.split() for x in expected_taxes], []))
  assert (set((x.tax.code for x in taxed_price.taxes)) == expected_codes)
  expected_tax = Money(TAX_AMOUNTS[expected_taxes], u'USD')
  assert (taxed_price.taxful.amount == (price.amount + expected_tax))
 TaxRule.objects.all().delete()

@ pytest . mark . django_db @ pytest . mark . parametrize ( u'address, expected_taxes' , EXPECTED_TAXES_BY_ADDRESS ) def test_module ( address , expected_taxes ) : shop = get_shop ( prices_include_tax = False , currency = u'USD' ) product = create_product ( u'PROD' , shop = shop , default_price = 1000 ) price = product . get_shop_instance ( shop ) . default_price for ruledef in shuffled ( TAX_RULE_DEFS ) : rule = ruledef . get_tax_rule ( ) rule . tax . save ( ) rule . tax = rule . tax rule . save ( ) rule . tax_classes . add ( product . tax_class ) assert ( TaxRule . objects . count ( ) == len ( TAX_RULE_DEFS ) ) with override_settings ( SHUUP_TAX_MODULE = u'default_tax' ) : module = get_tax_module ( ) assert isinstance ( module , DefaultTaxModule ) context = TaxingContext ( location = address ) taxed_price = module . get_taxed_price_for ( context , product , price ) expected_codes = set ( sum ( [ x . split ( ) for x in expected_taxes ] , [ ] ) ) assert ( set ( ( x . tax . code for x in taxed_price . taxes ) ) == expected_codes ) expected_tax = Money ( TAX_AMOUNTS [ expected_taxes ] , u'USD' ) assert ( taxed_price . taxful . amount == ( price . amount + expected_tax ) ) TaxRule . objects . all ( ) . delete ( )
helper for running tests .