예제 #1
0
def test_product_add_with_product_set_variants(client, web2py):
    """
        Add all variants when adding a product with a product set
    """
    from populate_os_tables import populate_shop_products_sets
    populate_shop_products_sets(web2py, options=True, values=True)

    url = '/shop_manage/product_add'
    client.get(url)
    assert client.status == 200

    data = {
        'Name': 'Grapefruit',
        'Description': 'Also great as juice',
        'Visibility': 'in_stock',
        'shop_products_sets_id': 1,
    }

    client.post(url, data=data)
    assert client.status == 200
    assert web2py.db(web2py.db.shop_products).count() == 1

    # Make sure the first variant is the default, by default
    variant = web2py.db.shop_products_variants(1)
    assert variant.DefaultVariant == True

    # All variants created?
    assert web2py.db(web2py.db.shop_products_variants).count() == 2
예제 #2
0
def test_products_sets_options_delete(client, web2py):
    """
        Can we delete an option?
    """
    from populate_os_tables import populate_shop_products_sets
    populate_shop_products_sets(web2py, options=True)

    url = '/shop_manage/products_sets_options_delete?spsoID=1'
    client.get(url)
    assert client.status == 200

    assert web2py.db(web2py.db.shop_products_sets_options).count() == 0
예제 #3
0
def test_products_set_delete(client, web2py):
    """
        Can we delete a product set?
    """
    from populate_os_tables import populate_shop_products_sets
    populate_shop_products_sets(web2py)

    url = '/shop_manage/products_set_delete?spsID=1'
    client.get(url)
    assert client.status == 200

    query = (web2py.db.shop_products_sets.id)
    assert web2py.db(query).count() == 0
예제 #4
0
def test_products_sets(client, web2py):
    """
        Is the products_sets page listing products_sets?
    """
    from populate_os_tables import populate_shop_products_sets
    populate_shop_products_sets(web2py)

    assert web2py.db(web2py.db.shop_products_sets).count() == 1

    url = '/shop_manage/products_sets'
    client.get(url)
    assert client.status == 200

    products_set = web2py.db.shop_products_sets(1)
    assert products_set.Name in client.text
예제 #5
0
def test_products_set_options(client, web2py):
    """
        Are options and values in a set listed correctly
    """
    from populate_os_tables import populate_shop_products_sets
    populate_shop_products_sets(web2py, options=True, values=True)

    url = '/shop_manage/products_set_options?spsID=1'
    client.get(url)
    assert client.status == 200

    option = web2py.db.shop_products_sets_options(1)
    value = web2py.db.shop_products_sets_options_values(1)

    assert option.Name in client.text
    assert value.Name in client.text
예제 #6
0
def test_products_set_options_add(client, web2py):
    """
        Can we add an options?
    """
    from populate_os_tables import populate_shop_products_sets
    populate_shop_products_sets(web2py)

    url = '/shop_manage/products_set_options?spsID=1'
    client.get(url)
    assert client.status == 200

    data = {'Name': 'Banana'}
    client.post(url, data=data)
    assert client.status == 200

    assert web2py.db(web2py.db.shop_products_sets_options).count() == 1
    assert data['Name'] in client.text
예제 #7
0
def test_product_variants_with_products_set(client, web2py):
    """
        Is the delete message saying "disable" for products with a set?
    """
    from populate_os_tables import populate_shop_products_sets
    from populate_os_tables import populate_shop_products_variants
    populate_shop_products_sets(web2py)
    populate_shop_products_variants(web2py)

    product = web2py.db.shop_products(1)
    product.shop_products_sets_id = 1
    product.update_record()
    web2py.db.commit()

    url = '/shop_manage/product_variants?spID=1'
    client.get(url)
    assert client.status == 200

    assert "Do you really want to disable this variant" in client.text
    assert '<a class="btn btn-default btn-sm" href="/shop_manage/product_variant_add?spID=2" id="" style="" target="" title=""><span class="fa fa-plus"></span> Add</a>' not in client.text
예제 #8
0
def test_products_set_options_value_add(client, web2py):
    """
        Can we add an option value?
    """
    from populate_os_tables import populate_shop_products_sets
    populate_shop_products_sets(web2py, options=True)

    url = '/shop_manage/products_set_options?spsID=1'
    client.get(url)
    assert client.status == 200

    data = {
        'shop_products_sets_options_id': 1,
        'Name': 'Banana Value',
        '_formname': 'shop_products_sets_options_values/None'
    }
    client.post(url, data=data)
    assert client.status == 200

    assert web2py.db(web2py.db.shop_products_sets_options_values).count() == 1
    assert data['Name'] in client.text
예제 #9
0
def test_products_set_edit(client, web2py):
    """
        Can we edit a products_set?
    """
    from populate_os_tables import populate_shop_products_sets
    populate_shop_products_sets(web2py)

    url = '/shop_manage/products_set_edit?spsID=1'
    client.get(url)
    assert client.status == 200

    data = {
        'id': '1',
        'Name': 'Grapefruit',
        'Description': 'Also great as juice'
    }

    client.post(url, data=data)
    assert client.status == 200

    products_set = web2py.db.shop_products_sets(1)
    assert products_set.Name == data['Name']
예제 #10
0
def test_product_variant_add_with_products_set(client, web2py):
    """
        We shouldn't be allowed to add a variant to a product with a set
    """
    from populate_os_tables import populate_shop_products
    from populate_os_tables import populate_tax_rates
    from populate_os_tables import populate_shop_products_sets
    populate_shop_products_sets(web2py)
    populate_shop_products(web2py)
    populate_tax_rates(web2py)

    product = web2py.db.shop_products(1)
    product.shop_products_sets_id = 1
    product.update_record()
    web2py.db.commit()
    assert web2py.db(web2py.db.shop_products).count() == 1

    url = '/shop_manage/product_variant_add?spID=1'
    client.get(url)
    assert client.status == 200

    assert "Unable to add" in client.text