예제 #1
0
파일: test_form.py 프로젝트: akx/shoop
def test_clear_prices():
    product = _get_test_product()
    # We can clear the prices out, can't we?
    form_data = {}
    frm = SimplePricingForm(product=product, data=form_data, empty_permitted=True)
    frm.full_clean()
    frm.save()
    assert not SimpleProductPrice.objects.filter(product=product).exists()
예제 #2
0
def test_basic_form_sanity():
    shop = get_default_shop()
    group = get_default_customer_group()
    product = _get_test_product()
    frm = SimplePricingForm(product=product, empty_permitted=True)
    assert len(frm.groups) == ContactGroup.objects.count()
    assert len(frm.shops) == Shop.objects.count()

    assert "s_%d_g_%d" % (shop.id, group.id) in frm.fields
예제 #3
0
def test_no_changes_into_form():
    product = _get_test_product()
    shop = get_default_shop()
    frm = SimplePricingForm(product=product, empty_permitted=True)
    # No changes made, right?
    form_data = get_form_data(frm, prepared=True)
    frm = SimplePricingForm(product=product,
                            data=form_data,
                            empty_permitted=True)
    frm.full_clean()
    frm.save()
    assert SimpleProductPrice.objects.get(product=product,
                                          shop=shop).price == 250
예제 #4
0
파일: test_form.py 프로젝트: sidaga/shoop
def test_basic_form_sanity():
    shop = get_default_shop()
    group = get_default_customer_group()
    product = _get_test_product()
    frm = SimplePricingForm(product=product, empty_permitted=True)
    assert len(frm.groups) == 1 + ContactGroup.objects.count()
    assert len(frm.shops) == 1 + Shop.objects.count()
    for shop_id in (0, shop.id):
        for group_id in (0, group.id):
            assert "s_%d_g_%d" % (shop_id, group_id) in frm.fields

    form_data = get_form_data(frm)
    assert form_data["s_%d_g_0" % shop.id] == 250
    assert form_data["s_0_g_0"] == 200
예제 #5
0
def test_clear_prices():
    product = _get_test_product()
    # We can clear the prices out, can't we?
    form_data = {}
    frm = SimplePricingForm(product=product,
                            data=form_data,
                            empty_permitted=True)
    frm.full_clean()
    frm.save()
    assert not SimpleProductPrice.objects.filter(product=product).exists()
예제 #6
0
파일: test_form.py 프로젝트: akx/shoop
def test_no_changes_into_form():
    product = _get_test_product()
    shop = get_default_shop()
    frm = SimplePricingForm(product=product, empty_permitted=True)
    # No changes made, right?
    form_data = get_form_data(frm, prepared=True)
    frm = SimplePricingForm(product=product, data=form_data, empty_permitted=True)
    frm.full_clean()
    frm.save()
    assert SimpleProductPrice.objects.get(product=product, shop=shop).price.value == 250
예제 #7
0
def test_change_shop_price():
    product = _get_test_product()
    shop = get_default_shop()
    group = get_default_customer_group()

    form_field = "s_%d_g_%d" % (shop.id, group.id)

    frm = SimplePricingForm(product=product, empty_permitted=True)
    form_data = get_form_data(frm, prepared=True)
    # Price hike time!
    form_data[form_field] = "4000"
    frm = SimplePricingForm(product=product,
                            data=form_data,
                            empty_permitted=True)
    frm.full_clean()
    frm.save()
    assert SimpleProductPrice.objects.get(product=product,
                                          shop=shop,
                                          group=group).price == 4000

    # Never mind actually, same price for all shops
    form_data[form_field] = ""
    frm = SimplePricingForm(product=product,
                            data=form_data,
                            empty_permitted=True)
    frm.full_clean()
    frm.save()

    assert not SimpleProductPrice.objects.filter(
        product=product, shop=shop, group=group).exists()
예제 #8
0
파일: test_form.py 프로젝트: akx/shoop
def test_change_shop_price():
    product = _get_test_product()
    shop = get_default_shop()
    group = get_default_customer_group()
    price = shop.create_price

    form_field = "s_%d_g_%d" % (shop.id, group.id)

    frm = SimplePricingForm(product=product, empty_permitted=True)
    form_data = get_form_data(frm, prepared=True)
    # Price hike time!
    form_data[form_field] = "4000"
    frm = SimplePricingForm(product=product, data=form_data, empty_permitted=True)
    frm.full_clean()
    frm.save()
    assert SimpleProductPrice.objects.get(product=product, shop=shop, group=group).price == price(4000)

    # Never mind actually, same price for all shops
    form_data[form_field] = ""
    frm = SimplePricingForm(product=product, data=form_data, empty_permitted=True)
    frm.full_clean()
    frm.save()

    assert not SimpleProductPrice.objects.filter(product=product, shop=shop, group=group).exists()
예제 #9
0
파일: test_form.py 프로젝트: charn/shoop
def test_change_shop_price():
    product = _get_test_product()
    shop = get_default_shop()
    frm = SimplePricingForm(product=product, empty_permitted=True)
    form_data = get_form_data(frm, prepared=True)
    # Price hike time!
    form_data["s_%d_g_0" % shop.id] = "4000"
    frm = SimplePricingForm(product=product, data=form_data, empty_permitted=True)
    frm.full_clean()
    frm.save()
    assert SimpleProductPrice.objects.get(product=product, shop=None).price == 200
    assert SimpleProductPrice.objects.get(product=product, shop=shop).price == 4000

    # Never mind actually, same price for all shops
    form_data["s_%d_g_0" % shop.id] = ""
    frm = SimplePricingForm(product=product, data=form_data, empty_permitted=True)
    frm.full_clean()
    frm.save()
    assert SimpleProductPrice.objects.get(product=product, shop=None).price == 200
    assert not SimpleProductPrice.objects.filter(product=product, shop=shop).exists()