本文整理汇总了Python中shuup.testing.factories.get_default_supplier函数的典型用法代码示例。如果您正苦于以下问题:Python get_default_supplier函数的具体用法?Python get_default_supplier怎么用?Python get_default_supplier使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_default_supplier函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_copy_order_to_basket
def test_copy_order_to_basket(admin_user, settings):
configure(settings)
shop = factories.get_default_shop()
basket = factories.get_basket()
p1 = factories.create_product("test", shop=shop, supplier=factories.get_default_supplier())
order = factories.create_order_with_product(factories.get_default_product(), factories.get_default_supplier(), 2, 10, shop=shop)
factories.add_product_to_order(order, factories.get_default_supplier(), p1, 2, 5)
order.customer = get_person_contact(admin_user)
order.save()
client = _get_client(admin_user)
payload = {
"order": order.pk
}
response = client.post('/api/shuup/basket/{}-{}/add_from_order/'.format(shop.pk, basket.key), payload)
assert response.status_code == status.HTTP_200_OK
response_data = json.loads(response.content.decode("utf-8"))
assert len(response_data["items"]) == 2
assert not response_data["validation_errors"]
basket.refresh_from_db()
assert len(basket.data["lines"]) == 2
# do it again, basket should clear first then read items
payload = {
"order": order.pk
}
response = client.post('/api/shuup/basket/{}-{}/add_from_order/'.format(shop.pk, basket.key), payload)
assert response.status_code == status.HTTP_200_OK
response_data = json.loads(response.content.decode("utf-8"))
assert len(response_data["items"]) == 2
assert not response_data["validation_errors"]
basket.refresh_from_db()
assert len(basket.data["lines"]) == 2
开发者ID:suutari-ai,项目名称:shuup,代码行数:32,代码来源:test_basket_api.py
示例2: test_order_creator_account_manager
def test_order_creator_account_manager():
company = create_random_company()
shop = get_shop(identifier="random-shop", enabled=True)
source = seed_source(create_random_user(), shop)
source.customer = company
source.add_line(
type=OrderLineType.PRODUCT,
product=get_default_product(),
supplier=get_default_supplier(),
quantity=1,
base_unit_price=source.create_price(10),
)
creator = OrderCreator()
order = creator.create_order(source)
assert order.account_manager is None # Company contact doesn't have account manager field
person = create_random_person()
person.account_manager = create_random_person()
person.save()
source = seed_source(create_random_user(), shop)
source.customer = person
source.add_line(
type=OrderLineType.PRODUCT,
product=get_default_product(),
supplier=get_default_supplier(),
quantity=1,
base_unit_price=source.create_price(10),
)
creator = OrderCreator()
order = creator.create_order(source)
assert order.account_manager is not None
assert order.account_manager == person.account_manager
with pytest.raises(ProtectedError):
person.account_manager.delete()
开发者ID:ruqaiya,项目名称:shuup,代码行数:35,代码来源:test_order_creator.py
示例3: get_frontend_order_state
def get_frontend_order_state(contact, valid_lines=True):
"""
Get a dict structure mirroring what the frontend JavaScript would submit.
:type contact: Contact|None
"""
translation.activate("en")
shop = get_default_shop()
tax = Tax.objects.create(code="test_code", rate=decimal.Decimal("0.20"), name="Default")
tax_class = TaxClass.objects.create(identifier="test_tax_class", name="Default")
rule = TaxRule.objects.create(tax=tax)
rule.tax_classes.add(tax_class)
rule.save()
product = create_product(
sku=printable_gibberish(),
supplier=get_default_supplier(),
shop=shop
)
product.tax_class = tax_class
product.save()
if valid_lines:
lines = [
{"id": "x", "type": "product", "product": {"id": product.id}, "quantity": "32", "baseUnitPrice": 50},
{"id": "y", "type": "other", "sku": "hello", "text": "A greeting", "quantity": 1, "unitPrice": "5.5"},
{"id": "z", "type": "text", "text": "This was an order!", "quantity": 0},
]
else:
unshopped_product = create_product(sku=printable_gibberish(), supplier=get_default_supplier())
not_visible_product = create_product(
sku=printable_gibberish(),
supplier=get_default_supplier(),
shop=shop
)
not_visible_shop_product = not_visible_product.get_shop_instance(shop)
not_visible_shop_product.visible = False
not_visible_shop_product.save()
lines = [
{"id": "x", "type": "product"}, # no product?
{"id": "x", "type": "product", "product": {"id": unshopped_product.id}}, # not in this shop?
{"id": "y", "type": "product", "product": {"id": -product.id}}, # invalid product?
{"id": "z", "type": "other", "quantity": 1, "unitPrice": "q"}, # what's that price?
{"id": "rr", "type": "product", "quantity": 1, "product": {"id": not_visible_product.id}} # not visible
]
state = {
"customer": {"id": contact.id if contact else None},
"lines": lines,
"methods": {
"shippingMethod": {"id": get_default_shipping_method().id},
"paymentMethod": {"id": get_default_payment_method().id},
},
"shop": {
"selected": {
"id": shop.id,
"name": shop.name,
"currency": shop.currency,
"priceIncludeTaxes": shop.prices_include_tax
}
}
}
return state
开发者ID:andela-kerinoso,项目名称:shuup,代码行数:60,代码来源:test_order_creator.py
示例4: test_processor_orderability
def test_processor_orderability(admin_user):
source = OrderSource(Shop())
processor = OrderProcessor()
line = source.add_line(
type=OrderLineType.PRODUCT,
product=get_default_product(),
supplier=get_default_supplier(),
quantity=1,
shop=get_default_shop(),
base_unit_price=source.create_price(10),
)
line.order = Order(shop=get_default_shop())
assert processor._check_orderability(line) is None
unorderable_line = source.add_line(
type=OrderLineType.PRODUCT,
product=create_product("no-shop"),
supplier=get_default_supplier(),
quantity=1,
shop=get_default_shop(),
base_unit_price=source.create_price(20),
)
unorderable_line.order = Order(shop=get_default_shop())
with pytest.raises(ValidationError) as exc:
processor._check_orderability(unorderable_line)
assert "Not available in" in exc.value.message
开发者ID:ruqaiya,项目名称:shuup,代码行数:26,代码来源:test_order_creator.py
示例5: test_get_orderable_variation_children
def test_get_orderable_variation_children(rf):
supplier = get_default_supplier()
shop = get_default_shop()
variable_name = "Color"
parent = create_product("test-sku-1", shop=shop)
variation_variable = ProductVariationVariable.objects.create(product=parent, identifier="color", name=variable_name)
red_value = ProductVariationVariableValue.objects.create(variable=variation_variable, identifier="red", value="Red")
blue_value =ProductVariationVariableValue.objects.create(variable=variation_variable, identifier="blue", value="Blue")
combinations = list(parent.get_all_available_combinations())
assert len(combinations) == 2
for combo in combinations:
assert not combo["result_product_pk"]
child = create_product("xyz-%s" % combo["sku_part"], shop=shop, supplier=get_default_supplier(), default_price=20)
child.link_to_parent(parent, combination_hash=combo["hash"])
combinations = list(parent.get_all_available_combinations())
assert len(combinations) == 2
parent.refresh_from_db()
assert parent.is_variation_parent()
request = apply_request_middleware(rf.get("/"))
cache.clear()
for time in range(2):
orderable_children, is_orderable = get_orderable_variation_children(parent, request, None)
assert len(orderable_children)
for var_variable, var_values in dict(orderable_children).items():
assert var_variable == variation_variable
assert red_value in var_values
assert blue_value in var_values
开发者ID:ruqaiya,项目名称:shuup,代码行数:30,代码来源:test_utils.py
示例6: test_shipping_table_behavior
def test_shipping_table_behavior(admin_user):
service = get_custom_carrier_service()
component = ShippingTableByModeBehaviorComponent.objects.create(
mode=FetchTableMode.LOWEST_DELIVERY_TIME
)
service.behavior_components.add(component)
source = get_source(admin_user, service)
PRODUCT_WEIGHT = Decimal(700.0) # in grams
PRODUCT_WIDTH = Decimal(340)
PRODUCT_DEPTH = Decimal(320)
PRODUCT_HEIGHT = Decimal(180)
product = get_default_product()
product.gross_weight = PRODUCT_WEIGHT
product.width = PRODUCT_WIDTH
product.depth = PRODUCT_DEPTH
product.height = PRODUCT_HEIGHT
product.save()
source.add_line(
type=OrderLineType.PRODUCT,
product=product,
supplier=get_default_supplier(),
quantity=1,
base_unit_price=source.create_price(10),
)
assert abs((component.get_source_weight(source) * KG_TO_G) - PRODUCT_WEIGHT) < Decimal(0.0001)
# configure cubic usage
component.use_cubic_weight = True
component.cubic_weight_factor = Decimal(6000.0)
component.cubic_weight_exemption = Decimal(3.000)
component.save()
# not using cubic weight because of weight exemption
assert abs((component.get_source_weight(source) * KG_TO_G) - PRODUCT_WEIGHT) < Decimal(0.0001)
source.add_line(
type=OrderLineType.PRODUCT,
product=product,
supplier=get_default_supplier(),
quantity=7,
base_unit_price=source.create_price(10),
)
cubic_weight = (PRODUCT_WIDTH * PRODUCT_DEPTH * (PRODUCT_HEIGHT * 8)) / component.cubic_weight_factor
assert abs((component.get_source_weight(source) * KG_TO_G) - cubic_weight) < Decimal(0.0001)
# set constraints
component.max_package_width = Decimal(1000)
component.max_package_height = Decimal(1000)
component.max_package_length = Decimal(1000)
component.max_package_edges_sum = Decimal(2000)
component.max_package_weight = Decimal(10)
component.save()
cubic_weight = (PRODUCT_WIDTH * PRODUCT_DEPTH * (PRODUCT_HEIGHT * 8)) / component.cubic_weight_factor
assert abs((component.get_source_weight(source) * KG_TO_G) - cubic_weight) < Decimal(0.0001)
开发者ID:rockho-team,项目名称:shuup-shipping-table,代码行数:60,代码来源:test_models.py
示例7: test_product_hightlight_plugin
def test_product_hightlight_plugin(rf, highlight_type, orderable):
shop = get_default_shop()
p1 = create_product("p1", shop, get_default_supplier(), "10")
p2 = create_product("p2", shop, get_default_supplier(), "20")
p3 = create_product("p3", shop, get_default_supplier(), "30")
p4 = create_product("p4", shop, get_default_supplier(), "40")
sp4 = p4.get_shop_instance(shop)
sp4.purchasable = False
sp4.save()
context = get_context(rf)
plugin = ProductHighlightPlugin({
"type": highlight_type,
"count": 4,
"orderable_only": orderable
})
context_products = plugin.get_context_data(context)["products"]
assert p1 in context_products
assert p2 in context_products
assert p3 in context_products
if orderable:
assert p4 not in context_products
else:
assert p4 in context_products
开发者ID:ruqaiya,项目名称:shuup,代码行数:26,代码来源:test_plugins.py
示例8: _create_order
def _create_order(shop, customer):
p1 = factories.create_product("test", shop=shop, supplier=factories.get_default_supplier())
order = factories.create_order_with_product(factories.get_default_product(), factories.get_default_supplier(), 2,
10, shop=shop)
factories.add_product_to_order(order, factories.get_default_supplier(), p1, 2, 5)
order.customer = customer
order.save()
return order
开发者ID:ruqaiya,项目名称:shuup,代码行数:8,代码来源:test_basket_from_order.py
示例9: test_refunds
def test_refunds(browser, admin_user, live_server, settings):
order = create_order_with_product(
get_default_product(), get_default_supplier(), 10, decimal.Decimal("10"), n_lines=10,
shop=get_default_shop())
order2 = create_order_with_product(
get_default_product(), get_default_supplier(), 10, decimal.Decimal("10"), n_lines=10,
shop=get_default_shop())
order2.create_payment(order2.taxful_total_price)
initialize_admin_browser_test(browser, live_server, settings)
_test_toolbar_visibility(browser, live_server, order)
_test_create_full_refund(browser, live_server, order)
_test_refund_view(browser, live_server, order2)
开发者ID:suutari,项目名称:shoop,代码行数:12,代码来源:test_refunds.py
示例10: test_correios_delivery_time_2
def test_correios_delivery_time_2(rf, admin_user):
with patch.object(CorreiosWS, 'get_preco_prazo', return_value=MOCKED_SUCCESS_RESULT):
pac_carrier = get_correios_carrier_2()
contact = get_person_contact(admin_user)
p1 = create_product(sku='p1',
supplier=get_default_supplier(),
width=400,
depth=400,
height=400,
gross_weight=1250)
# P2 é pesado pacas - é empacotado em uma caixa separada
# só para dar problema na metade da entrega
p2 = create_product(sku='p2',
supplier=get_default_supplier(),
width=400,
depth=400,
height=400,
gross_weight=31250)
source = seed_source(admin_user)
source.add_line(
type=OrderLineType.PRODUCT,
product=p1,
supplier=get_default_supplier(),
quantity=2,
base_unit_price=source.create_price(10))
source.add_line(
type=OrderLineType.PRODUCT,
product=p2,
supplier=get_default_supplier(),
quantity=1,
base_unit_price=source.create_price(20))
billing_address = get_address()
shipping_address = get_address(name="My House", country='BR')
shipping_address.postal_code = "89070210"
source.billing_address = billing_address
source.shipping_address = shipping_address
source.customer = contact
shipping = ShippingMethod.objects.filter(carrier=pac_carrier).first()
bc = shipping.behavior_components.first()
packages = bc._pack_source(source)
assert len(packages) == 3
results = bc._get_correios_results(source, packages)
assert len(results) == 3
开发者ID:rockho-team,项目名称:shuup-correios,代码行数:50,代码来源:test_methods.py
示例11: test_product_from_category_plugin
def test_product_from_category_plugin(rf):
shop = get_default_shop()
category1 = get_default_category()
category2 = CategoryFactory(status=CategoryStatus.VISIBLE)
category1.shops.add(shop)
category2.shops.add(shop)
p1 = create_product("p1", shop, get_default_supplier(), "10")
p2 = create_product("p2", shop, get_default_supplier(), "20")
p3 = create_product("p3", shop, get_default_supplier(), "30")
sp1 = p1.get_shop_instance(shop)
sp2 = p2.get_shop_instance(shop)
sp3 = p3.get_shop_instance(shop)
sp1.categories.add(category1)
sp2.categories.add(category1)
sp3.categories.add(category2)
context = get_context(rf)
plugin = ProductsFromCategoryPlugin({
"category": category1.pk
})
context_products = plugin.get_context_data(context)["products"]
assert p1 in context_products
assert p2 in context_products
assert p3 not in context_products
# test the plugin form
with override_current_theme_class(None):
theme = get_current_theme(get_default_shop())
cell = LayoutCell(theme, ProductsFromCategoryPlugin.identifier, sizes={"md": 8})
lcfg = LayoutCellFormGroup(layout_cell=cell, theme=theme, request=apply_request_middleware(rf.get("/")))
assert not lcfg.is_valid()
lcfg = LayoutCellFormGroup(
data={
"general-cell_width": "8",
"general-cell_align": "pull-right",
"plugin-count": 4,
"plugin-category": category2.pk
},
layout_cell=cell,
theme=theme,
request=apply_request_middleware(rf.get("/"))
)
assert lcfg.is_valid()
lcfg.save()
assert cell.config["category"] == str(category2.pk)
开发者ID:ruqaiya,项目名称:shuup,代码行数:50,代码来源:test_plugins.py
示例12: test_order_received
def test_order_received(rf, regular_user):
activate("en")
get_default_product()
get_default_supplier()
get_test_script("test script", "order_received")
template_data = STEP_DATA[0]["actions"][0]["template_data"]
for lang in ["en", "fi"]:
n_outbox_pre = len(mail.outbox)
customer = create_random_person(locale=lang)
create_random_order(customer)
assert (len(mail.outbox) == n_outbox_pre + 1), "Sending email failed"
latest_mail = mail.outbox[-1]
assert latest_mail.subject == template_data[lang]["subject"], "Subject doesn't match"
assert latest_mail.body == template_data[lang]["body"], "Body doesn't match"
开发者ID:ruqaiya,项目名称:shuup,代码行数:15,代码来源:test_order_notifications.py
示例13: test_complex_import
def test_complex_import():
filename = "complex_import.xlsx"
activate("en")
shop = get_default_shop()
get_default_tax_class()
get_default_product_type()
get_default_supplier()
get_default_sales_unit()
path = os.path.join(os.path.dirname(__file__), "data", "product", filename)
transformed_data = transform_file(filename.split(".")[1], path)
importer = ProductImporter(transformed_data, shop, "en")
importer.process_data()
assert len(importer.unmatched_fields) == 0
importer.do_import(ImportMode.CREATE_UPDATE)
products = importer.new_objects
assert len(products) == 6
assert ShopProduct.objects.count() == 6
assert Category.objects.count() == 11
assert Manufacturer.objects.count() == 4
for idx, product in enumerate(Product.objects.all().order_by("sku")):
shop_product = product.get_shop_instance(shop)
data = PRODUCT_DATA[idx]
assert product.sku == data["sku"]
assert product.name == data["name"]
assert shop_product.default_price_value == Decimal(data["price"])
assert product.description == data["description"]
if data.get("categories"):
all_cats = set(data["categories"])
all_cats.add(data["category"])
for cat in shop_product.categories.all():
assert cat.name in all_cats
assert shop_product.categories.count() == len(all_cats) # also add primary category
if data.get("category"):
assert shop_product.primary_category.name == data["category"]
assert force_text(shop_product.visibility.label) == data["visibility"].lower()
assert product.tax_class.name == data["tax_class"]
if data.get("manufacturer"):
assert product.manufacturer.name == data["manufacturer"]
开发者ID:ruqaiya,项目名称:shuup,代码行数:48,代码来源:test_product_import.py
示例14: test_sales_between_ranges
def test_sales_between_ranges():
shop = get_default_shop()
supplier = get_default_supplier()
person = create_random_person()
initial_group_count = person.groups.count()
sales_ranges = [
("wood", 15, 0),
("silver", 0, 50),
("diamond", 100, None)
]
for identifier, min, max in sales_ranges:
create_sales_range(identifier, shop, min, max)
payment = create_fully_paid_order(shop, person, supplier, "sku1", 10)
assert get_total_sales(shop, person) == 10
update_customers_groups(Payment, payment)
assert person.groups.count() == (initial_group_count + 1)
assert bool([group for group in person.groups.all() if group.identifier == "silver"])
assert not bool([group for group in person.groups.all() if group.identifier == "wood"])
payment = create_fully_paid_order(shop, person, supplier, "sku2", 50)
assert get_total_sales(shop, person) == 60
update_customers_groups(Payment, payment)
assert person.groups.count() == initial_group_count
assert not bool([group for group in person.groups.all() if group.identifier in ["silver", "gold", "diamond"]])
payment = create_fully_paid_order(shop, person, supplier, "sku3", 200)
assert get_total_sales(shop, person) == 260
update_customers_groups(Payment, payment)
assert person.groups.count() == (initial_group_count + 1)
assert bool([group for group in person.groups.all() if group.identifier == "diamond"])
开发者ID:ruqaiya,项目名称:shuup,代码行数:31,代码来源:test_sales_ranges.py
示例15: test_min_amount_is_not_included
def test_min_amount_is_not_included():
shop = get_default_shop()
supplier = get_default_supplier()
person = create_random_person()
initial_group_count = person.groups.count()
sales_ranges = [
("silver", 0, 50),
("gold", 50, 100),
("diamond", 100, 1000),
("reverse_diamond", 1000, 100)
]
for identifier, min, max in sales_ranges:
create_sales_range(identifier, shop, min, max)
payment = create_fully_paid_order(shop, person, supplier, "sku1", 50)
assert get_total_sales(shop, person) == 50
update_customers_groups(Payment, payment)
assert person.groups.count() == (initial_group_count + 1)
assert bool([group for group in person.groups.all() if group.identifier == "gold"])
assert not bool([group for group in person.groups.all() if group.identifier in ["silver", "diamond"]])
payment = create_fully_paid_order(shop, person, supplier, "sku2", 50)
assert get_total_sales(shop, person) == 100
update_customers_groups(Payment, payment)
assert person.groups.count() == (initial_group_count + 1)
assert bool([group for group in person.groups.all() if group.identifier == "diamond"])
assert not bool([group for group in person.groups.all() if group.identifier == "reverse_diamond"])
assert not bool([group for group in person.groups.all() if group.identifier in ["silver", "gold"]])
开发者ID:ruqaiya,项目名称:shuup,代码行数:28,代码来源:test_sales_ranges.py
示例16: test_mass_edit_orders3
def test_mass_edit_orders3(rf, admin_user):
shop = get_default_shop()
supplier = get_default_supplier()
contact1 = create_random_person()
product1 = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price="50")
product2 = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price="501")
order1 = create_random_order(customer=contact1,
products=[product1, product2],
completion_probability=0)
order2 = create_random_order(customer=contact1,
products=[product1, product2],
completion_probability=0)
assert order1.status.role != OrderStatusRole.CANCELED
assert order2.status.role != OrderStatusRole.CANCELED
payload = {
"action": OrderConfirmationPdfAction().identifier,
"values": [order1.pk, order2.pk]
}
request = apply_request_middleware(rf.post(
"/",
user=admin_user,
))
request._body = json.dumps(payload).encode("UTF-8")
view = OrderListView.as_view()
response = view(request=request)
assert response.status_code == 200
if weasyprint:
assert response['Content-Disposition'] == 'attachment; filename=order_confirmation_pdf.zip'
else:
assert response["content-type"] == "application/json"
开发者ID:gurch101,项目名称:shuup,代码行数:33,代码来源:test_order_mass_actions.py
示例17: test_best_selling_products_with_multiple_orders
def test_best_selling_products_with_multiple_orders():
context = get_jinja_context()
supplier = get_default_supplier()
shop = get_default_shop()
n_products = 2
price = 10
product_1 = create_product("test-sku-1", supplier=supplier, shop=shop)
product_2 = create_product("test-sku-2", supplier=supplier, shop=shop)
create_order_with_product(product_1, supplier, quantity=1, taxless_base_unit_price=price, shop=shop)
create_order_with_product(product_2, supplier, quantity=1, taxless_base_unit_price=price, shop=shop)
cache.clear()
# Two initial products sold
assert product_1 in general.get_best_selling_products(context, n_products=n_products)
assert product_2 in general.get_best_selling_products(context, n_products=n_products)
product_3 = create_product("test-sku-3", supplier=supplier, shop=shop)
create_order_with_product(product_3, supplier, quantity=2, taxless_base_unit_price=price, shop=shop)
cache.clear()
# Third product sold in greater quantity
assert product_3 in general.get_best_selling_products(context, n_products=n_products)
create_order_with_product(product_1, supplier, quantity=4, taxless_base_unit_price=price, shop=shop)
create_order_with_product(product_2, supplier, quantity=4, taxless_base_unit_price=price, shop=shop)
cache.clear()
# Third product outsold by first two products
assert product_3 not in general.get_best_selling_products(context, n_products=n_products)
children = [create_product("SimpleVarChild-%d" % x, supplier=supplier, shop=shop) for x in range(5)]
for child in children:
child.link_to_parent(product_3)
create_order_with_product(child, supplier, quantity=1, taxless_base_unit_price=price, shop=shop)
cache.clear()
# Third product now sold in greatest quantity
assert product_3 == general.get_best_selling_products(context, n_products=n_products)[0]
开发者ID:suutari,项目名称:shoop,代码行数:35,代码来源:test_general_template_helpers.py
示例18: test_productfilter_works
def test_productfilter_works(rf):
request, shop, group = initialize_test(rf, False)
price = shop.create_price
product_price = "100"
discount_percentage = "0.30"
supplier = get_default_supplier()
product = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price=product_price)
shop_product = product.get_shop_instance(shop)
# create catalog campaign
catalog_filter = ProductFilter.objects.create()
catalog_filter.products.add(product)
assert catalog_filter.matches(shop_product)
catalog_campaign = CatalogCampaign.objects.create(shop=shop, active=True, name="test")
catalog_campaign.filters.add(catalog_filter)
cdp = ProductDiscountPercentage.objects.create(campaign=catalog_campaign, discount_percentage=discount_percentage)
# add product to basket
basket = get_basket(request)
basket.add_product(supplier=supplier, shop=shop, product=product, quantity=1)
basket.shipping_method = get_shipping_method(shop=shop)
basket.save()
expected_total = price(product_price) - (Decimal(discount_percentage) * price(product_price))
assert basket.total_price == expected_total
开发者ID:gurch101,项目名称:shuup,代码行数:28,代码来源:test_filters.py
示例19: test_mass_edit_orders
def test_mass_edit_orders(rf, admin_user):
shop = get_default_shop()
supplier = get_default_supplier()
contact1 = create_random_person()
product1 = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price="50")
product2 = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price="501")
order = create_random_order(customer=contact1,
products=[product1, product2],
completion_probability=0)
assert order.status.role != OrderStatusRole.CANCELED
payload = {
"action": CancelOrderAction().identifier,
"values": [order.pk]
}
request = apply_request_middleware(rf.post(
"/",
user=admin_user,
))
request._body = json.dumps(payload).encode("UTF-8")
view = OrderListView.as_view()
response = view(request=request)
assert response.status_code == 200
for order in Order.objects.all():
assert order.status.role == OrderStatusRole.CANCELED
开发者ID:gurch101,项目名称:shuup,代码行数:26,代码来源:test_order_mass_actions.py
示例20: test_discounted_price
def test_discounted_price(rf):
shop = factories.get_default_shop()
supplier = factories.get_default_supplier()
request = rf.get("/")
request.shop = shop
apply_request_middleware(request)
assert request.shop == shop
original_price = 10
product = factories.create_product("test1", shop=shop, supplier=supplier, default_price=original_price)
shop_product = product.get_shop_instance(shop)
# Set discount with discount amount for $2
discount_amount = 2
discount = Discount.objects.create(
active=True, product=product, supplier=supplier, discount_amount_value=discount_amount)
discount.shops = [shop]
# Even though the supplier is matching with the product there is no discount
# since the supplier is not in pricing context.
assert not hasattr(request, "supplier")
assert supplier in shop_product.suppliers.all()
assert product.get_price_info(request).price == request.shop.create_price(10)
setattr(request, "supplier", supplier)
assert product.get_price_info(request).price == request.shop.create_price(8)
# No discount once we change the discount supplier
new_supplier = Supplier.objects.create(identifier="*")
discount.supplier = new_supplier
discount.save()
assert product.get_price_info(request).price == request.shop.create_price(10)
开发者ID:ruqaiya,项目名称:shuup,代码行数:32,代码来源:test_supplier_discounts.py
注:本文中的shuup.testing.factories.get_default_supplier函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论