Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add tests
Krzysztof Wolskid8ebd7855c9d
diff --git a/tests/conftest.py b/tests/conftest.pyindex 3652431be6..2091346221 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -1,6 +1,7 @@# coding: utf-8from __future__ import unicode_literals+from decimal import Decimalimport pytestfrom django.contrib.auth.models import AnonymousUserfrom mock import Mock@@ -123,7 +124,8 @@ def product_class(color_attribute, size_attribute):@pytest.fixturedef product_in_stock(product_class, default_category):product = Product.objects.create(- name='Test product', price=10, weight=1, product_class=product_class)+ name='Test product', price=Decimal('10.00'), weight=1,+ product_class=product_class)product.categories.add(default_category)variant = ProductVariant.objects.create(product=product, sku='123')warehouse_1 = StockLocation.objects.create(name='Warehouse 1')diff --git a/tests/test_integrations.py b/tests/test_integrations.pyindex 85b4a11064..4fa65076cd 100644--- a/tests/test_integrations.py+++ b/tests/test_integrations.py@@ -1,7 +1,14 @@from __future__ import unicode_literals+import csv+try:+ from StringIO import StringIO+except ImportError:+ from io import StringIO+from saleor.product.models import Categoryfrom saleor.integrations.feeds import SaleorFeed+from saleor.integrations.utils import update_feeddef test_saleor_feed_items(product_in_stock):@@ -23,3 +30,21 @@ def test_category_formatter(db):assert feed.get_full_category_name_path(main_category) == 'Main'assert feed.get_full_category_name_path(sub_category) == 'Main > Sub'++def test_feed_updater(product_in_stock, monkeypatch):+ variant = product_in_stock.variants.first()+ fake_file = StringIO()+ fake_file.__exit__ = lambda x, y, z: None+ fake_file.close = lambda: None+ fake_file.__enter__ = lambda: fake_file+ monkeypatch.setattr('saleor.integrations.utils.default_storage.open',+ lambda path, mode: fake_file)+ feed = SaleorFeed()+ feed.compression = False+ update_feed(feed)+ fake_file.seek(0)+ reader = csv.DictReader(fake_file, dialect=csv.excel_tab)+ for generated_item in reader:+ attributes = feed.item_attributes(variant)+ for key in attributes.keys():+ assert attributes[key] == generated_item[key]