def test_contact_group_basket_condition_with_none(rf): request = rf.get("/") request.shop = Shop() basket = get_basket(request) condition = ContactGroupBasketCondition.objects.create() result = condition.matches(basket) # Should not raise any errors assert result is False
def test_codes_type_conversion(): source = OrderSource(Shop()) assert source.codes == [] with pytest.raises(AttributeError): source.codes = "test" assert source.codes == [] source.add_code("t") source.add_code("e") source.add_code("s") assert source.codes == ["t", "e", "s"] was_added = source.add_code("t") assert was_added is False assert source.codes == ["t", "e", "s"] was_cleared = source.clear_codes() assert was_cleared assert source.codes == [] was_cleared = source.clear_codes() assert not was_cleared source.add_code("test") source.add_code(1) source.add_code("1") assert source.codes == ["test", "1"]
def _get_template_engine_and_context(): engine = django.template.engines['jinja2'] assert isinstance(engine, django_jinja.backend.Jinja2) request = RequestFactory().get('/') request.shop = Shop(currency='USD', prices_include_tax=False) request.customer = AnonymousContact() request.person = request.customer context = { 'request': request, 'prod': Product(sku='6.0745'), # TODO: Test also with variant products 'sline': _get_source_line(request), 'bline': _get_basket_line(request), 'oline': _get_order_line(request), } return (engine, context)
def test_pricing_module_is_active(): """ Make sure that our custom pricing module is active. """ shop = Shop(currency='USD', prices_include_tax=False) customer = AnonymousContact() product = Product(sku='6.0745') pricing_mod = get_pricing_module() pricing_ctx = pricing_mod.get_context_from_data(shop, customer) pi = product.get_price_info(pricing_ctx, quantity=2) price = shop.create_price assert pi.price == price('12.149') assert pi.base_price == price('48.596') assert pi.quantity == 2 assert pi.discounted_unit_price == price('6.0745') assert pi.base_unit_price == price('24.298') assert pi.discount_rate == Decimal('0.75')
def test_invalid_source_line_updating(): source = OrderSource(Shop()) with pytest.raises(TypeError): # Test forbidden keys SourceLine(source).update({"update": True})
def test_invalid_order_source_updating(): with pytest.raises(ValueError): # Test nonexisting key updating OrderSource(Shop()).update(__totes_not_here__=True)
def get_request(): request = RequestFactory().get('/') request.shop = Shop(currency='USD', prices_include_tax=False) request.customer = AnonymousContact() request.person = request.customer