Skip to content

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

Merge branch 'master' into add-products-csv-export

IKarbowiak1e6c381b7699
diff --cc .isort.cfg
index e806e422bd,6374636deb..c9fedd8070
--- a/.isort.cfg
+++ b/.isort.cfg
@@@ -1,2 -1,2 +1,2 @@@
[settings]
- known_third_party = PIL,babel,bleach,braintree,celery,dj_database_url,dj_email_url,django,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_django_optimizer,graphene_federation,graphql,graphql_jwt,graphql_relay,html5lib,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,petl,phonenumber_field,phonenumbers,prices,promise,pytest,pytz,razorpay,requests,sentry_sdk,six,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield
-known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_django_optimizer,graphene_federation,graphql,graphql_jwt,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,phonenumber_field,phonenumbers,prices,promise,pytest,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield
++known_third_party = PIL,babel,braintree,celery,dj_database_url,dj_email_url,django,django_countries,django_filters,django_measurement,django_prices,django_prices_openexchangerates,django_prices_vatlayer,draftjs_sanitizer,faker,freezegun,geolite2,google_measurement_protocol,graphene,graphene_django,graphene_django_optimizer,graphene_federation,graphql,graphql_jwt,graphql_relay,html_to_draftjs,i18naddress,jaeger_client,jwt,markdown,measurement,mptt,oauthlib,opentracing,petl,phonenumber_field,phonenumbers,prices,promise,pytest,pytz,razorpay,requests,sentry_sdk,storages,stripe,templated_email,text_unidecode,tqdm,versatileimagefield
diff --cc CHANGELOG.md
index 5502399780,dfa606582a..971384b77e
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -69,13 -69,32 +69,33 @@@ All notable, unreleased changes to thi
- Fix access to order query when request from service account - #5258 by @fowczarek
- Customer shouldn't be able to see draft orders by token - #5259 by @fowczarek
- Customer shouldn't be able to query checkout with another customer - #5268 by @fowczarek
+- Add products csv export - #5255 by @IKarbowiak
- Added integration support of Jaeger Tracing - #5282 by @NyanKiyoshi
- - Customer shouldn't be able to see draft orders by token - #5259 by @fowczarek
+ - Customer shouldn't be able to see draft orders by token - #5259 by @fowczarek
- Return `null` when querying `me` as an anonymous user - #5231 as @maarcingebala
+ - Add `fulfillment created` webhook - @szewczykmira
- Unify saleor metadata - #5178 by @fowczarek
- Add compiled versions of emails to the repository - #5260 by @tomaszszymanski129
-
+ - Add required prop to fields where applicable - #5293 by @dominik-zeglen
+ - Drop get_absolute_url methods - #5299 by @IKarbowiak
+ - Add --force flag to cleardb command - #5302 by @maarcingebala
+ - Require non-empty message in orderAddNote mutation - #5316 by @maarcingebala
+ - Stock management refactor - #5323 by @IKarbowiak
+ - Add discount error codes - #5348 by @IKarbowiak
+ - Add benchmarks to checkout mutations - #5339 by @fowczarek
+ - Add pagination tests - #5363 by @fowczarek
+ - Add ability to assign multiple warehouses in mutations to create/update a shipping zone - #5399 by @fowczarek
+ - Add filter by ids to warehouses query - #5414 by @fowczarek
+ - Add shipping rate price validation - #5411 by @kswiatek92
+ - Remove unused settings and environment variables - #5420 by @maarcingebala
+ - Add product price validation - #5413 by @kswiatek92
+ - Add attribute validation to attributeAssign - #5423 by @kswiatek92
+ - Add possibility to Update/Delete more than one item in metadata - #5446 by @koradon
+ - Check if image exists before validating - #5425 by @kswiatek92
+ - Fix warehouses query not working without id - #5441 by @koradon
+ - Add accountErrors to CreateToken as a required field - #5437 by @koradon
+ - Raise GraphQLError if filter has not valid IDs - #5460 by @gabmartinez
+ - Fix missing accountError when JSONWebTokenError is raised in CreateToken - #5465 by @koradon
## 2.9.0
diff --cc requirements.txt
index 1d221f8e32,e35150bec9..670de828d5
--- a/requirements.txt
+++ b/requirements.txt
@@@ -73,9 -68,8 +68,9 @@@ measurement==3.2.
mpmath==1.1.0
oauthlib==3.1.0
opentracing==2.3.0
+petl==1.3.0
- phonenumberslite==8.11.4
- pillow==7.0.0
+ phonenumberslite==8.12.1
+ pillow==7.1.1
prices==1.0.0
promise==2.3
protobuf==3.11.3
diff --cc requirements_dev.txt
index 5561ff4266,8307d9c15e..e6b52f2efe
--- a/requirements_dev.txt
+++ b/requirements_dev.txt
@@@ -105,13 -101,12 +101,13 @@@ mypy-extensions==0.4.
nodeenv==1.3.5
oauthlib==3.1.0
opentracing==2.3.0
- packaging==20.1
+ packaging==20.3
pathspec==0.7.0
+petl==1.3.0
- phonenumberslite==8.11.4
- pillow==7.0.0
+ phonenumberslite==8.12.1
+ pillow==7.1.1
pluggy==0.13.1
- pre-commit==1.21.0
+ pre-commit==2.2.0
prices==1.0.0
promise==2.3
protobuf==3.11.3
diff --cc saleor/csv/utils/products_data.py
index e45013a797,0000000000..fa31beb027
mode 100644,000000..100644
--- a/saleor/csv/utils/products_data.py
+++ b/saleor/csv/utils/products_data.py
@@@ -1,315 -1,0 +1,315 @@@
+import os
+from collections import ChainMap, defaultdict
+from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, Union
+
+from django.conf import settings
+from django.db.models import F
+
+from ...core.utils import build_absolute_uri
+from ...product.models import ProductVariant
+
+if TYPE_CHECKING:
+ # flake8: noqa
+ from django.db.models import QuerySet
+
+
+class ProductExportFields:
+ """Data structure with fields for product export."""
+
+ PRODUCT_RELATION_FIELDS = [
+ "attribute_value",
+ "attribute_slug",
+ "collections__slug",
+ "image_path",
+ ]
+ WAREHOUSE_FIELDS = [
- "stock__warehouse__slug",
- "stock__quantity",
- "stock__quantity_allocated",
++ "stocks__warehouse__slug",
++ "stocks__quantity",
++ "stocks__quantity_allocated",
+ ]
+ ATTRIBUTE_FIELDS = ["slugs_of_values", "attribute_slug"]
+ PRODUCT_HEADERS_MAPPING = {
+ "product": {
+ "id": "id",
+ "name": "name",
+ "description": "description",
+ "product_type__name": "product type",
+ "category__slug": "category",
+ "is_published": "visible",
+ "price_amount": "price",
+ "product_currency": "product currency",
+ },
+ "product_many_to_many": {"collections": "collections"},
+ "variant": {
+ "sku": "sku",
+ "price_override_amount": "price override",
+ "cost_price_amount": "cost price",
+ "variant_currency": "variant_currency",
+ },
+ "common": {"images": "images"},
+ }
+
+
+def get_products_data(
+ queryset: "QuerySet",
+) -> Tuple[List[Dict[str, Union[str, bool]]], Dict[str, str], List[str]]:
+ export_data, attributes_and_warehouse_headers = prepare_products_data(queryset)
+ csv_headers_mapping = dict(
+ ChainMap(*reversed(ProductExportFields.PRODUCT_HEADERS_MAPPING.values())) # type: ignore
+ )
+ headers = list(csv_headers_mapping.keys()) + attributes_and_warehouse_headers
+ return export_data, csv_headers_mapping, headers
+
+
+def prepare_products_data(
+ queryset: "QuerySet",
+) -> Tuple[List[Dict[str, Union[str, bool]]], List[str]]:
+ """Create data list of products and their variants with fields values.
+
+ It return list with product and variant data which can be used as import to
+ csv writer and list of attribute and warehouse headers.
+ """
+
+ variants_attributes_fields: Set[str] = set()
+ warehouse_fields: Set[str] = set()
+
+ products_with_variants_data = []
+ products_data = queryset.annotate(product_currency=F("currency")).values(
+ *ProductExportFields.PRODUCT_HEADERS_MAPPING["product"].keys()
+ )
+
+ product_relations_data, products_attributes_fields = prepare_product_relations_data(
+ queryset
+ )
+
+ for product_data in products_data:
+ pk = product_data["id"]
+ relations_data = product_relations_data.get(pk, {})
+ data = {**product_data, **relations_data}
+
+ products_with_variants_data.append(data)
+
+ variants_data, *headers = prepare_variants_data(pk)
+ products_with_variants_data.extend(variants_data)
+ variants_attributes_fields.update(headers[0])
+ warehouse_fields.update(headers[1])
+
+ attribute_and_warehouse_headers: list = (
+ sorted(products_attributes_fields)
+ + sorted(variants_attributes_fields)
+ + sorted(warehouse_fields)
+ )
+
+ return products_with_variants_data, attribute_and_warehouse_headers
+
+
+def prepare_product_relations_data(
+ queryset: "QuerySet",
+) -> Tuple[Dict[int, Dict[str, str]], set]:
+ """Prepare data about products relation fields for given queryset.
+
+ It return dict where key is a product pk, value is a dict with relation fields data.
+ It also returns set with attribute headers.
+ """
+
+ product_fields = ProductExportFields.PRODUCT_RELATION_FIELDS + ["pk"]
+ relations_data = queryset.annotate(
+ attribute_value=F("attributes__values__slug"),
+ attribute_slug=F("attributes__assignment__attribute__slug"),
+ image_path=F("images__image"),
+ ).values(*product_fields)
+
+ attributes_headers = set()
+ result_data: Dict[int, dict] = defaultdict(dict)
+ for data in relations_data:
+ pk = data.get("pk")
+ attribute_data = {
+ "slug": data["attribute_slug"],
+ "value": data["attribute_value"],
+ }
+ collection = data.get("collections__slug")
+ image = data.pop("image_path")
+
+ result_data, attribute_header = add_attribute_info_to_data(
+ pk, attribute_data, result_data
+ )
+ if attribute_header:
+ attributes_headers.add(attribute_header)
+
+ result_data = add_image_uris_to_data(pk, image, result_data)
+ result_data = add_collection_info_to_data(pk, collection, result_data)
+
+ result: Dict[int, Dict[str, str]] = {
+ pk: {header: ", ".join(sorted(values)) for header, values in data.items()}
+ for pk, data in result_data.items()
+ }
+ return result, attributes_headers
+
+
+def add_collection_info_to_data(
+ pk: int, collection: str, result_data: Dict[int, dict]
+) -> Dict[int, dict]:
+ """Add collection info to product data.
+
+ This functions adds info about collection to dict with product data.
+ If some collection info already exists in data, collection slug is added
+ to set with other values.
+ It returns updated product data.
+ """
+
+ if collection:
+ header = "collections"
+ if header in result_data[pk]:
+ result_data[pk][header].add(collection) # type: ignore
+ else:
+ result_data[pk][header] = {collection}
+ return result_data
+
+
+def prepare_variants_data(pk: int) -> Tuple[List[dict], set, set]:
+ """Prepare variants data for product with given pk.
+
+ This function gets product pk and prepared data about product's variants.
+ Returned data contains info about variant fields and relations.
+ It also return sets with variant attributes and warehouse headers.
+ """
+ variants = ProductVariant.objects.filter(product__pk=pk).prefetch_related(
+ "images", "attributes"
+ )
+ fields = (
+ ["pk", "image_path"]
+ + list(ProductExportFields.PRODUCT_HEADERS_MAPPING["variant"].keys())
+ + ProductExportFields.ATTRIBUTE_FIELDS
+ + ProductExportFields.WAREHOUSE_FIELDS
+ )
+ variants_data = (
+ variants.annotate(
+ slugs_of_values=F("attributes__values__slug"),
+ attribute_slug=F("attributes__assignment__attribute__slug"),
+ variant_currency=F("currency"),
+ image_path=F("images__image"),
+ )
+ .order_by("sku")
+ .values(*fields)
+ )
+
+ result_data, variant_attributes_headers, warehouse_headers = update_variant_data(
+ variants_data
+ )
+
+ result = [
+ {
+ header: ", ".join(sorted(values)) if isinstance(values, set) else values
+ for header, values in data.items()
+ }
+ for pk, data in result_data.items()
+ ]
+ return result, variant_attributes_headers, warehouse_headers
+
+
+def update_variant_data(
+ variants_data: List[Dict[str, Union[str, int]]]
+) -> Tuple[Dict[int, dict], set, set]:
+ """Update variant data with info about relations fields.
+
+ This function gets dict with variants data and updated it with info
+ about relations fields.
+ It return dict with updated info and sets of attributes and warehouse headers.
+ """
+ variant_attributes_headers = set()
+ warehouse_headers = set()
+ result_data: Dict[int, dict] = defaultdict(dict)
+ for data in variants_data:
+ pk: int = data.pop("pk") # type: ignore
+ attribute_data = {
+ "slug": data.pop("attribute_slug"),
+ "value": data.pop("slugs_of_values"),
+ }
+ warehouse_data = {
- "slug": data.pop("stock__warehouse__slug"),
- "qty": data.pop("stock__quantity"),
- "qty_alc": data.pop("stock__quantity_allocated"),
++ "slug": data.pop("stocks__warehouse__slug"),
++ "qty": data.pop("stocks__quantity"),
++ "qty_alc": data.pop("stocks__quantity_allocated"),
+ }
+ image: str = data.pop("image_path") # type: ignore
+
+ if pk not in result_data:
+ result_data[pk] = data
+
+ result_data, attribute_header = add_attribute_info_to_data(
+ pk, attribute_data, result_data
+ )
+ if attribute_header:
+ variant_attributes_headers.add(attribute_header)
+
+ result_data, headers = add_warehouse_info_to_data(
+ pk, warehouse_data, result_data
+ )
+ if headers:
+ warehouse_headers.update(headers)
+
+ result_data = add_image_uris_to_data(pk, image, result_data)
+
+ return result_data, variant_attributes_headers, warehouse_headers
+
+
+def add_image_uris_to_data(
+ pk: int, image: str, result_data: Dict[int, dict]
+) -> Dict[int, dict]:
+ """Add absolute uri of given image path to product or variant data.
+
+ This function based on given image path creates absolute uri and adds it to dict
+ with variant or product data. If some info about images already exists in data,
+ absolute uri of given image is added to set with other uris.
+ """
+ if image:
+ header = "images"
+ uri = build_absolute_uri(os.path.join(settings.MEDIA_URL, image))
+ if header in result_data[pk]:
+ result_data[pk][header].add(uri)
+ else:
+ result_data[pk][header] = {uri}
+ return result_data
+
+
+def add_attribute_info_to_data(
+ pk: int, attribute_data: Dict[str, Union[str, int]], result_data: Dict[int, dict],
+) -> Tuple[Dict[int, dict], Optional[str]]:
+ """Add info about attribute to variant or product data.
+
+ This functions adds info about attribute to dict with variant or product data.
+ If attribute with given slug already exists in data, attribute value is added
+ to set with values.
+ It returns updated data and attribute header created based on attribute slug.
+ """
+ slug = attribute_data["slug"]
+ header = None
+ if slug:
+ header = f"{slug} (attribute)"
+ if header in result_data[pk]:
+ result_data[pk][header].add(attribute_data["value"]) # type: ignore
+ else:
+ result_data[pk][header] = {attribute_data["value"]}
+ return result_data, header
+
+
+def add_warehouse_info_to_data(
+ pk: int, warehouse_data: Dict[str, Union[str, int]], result_data: Dict[int, dict],
+) -> Tuple[Dict[int, dict], set]:
+ """Add info about stock quantity to variant data.
+
+ This functions adds info about stock quantity and quantity allocated to dict
+ with variant data. It returns updated data and warehouse header created based on
+ warehouse slug.
+ """
+
+ slug = warehouse_data["slug"]
+ warehouse_headers: Set[str] = set()
+ if slug:
+ warehouse_qty_header = f"{slug} (warehouse quantity)"
+ warehouse_qty_alc_header = f"{slug} (warehouse quantity allocated)"
+ if warehouse_qty_header not in result_data[pk]:
+ result_data[pk][warehouse_qty_header] = warehouse_data["qty"]
+ result_data[pk][warehouse_qty_alc_header] = warehouse_data["qty_alc"]
+ warehouse_headers = {warehouse_qty_header, warehouse_qty_alc_header}
+
+ return result_data, warehouse_headers
diff --cc saleor/graphql/api.py
index 37594ba73f,330cf8cf5d..d2be77056e
--- a/saleor/graphql/api.py
+++ b/saleor/graphql/api.py
@@@ -3,15 -3,14 +3,15 @@@ from graphene_federation import build_s
from .account.schema import AccountMutations, AccountQueries
from .checkout.schema import CheckoutMutations, CheckoutQueries
from .core.schema import CoreMutations, CoreQueries
+from .csv.schema import CsvMutations, CsvQueries
from .discount.schema import DiscountMutations, DiscountQueries
- from .extensions.schema import ExtensionsMutations, ExtensionsQueries
-from .plugins.schema import PluginsMutations, PluginsQueries
from .giftcard.schema import GiftCardMutations, GiftCardQueries
from .menu.schema import MenuMutations, MenuQueries
from .meta.schema import MetaMutations
from .order.schema import OrderMutations, OrderQueries
from .page.schema import PageMutations, PageQueries
from .payment.schema import PaymentMutations, PaymentQueries
++from .plugins.schema import PluginsMutations, PluginsQueries
from .product.schema import ProductMutations, ProductQueries
from .shipping.schema import ShippingMutations, ShippingQueries
from .shop.schema import ShopMutations, ShopQueries
@@@ -30,9 -23,8 +24,9 @@@ class Query
AccountQueries,
CheckoutQueries,
CoreQueries,
+ CsvQueries,
DiscountQueries,
- ExtensionsQueries,
+ PluginsQueries,
GiftCardQueries,
MenuQueries,
OrderQueries,
@@@ -53,9 -45,8 +47,9 @@@ class Mutation
AccountMutations,
CheckoutMutations,
CoreMutations,
+ CsvMutations,
DiscountMutations,
- ExtensionsMutations,
+ PluginsMutations,
GiftCardMutations,
MenuMutations,
MetaMutations,
diff --cc saleor/graphql/core/enums.py
index 14c73da006,4d8fe49881..f71e10a80f
--- a/saleor/graphql/core/enums.py
+++ b/saleor/graphql/core/enums.py
@@@ -5,9 -5,7 +5,8 @@@ from ...checkout import error_codes as
from ...core import error_codes as core_error_codes
from ...core.permissions import get_permissions_enum_list
from ...core.weight import WeightUnits
+from ...csv import error_codes as csv_error_codes
- from ...extensions import error_codes as extensions_error_codes
- from ...extensions.plugins.vatlayer import TaxRateType as CoreTaxRateType
+ from ...discount import error_codes as discount_error_codes
from ...giftcard import error_codes as giftcard_error_codes
from ...menu import error_codes as menu_error_codes
from ...order import error_codes as order_error_codes
@@@ -86,10 -86,8 +87,9 @@@ WeightUnitsEnum = graphene.Enum
AccountErrorCode = graphene.Enum.from_enum(account_error_codes.AccountErrorCode)
CheckoutErrorCode = graphene.Enum.from_enum(checkout_error_codes.CheckoutErrorCode)
+CsvErrorCode = graphene.Enum.from_enum(csv_error_codes.CsvErrorCode)
- ExtensionsErrorCode = graphene.Enum.from_enum(
- extensions_error_codes.ExtensionsErrorCode
- )
+ DiscountErrorCode = graphene.Enum.from_enum(discount_error_codes.DiscountErrorCode)
+ PluginErrorCode = graphene.Enum.from_enum(plugin_error_codes.PluginErrorCode)
GiftCardErrorCode = graphene.Enum.from_enum(giftcard_error_codes.GiftCardErrorCode)
MenuErrorCode = graphene.Enum.from_enum(menu_error_codes.MenuErrorCode)
MetadataErrorCode = graphene.Enum.from_enum(core_error_codes.MetadataErrorCode)
diff --cc saleor/graphql/core/types/common.py
index 4defb646b4,d2c61de7b0..3be4f068fe
--- a/saleor/graphql/core/types/common.py
+++ b/saleor/graphql/core/types/common.py
@@@ -5,8 -5,7 +5,8 @@@ from ...translations.enums import Langu
from ..enums import (
AccountErrorCode,
CheckoutErrorCode,
+ CsvErrorCode,
- ExtensionsErrorCode,
+ DiscountErrorCode,
GiftCardErrorCode,
MenuErrorCode,
MetadataErrorCode,
@@@ -50,15 -51,15 +52,19 @@@ class AccountError(Error)
class CheckoutError(Error):
- code = CheckoutErrorCode(description="The error code.")
+ code = CheckoutErrorCode(description="The error code.", required=True)
+
+
+ class DiscountError(Error):
+ code = DiscountErrorCode(description="The error code.", required=True)
+class CsvError(Error):
+ code = CsvErrorCode(description="The error code.")
+
+
class MenuError(Error):
- code = MenuErrorCode(description="The error code.")
+ code = MenuErrorCode(description="The error code.", required=True)
class MetadataError(Error):
diff --cc saleor/graphql/product/filters.py
index 3a52c8d177,23a5d61e58..35f448f4e9
--- a/saleor/graphql/product/filters.py
+++ b/saleor/graphql/product/filters.py
@@@ -11,9 -19,16 +19,15 @@@ from ...search.backends import picke
from ...warehouse.models import Stock
from ..core.filters import EnumFilter, ListObjectTypeFilter, ObjectTypeFilter
from ..core.types import FilterInputObjectType
- from ..core.types.common import PriceRangeInput
+ from ..core.types.common import IntRangeInput, PriceRangeInput
from ..core.utils import from_global_id_strict_type
- from ..utils import filter_by_query_param, get_nodes
+ from ..utils import (
+ filter_by_query_param,
+ filter_range_field,
+ get_nodes,
+ resolve_global_ids_to_primary_keys,
+ )
+ from ..warehouse import types as warehouse_types
-from . import types
from .enums import (
CollectionPublished,
ProductTypeConfigurable,
diff --cc saleor/graphql/schema.graphql
index 3224d95424,311d4b72ef..b073eeeeab
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@@ -1325,22 -1340,10 +1340,22 @@@ type CreditCard
expYear: Int!
}
+type CsvError {
+ field: String
+ message: String
+ code: CsvErrorCode
+}
+
+enum CsvErrorCode {
+ INVALID
+ NOT_FOUND
+ REQUIRED
+}
+
type CustomerBulkDelete {
- errors: [Error!]
+ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
count: Int!
- accountErrors: [AccountError!]
+ accountErrors: [AccountError!]!
}
type CustomerCreate {
@@@ -1616,40 -1634,7 +1646,25 @@@ type Error
message: String
}
+type ExportProducts {
- errors: [Error!]
++ errors: [Error!]! @deprecated(reason: "Use typed errors with error codes. This field will be removed after 2020-07-31.")
+ job: Job
- csvErrors: [CsvError!]
++ csvErrors: [CsvError!]!
+}
+
+input ExportProductsInput {
+ scope: ExportScope!
+ filter: ProductFilterInput
+ ids: [ID!]
+}
+
+enum ExportScope {
+ ALL
+ IDS
+ FILTER
+}
+
- type ExtensionsError {
- field: String
- message: String
- code: ExtensionsErrorCode
- }
-
- enum ExtensionsErrorCode {
- GRAPHQL_ERROR
- INVALID
- PLUGIN_MISCONFIGURED
- NOT_FOUND
- REQUIRED
- UNIQUE
- }
-
- type Fulfillment implements Node, ObjectWithMetadata {
+ type Fulfillment implements Node & ObjectWithMetadata {
id: ID!
fulfillmentOrder: Int!
status: FulfillmentStatus!
diff --cc templates/templated_email/compiled/export_products_csv.html
index 5358312338,0000000000..6a500db654
mode 100644,000000..100644
--- a/templates/templated_email/compiled/export_products_csv.html
+++ b/templates/templated_email/compiled/export_products_csv.html
@@@ -1,405 -1,0 +1,405 @@@
+
+ <!doctype html>
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
+ <head>
+ <title>
+
+ </title>
+ <!--[if !mso]><!-- -->
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <!--<![endif]-->
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <style type="text/css">
+ #outlook a { padding:0; }
+ body { margin:0;padding:0;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%; }
+ table, td { border-collapse:collapse;mso-table-lspace:0pt;mso-table-rspace:0pt; }
+ img { border:0;height:auto;line-height:100%; outline:none;text-decoration:none;-ms-interpolation-mode:bicubic; }
+ p { display:block;margin:13px 0; }
+ </style>
+ <!--[if mso]>
+ <xml>
+ <o:OfficeDocumentSettings>
+ <o:AllowPNG/>
+ <o:PixelsPerInch>96</o:PixelsPerInch>
+ </o:OfficeDocumentSettings>
+ </xml>
+ <![endif]-->
+ <!--[if lte mso 11]>
+ <style type="text/css">
- .outlook-group-fix { width:100% !important; }
++ .mj-outlook-group-fix { width:100% !important; }
+ </style>
+ <![endif]-->
+
+ <!--[if !mso]><!-->
+ <link href="https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700" rel="stylesheet" type="text/css">
+ <style type="text/css">
+ @import url(https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700);
+ </style>
+ <!--<![endif]-->
+
+
+
+ <style type="text/css">
+ @media only screen and (min-width:480px) {
+ .mj-column-per-100 { width:100% !important; max-width: 100%; }
+ }
+ </style>
+
+
+ <style type="text/css">
+
+
+
+ @media only screen and (max-width:480px) {
- table.full-width-mobile { width: 100% !important; }
- td.full-width-mobile { width: auto !important; }
++ table.mj-full-width-mobile { width: 100% !important; }
++ td.mj-full-width-mobile { width: auto !important; }
+ }
+
+ </style>
+ <style type="text/css">address {
+ font-style: inherit;
+ font-family: Ubuntu, Helvetica, Arial;
+ }</style>
+
+ </head>
+ <body>
+
+
- <div style="">
++ <div style>
+ {% load i18n %}{% load static %}
+
+ <!--[if mso | IE]>
+ <table
+ align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"
+ >
+ <tr>
+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
+ <![endif]-->
+
+
+ <div style="margin:0px auto;max-width:600px;">
+
+ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
+ <tbody>
+ <tr>
+ <td style="direction: ltr; font-size: 0px; padding: 20px 0; text-align: center;" align="center">
+ <!--[if mso | IE]>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+
+ <tr>
+
+ <td
+ class="" style="vertical-align:top;width:600px;"
+ >
+ <![endif]-->
+
- <div class="mj-column-per-100 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
++ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
+
+ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
+
+ <tr>
+ <td align="center" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">
+
+ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;">
+ <tbody>
+ <tr>
+ <td style="padding: 5px; width: 176px;" width="176">
+
+ <img height="38" src="{{ logo_url }}" style="border:0;display:block;outline:none;text-decoration:none;height:38px;width:100%;font-size:13px;" width="176">
+
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </td>
+ </tr>
+
+ </table>
+
+ </div>
+
+ <!--[if mso | IE]>
+ </td>
+
+ </tr>
+
+ </table>
+ <![endif]-->
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </div>
+
+
+ <!--[if mso | IE]>
+ </td>
+ </tr>
+ </table>
+
+ <table
+ align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"
+ >
+ <tr>
+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
+ <![endif]-->
+
+
+ <div style="margin:0px auto;max-width:600px;">
+
+ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
+ <tbody>
+ <tr>
+ <td style="direction: ltr; font-size: 0px; padding: 20px 0; text-align: center;" align="center">
+ <!--[if mso | IE]>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+
+ <tr>
+
+ <td
+ class="" style="vertical-align:top;width:600px;"
+ >
+ <![endif]-->
+
- <div class="mj-column-per-100 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
++ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
+
+ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
+
+ <tr>
+ <td align="left" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">
+
+ <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:16px;line-height:1;text-align:left;color:#000000;">{% trans "Hi!" context "Standard e-mail greeting" %}</div>
+
+ </td>
+ </tr>
+
+ <tr>
+ <td align="left" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">
+
+ <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">{% blocktrans context "Export products e-mail text" %}
+ Your CSV file with products data is ready to download: <a href="{{ csv_link }}">{{ csv_link }}</a>
+ {% endblocktrans %}</div>
+
+ </td>
+ </tr>
+
+ </table>
+
+ </div>
+
+ <!--[if mso | IE]>
+ </td>
+
+ </tr>
+
+ </table>
+ <![endif]-->
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </div>
+
+
+ <!--[if mso | IE]>
+ </td>
+ </tr>
+ </table>
+
+ <table
+ align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"
+ >
+ <tr>
+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
+ <![endif]-->
+
+
+ <div style="margin:0px auto;max-width:600px;">
+
+ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
+ <tbody>
+ <tr>
+ <td style="direction: ltr; font-size: 0px; padding: 20px 0; text-align: center;" align="center">
+ <!--[if mso | IE]>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+
+ <tr>
+
+ <td
+ class="" style="vertical-align:top;width:600px;"
+ >
+ <![endif]-->
+
- <div class="mj-column-per-100 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
++ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
+
+ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
+
+ <tr>
+ <td align="left" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">
+
+ <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">{% blocktrans trimmed context "Base email text" %}
+ This is an automatically generated e-mail, please do not reply.
+ {% endblocktrans %}</div>
+
+ </td>
+ </tr>
+
+ </table>
+
+ </div>
+
+ <!--[if mso | IE]>
+ </td>
+
+ </tr>
+
+ </table>
+ <![endif]-->
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </div>
+
+
+ <!--[if mso | IE]>
+ </td>
+ </tr>
+ </table>
+
+ <table
+ align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600"
+ >
+ <tr>
+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
+ <![endif]-->
+
+
+ <div style="background:#F2F2F2;background-color:#F2F2F2;margin:0px auto;max-width:600px;">
+
+ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#F2F2F2;background-color:#F2F2F2;width:100%;">
+ <tbody>
+ <tr>
+ <td style="direction: ltr; font-size: 0px; padding: 20px 0; text-align: center;" align="center">
+ <!--[if mso | IE]>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+
+ <tr>
+
+ <td
+ class="" style="vertical-align:top;width:600px;"
+ >
+ <![endif]-->
+
- <div class="mj-column-per-100 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
++ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
+
+ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
+
+ <tr>
+ <td align="center" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">
+
+ <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:center;color:#000000;">{% blocktrans trimmed context "Base email footer" %}
+ Sincerely, {{ site_name }}
+ {% endblocktrans %}</div>
+
+ </td>
+ </tr>
+
+ </table>
+
+ </div>
+
+ <!--[if mso | IE]>
+ </td>
+
+ </tr>
+
+ </table>
+ <![endif]-->
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </div>
+
+
+ <!--[if mso | IE]>
+ </td>
+ </tr>
+ </table>
+
+ <table
+ align="center" border="0" cellpadding="0" cellspacing="0" class="no-display-outlook" style="width:600px;" width="600"
+ >
+ <tr>
+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
+ <![endif]-->
+
+
+ <div class="no-display" style="display: none; margin: 0px auto; max-width: 600px;">
+
+ <table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
+ <tbody>
+ <tr>
+ <td style="direction: ltr; font-size: 0px; padding: 20px 0; text-align: center;" align="center">
+ <!--[if mso | IE]>
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0">
+
+ <tr>
+
+ <td
+ class="" style="vertical-align:top;width:600px;"
+ >
+ <![endif]-->
+
- <div class="mj-column-per-100 outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
++ <div class="mj-column-per-100 mj-outlook-group-fix" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
+
+ <table border="0" cellpadding="0" cellspacing="0" role="presentation" style="vertical-align:top;" width="100%">
+
+ <tr>
+ <td align="left" style="font-size: 0px; padding: 10px 25px; word-break: break-word;">
+
+ <div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:13px;line-height:1;text-align:left;color:#000000;">{% if schema_markup %}
+ <script type="application/ld+json">{{ schema_markup|safe }}</script>
+ {% endif %}</div>
+
+ </td>
+ </tr>
+
+ </table>
+
+ </div>
+
+ <!--[if mso | IE]>
+ </td>
+
+ </tr>
+
+ </table>
+ <![endif]-->
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ </div>
+
+
+ <!--[if mso | IE]>
+ </td>
+ </tr>
+ </table>
+ <![endif]-->
+
+
+ </div>
+
+ </body>
+ </html>
+
diff --cc tests/test_csv_products_data.py
index 7b442c188f,0000000000..0349ed627c
mode 100644,000000..100644
--- a/tests/test_csv_products_data.py
+++ b/tests/test_csv_products_data.py
@@@ -1,329 -1,0 +1,328 @@@
+from unittest.mock import patch
+
+from saleor.csv.utils.products_data import (
+ ProductExportFields,
+ add_attribute_info_to_data,
+ add_collection_info_to_data,
+ add_image_uris_to_data,
+ add_warehouse_info_to_data,
+ get_products_data,
+ prepare_product_relations_data,
+ prepare_products_data,
+ prepare_variants_data,
+)
+from saleor.product.models import Product, VariantImage
+
+
+@patch("saleor.csv.utils.products_data.prepare_products_data")
+def test_get_products_data(mock_prepare_products_data, product_list):
+ exp_data = [{"test1": "test"}]
+ attr_and_warehouse_headers = ["attr1", "test warehouse", "attr2"]
+ mock_prepare_products_data.return_value = (exp_data, attr_and_warehouse_headers)
+ queryset = Product.objects.all()
+ export_data, csv_headers_mapping, headers = get_products_data(queryset)
+
+ product_headers = ProductExportFields.PRODUCT_HEADERS_MAPPING
+ expected_csv_headers = {
+ **product_headers["product"],
+ **product_headers["product_many_to_many"],
+ **product_headers["variant"],
+ **product_headers["common"],
+ }
+ expected_headers = list(expected_csv_headers.keys()) + attr_and_warehouse_headers
+
+ assert export_data == exp_data
+ assert csv_headers_mapping == expected_csv_headers
+ assert headers == expected_headers
+
+
+def test_prepare_products_data(product, product_with_image, collection, image):
+ collection.products.add(product)
+
+ variant = product.variants.first()
+ VariantImage.objects.create(variant=variant, image=product.images.first())
+
+ products = Product.objects.all()
+ data, headers = prepare_products_data(products)
+
+ expected_data = []
+ expected_headers = set()
+ for product in products.order_by("pk"):
+ product_data = {}
+ product_data["collections"] = (
+ "" if not product.collections.all() else product.collections.first().slug
+ )
+ product_data["name"] = product.name
+ product_data["is_published"] = product.is_published
+ product_data["description"] = product.description
+ product_data["category__slug"] = product.category.slug
+ product_data["price_amount"] = product.price_amount
+ product_data["product_currency"] = product.currency
+ product_data["product_type__name"] = product.product_type.name
+ product_data["id"] = product.pk
+ product_data["images"] = (
+ ""
+ if not product.images.all()
+ else "http://mirumee.com{}".format(product.images.first().image.url)
+ )
+
+ assigned_attribute = product.attributes.first()
+ if assigned_attribute:
+ header = f"{assigned_attribute.attribute.slug} (attribute)"
+ product_data[header] = assigned_attribute.values.first().slug
+ expected_headers.add(header)
+
+ expected_data.append(product_data)
+
+ for variant in product.variants.all():
+ variant_data = {}
+ variant_data["images"] = (
+ ""
+ if not variant.images.all()
+ else "http://mirumee.com{}".format(variant.images.first().image.url)
+ )
+ variant_data["sku"] = variant.sku
+ variant_data["variant_currency"] = variant.currency
+ variant_data["price_override_amount"] = variant.price_override_amount
+ variant_data["cost_price_amount"] = variant.cost_price_amount
+
- for stock in variant.stock.all():
++ for stock in variant.stocks.all():
+ slug = stock.warehouse.slug
+ warehouse_headers = [
+ f"{slug} (warehouse quantity allocated)",
+ f"{slug} (warehouse quantity)",
+ ]
+ variant_data[warehouse_headers[0]] = stock.quantity_allocated
+ variant_data[warehouse_headers[1]] = stock.quantity
+ expected_headers.update(warehouse_headers)
+
+ assigned_attribute = variant.attributes.first()
+ if assigned_attribute:
+ header = f"{assigned_attribute.attribute.slug} (attribute)"
+ variant_data[header] = assigned_attribute.values.first().slug
+ expected_headers.add(header)
+
+ expected_data.append(variant_data)
+
+ assert data == expected_data
+ assert set(headers) == expected_headers
+
+
+def test_prepare_product_relations_data(product_with_image, collection_list):
+ pk = product_with_image.pk
+ collection_list[0].products.add(product_with_image)
+ collection_list[1].products.add(product_with_image)
+ qs = Product.objects.all()
+ result, result_headers = prepare_product_relations_data(qs)
+
+ collections = ", ".join(
+ sorted([collection.slug for collection in collection_list[:2]])
+ )
+ images = ", ".join(
+ [
+ "http://mirumee.com/media/" + image.image.name
+ for image in product_with_image.images.all()
+ ]
+ )
+ expected_result = {pk: {"collections": collections, "images": images}}
+
+ assigned_attribute = product_with_image.attributes.first()
+ if assigned_attribute:
+ header = f"{assigned_attribute.attribute.slug} (attribute)"
+ expected_result[pk][header] = assigned_attribute.values.first().slug
+
+ assert result == expected_result
+
+
+def test_prepare_variants_data(product):
+ variant = product.variants.first()
+
+ warehouse_headers = set()
+ attribute_headers = set()
+
+ expected_result = {
+ "sku": variant.sku,
+ "cost_price_amount": variant.cost_price_amount,
+ "price_override_amount": variant.price_override_amount,
+ "variant_currency": variant.currency,
+ }
+ assigned_attribute = variant.attributes.first()
+ if assigned_attribute:
+ header = f"{assigned_attribute.attribute.slug} (attribute)"
+ expected_result[header] = assigned_attribute.values.first().slug
+ attribute_headers.add(header)
+
- stock = variant.stock
- for stock in variant.stock.all():
++ for stock in variant.stocks.all():
+ slug = stock.warehouse.slug
+ headers = [
+ f"{slug} (warehouse quantity allocated)",
+ f"{slug} (warehouse quantity)",
+ ]
+ expected_result[headers[0]] = stock.quantity_allocated
+ expected_result[headers[1]] = stock.quantity
+ warehouse_headers.update(headers)
+
+ result_data, res_attribute_headers, res_warehouse_headers = prepare_variants_data(
+ product.pk
+ )
+
+ assert result_data == [expected_result]
+ assert res_attribute_headers == attribute_headers
+ assert res_warehouse_headers == warehouse_headers
+
+
+def test_add_collection_info_to_data(product):
+ pk = product.pk
+ collection = "test_collection"
+ input_data = {pk: {}}
+ result = add_collection_info_to_data(product.pk, collection, input_data)
+
+ assert result[pk]["collections"] == {collection}
+
+
+def test_add_collection_info_to_data_update_collections(product):
+ pk = product.pk
+ existing_collection = "test2"
+ collection = "test_collection"
+ input_data = {pk: {"collections": {existing_collection}}}
+ result = add_collection_info_to_data(product.pk, collection, input_data)
+
+ assert result[pk]["collections"] == {collection, existing_collection}
+
+
+def test_add_collection_info_to_data_no_collection(product):
+ pk = product.pk
+ collection = None
+ input_data = {pk: {}}
+ result = add_collection_info_to_data(product.pk, collection, input_data)
+
+ assert result == input_data
+
+
+def test_add_image_uris_to_data(product):
+ pk = product.pk
+ image_path = "test/path/image.jpg"
+ input_data = {pk: {}}
+ result = add_image_uris_to_data(product.pk, image_path, input_data)
+
+ assert result[pk]["images"] == {"http://mirumee.com/media/" + image_path}
+
+
+def test_add_image_uris_to_data_update_images(product):
+ pk = product.pk
+ old_path = "http://mirumee.com/media/test/image0.jpg"
+ image_path = "test/path/image.jpg"
+ input_data = {pk: {"images": {old_path}}}
+ result = add_image_uris_to_data(product.pk, image_path, input_data)
+
+ assert result[pk]["images"] == {"http://mirumee.com/media/" + image_path, old_path}
+
+
+def test_add_image_uris_to_data_no_image_path(product):
+ pk = product.pk
+ image_path = None
+ input_data = {pk: {"name": "test"}}
+ result = add_image_uris_to_data(product.pk, image_path, input_data)
+
+ assert result == input_data
+
+
+def test_add_attribute_info_to_data(product):
+ pk = product.pk
+ slug = "test_attribute_slug"
+ value = "test value"
+ attribute_data = {
+ "slug": slug,
+ "value": value,
+ }
+ input_data = {pk: {}}
+ result, header = add_attribute_info_to_data(product.pk, attribute_data, input_data)
+
+ expected_header = f"{slug} (attribute)"
+
+ assert header == expected_header
+ assert result[pk][header] == {value}
+
+
+def test_add_attribute_info_to_data_update_attribute_data(product):
+ pk = product.pk
+ slug = "test_attribute_slug"
+ value = "test value"
+ expected_header = f"{slug} (attribute)"
+
+ attribute_data = {
+ "slug": slug,
+ "value": value,
+ }
+ input_data = {pk: {expected_header: {"value1"}}}
+ result, header = add_attribute_info_to_data(product.pk, attribute_data, input_data)
+
+ assert header == expected_header
+ assert result[pk][header] == {value, "value1"}
+
+
+def test_add_attribute_info_to_data_no_slug(product):
+ pk = product.pk
+ attribute_data = {
+ "slug": None,
+ "value": None,
+ }
+ input_data = {pk: {}}
+ result, header = add_attribute_info_to_data(product.pk, attribute_data, input_data)
+
+ assert not header
+ assert result == input_data
+
+
+def test_add_warehouse_info_to_data(product):
+ pk = product.pk
+ slug = "test_warehouse"
+ warehouse_data = {
+ "slug": slug,
+ "qty": 12,
+ "qty_alc": 10,
+ }
+ input_data = {pk: {}}
+ result, headers = add_warehouse_info_to_data(product.pk, warehouse_data, input_data)
+
+ expected_headers = [
+ f"{slug} (warehouse quantity)",
+ f"{slug} (warehouse quantity allocated)",
+ ]
+ assert result[pk][expected_headers[0]] == 12
+ assert result[pk][expected_headers[1]] == 10
+ assert headers == set(expected_headers)
+
+
+def test_add_warehouse_info_to_data_data_not_changed(product):
+ pk = product.pk
+ slug = "test_warehouse"
+ warehouse_data = {
+ "slug": slug,
+ "qty": 12,
+ "qty_alc": 10,
+ }
+ input_data = {
+ pk: {
+ f"{slug} (warehouse quantity)": 5,
+ f"{slug} (warehouse quantity allocated)": 8,
+ }
+ }
+ result, headers = add_warehouse_info_to_data(product.pk, warehouse_data, input_data)
+
+ assert result == input_data
+ assert headers == set()
+
+
+def test_add_warehouse_info_to_data_data_no_slug(product):
+ pk = product.pk
+ warehouse_data = {
+ "slug": None,
+ "qty": None,
+ "qty_alc": None,
+ }
+ input_data = {pk: {}}
+ result, headers = add_warehouse_info_to_data(product.pk, warehouse_data, input_data)
+
+ assert result == input_data
+ assert headers == set()