Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add more test cases

Adam Janik619d4ffeb6c9
diff --git a/tests/test_graphql.py b/tests/test_graphql.py
index 109549806f..2eb1b448bc 100644
--- a/tests/test_graphql.py
+++ b/tests/test_graphql.py
@@ -141,6 +141,34 @@ def test_product_query(admin_client, product_in_stock):
}
}
}
+ purchaseCost{
+ start{
+ gross{
+ amount
+ }
+ }
+ stop{
+ gross{
+ amount
+ }
+ }
+ }
+ priceRange{
+ start{
+ gross{
+ amount
+ }
+ }
+ stop{
+ gross{
+ amount
+ }
+ }
+ }
+ grossMargin {
+ start
+ stop
+ }
}
}
}
@@ -158,6 +186,19 @@ def test_product_query(admin_client, product_in_stock):
assert product_data['url'] == product.get_absolute_url()
gross = product_data['availability']['priceRange']['start']['gross']
assert float(gross['amount']) == float(product.price.amount)
+ from saleor.product.utils import get_availability, get_product_costs_data
+ purchase_cost, gross_margin = get_product_costs_data(product_in_stock)
+ price_range = product_in_stock.get_price_range()
+ assert purchase_cost.start.gross.amount == product_data[
+ 'purchaseCost']['start']['gross']['amount']
+ assert purchase_cost.stop.gross.amount == product_data[
+ 'purchaseCost']['stop']['gross']['amount']
+ assert gross_margin[0] == product_data['grossMargin'][0]['start']
+ assert gross_margin[1] == product_data['grossMargin'][0]['stop']
+ assert price_range.start.gross.amount == product_data[
+ 'priceRange']['start']['gross']['amount']
+ assert price_range.stop.gross.amount == product_data[
+ 'priceRange']['stop']['gross']['amount']
def test_filter_product_by_category(client, product_in_stock):