Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use tmp fixture for media_root
Maciej Korycinski4d99017e3689
diff --git a/tests/api/test_account.py b/tests/api/test_account.pyindex 9c8e762b2d..4405c572c1 100644--- a/tests/api/test_account.py+++ b/tests/api/test_account.py@@ -97,7 +97,8 @@ def test_token_create_user_data(def test_query_user(- staff_api_client, customer_user, address, permission_manage_users):+ staff_api_client, customer_user, address, permission_manage_users,+ media_root):user = customer_useruser.default_shipping_address.country = 'US'user.default_shipping_address.save()@@ -755,7 +756,8 @@ def test_customer_delete_errors(customer_user, admin_user, staff_user):@patch('saleor.dashboard.emails.send_set_password_staff_email.delay')def test_staff_create(- send_set_password_staff_email_mock, staff_api_client, permission_manage_staff):+ send_set_password_staff_email_mock, staff_api_client, media_root,+ permission_manage_staff):query = """mutation CreateStaff($email: String, $permissions: [PermissionEnum],@@ -814,7 +816,7 @@ def test_staff_create(assert call_pk == staff_user.pk-def test_staff_update(staff_api_client, permission_manage_staff):+def test_staff_update(staff_api_client, permission_manage_staff, media_root):query = """mutation UpdateStaff($id: ID!, $permissions: [PermissionEnum], $is_active: Boolean) {@@ -1526,7 +1528,8 @@ def test_user_avatar_update_mutation_permission(api_client):assert_no_permission(response)-def test_user_avatar_update_mutation(monkeypatch, staff_api_client):+def test_user_avatar_update_mutation(+ monkeypatch, staff_api_client, media_root):query = USER_AVATAR_UPDATE_MUTATIONuser = staff_api_client.user@@ -1555,7 +1558,8 @@ def test_user_avatar_update_mutation(monkeypatch, staff_api_client):mock_create_thumbnails.assert_called_once_with(user_id=user.pk)-def test_user_avatar_update_mutation_image_exists(staff_api_client):+def test_user_avatar_update_mutation_image_exists(+ staff_api_client, media_root):query = USER_AVATAR_UPDATE_MUTATIONuser = staff_api_client.userdiff --git a/tests/api/test_category.py b/tests/api/test_category.pyindex 3756fcd4df..dd96652d7e 100644--- a/tests/api/test_category.py+++ b/tests/api/test_category.py@@ -49,7 +49,7 @@ def test_category_query(user_api_client, product):def test_category_create_mutation(- monkeypatch, staff_api_client, permission_manage_products):+ monkeypatch, staff_api_client, permission_manage_products, media_root):query = """mutation($name: String, $slug: String, $description: String,@@ -207,7 +207,8 @@ MUTATION_CATEGORY_UPDATE_MUTATION = """def test_category_update_mutation(- monkeypatch, staff_api_client, category, permission_manage_products):+ monkeypatch, staff_api_client, category, permission_manage_products,+ media_root):mock_create_thumbnails = Mock(return_value=None)monkeypatch.setattr(('saleor.dashboard.category.forms.'@@ -385,7 +386,8 @@ FETCH_CATEGORY_QUERY = """"""-def test_category_image_query(user_api_client, non_default_category):+def test_category_image_query(+ user_api_client, non_default_category, media_root):alt_text = 'Alt text for an image.'category = non_default_categoryimage_file, image_name = create_image()diff --git a/tests/api/test_collection.py b/tests/api/test_collection.pyindex cace77d7c7..1868e509ef 100644--- a/tests/api/test_collection.py+++ b/tests/api/test_collection.py@@ -55,7 +55,8 @@ def test_collections_query(def test_create_collection(- monkeypatch, staff_api_client, product_list, permission_manage_products):+ monkeypatch, staff_api_client, product_list, media_root,+ permission_manage_products):query = """mutation createCollection($name: String!, $slug: String!, $description: String,@@ -222,7 +223,8 @@ MUTATION_UPDATE_COLLECTION_WITH_BACKGROUND_IMAGE = """def test_update_collection_with_background_image(- monkeypatch, staff_api_client, collection, permission_manage_products):+ monkeypatch, staff_api_client, collection, permission_manage_products,+ media_root):mock_create_thumbnails = Mock(return_value=None)monkeypatch.setattr(('saleor.dashboard.collection.forms.'@@ -391,7 +393,7 @@ FETCH_COLLECTION_QUERY = """"""-def test_collection_image_query(user_api_client, collection):+def test_collection_image_query(user_api_client, collection, media_root):alt_text = 'Alt text for an image.'image_file, image_name = create_image()collection.background_image = image_filediff --git a/tests/api/test_digital_content.py b/tests/api/test_digital_content.pyindex 4d4d49bedc..b8bdbd8d00 100644--- a/tests/api/test_digital_content.py+++ b/tests/api/test_digital_content.py@@ -48,7 +48,8 @@ def test_fetch_single_digital_content(def test_digital_content_create_mutation_custom_settings(- monkeypatch, staff_api_client, variant, permission_manage_products):+ monkeypatch, staff_api_client, variant, permission_manage_products,+ media_root):query = """mutation createDigitalContent($variant: ID!,$input: DigitalContentUploadInput!) {@@ -88,7 +89,8 @@ def test_digital_content_create_mutation_custom_settings(def test_digital_content_create_mutation_default_settings(- monkeypatch, staff_api_client, variant, permission_manage_products):+ monkeypatch, staff_api_client, variant, permission_manage_products,+ media_root):query = """mutation digitalCreate($variant: ID!,$input: DigitalContentUploadInput!) {@@ -119,7 +121,8 @@ def test_digital_content_create_mutation_default_settings(assert variant.digital_content.use_default_settingsdef test_digital_content_create_mutation_removes_old_content(- monkeypatch, staff_api_client, variant, permission_manage_products):+ monkeypatch, staff_api_client, variant, permission_manage_products,+ media_root):query = """mutation digitalCreate($variant: ID!,$input: DigitalContentUploadInput!) {diff --git a/tests/api/test_product.py b/tests/api/test_product.pyindex af5815cdf1..611e84feef 100644--- a/tests/api/test_product.py+++ b/tests/api/test_product.py@@ -1194,7 +1194,8 @@ def test_product_type_delete_mutation(def test_product_image_create_mutation(- monkeypatch, staff_api_client, product, permission_manage_products):+ monkeypatch, staff_api_client, product, permission_manage_products,+ media_root):query = """mutation createProductImage($image: Upload!, $product: ID!) {productImageCreate(input: {image: $image, product: $product}) {diff --git a/tests/conftest.py b/tests/conftest.pyindex 3ec8286a70..a51c0cc34b 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -264,7 +264,7 @@ def size_attribute(db): # pylint: disable=W0613@pytest.fixture-def image():+def image(media_root):img_data = BytesIO()image = Image.new('RGB', size=(1, 1))image.save(img_data, format='JPEG')@@ -454,7 +454,7 @@ def unavailable_product_with_variant(product_type, category):@pytest.fixture-def product_with_images(product_type, category):+def product_with_images(product_type, category, media_root):product = Product.objects.create(name='Test product', price=Money('10.00', 'USD'),product_type=product_type, category=category)@@ -913,7 +913,7 @@ def payment_dummy(db, settings, order_with_lines):@pytest.fixture-def digital_content(category):+def digital_content(category, media_root):product_type = ProductType.objects.create(name='Digital Type', has_variants=True, is_shipping_required=False,is_digital=True@@ -930,3 +930,8 @@ def digital_content(category):content_file=image_file, product_variant=product_variant,use_default_settings=True)return d_content+++def media_root(tmpdir, settings):+ settings.MEDIA_ROOT = tmpdir.mkdir("media")diff --git a/tests/dashboard/test_category.py b/tests/dashboard/test_category.pyindex 32c6d219c1..4f7254faee 100644--- a/tests/dashboard/test_category.py+++ b/tests/dashboard/test_category.py@@ -28,7 +28,8 @@ def test_category_add(monkeypatch, admin_client):assert mock_create_thumbnails.call_count == 0-def test_category_add_with_background_image(monkeypatch, admin_client):+def test_category_add_with_background_image(+ monkeypatch, admin_client, media_root):mock_create_thumbnails = Mock(return_value=None)monkeypatch.setattr(('saleor.dashboard.category.forms.'@@ -89,7 +90,7 @@ def test_category_edit(monkeypatch, admin_client, category):def test_category_edit_with_background_image(- monkeypatch, admin_client, category):+ monkeypatch, admin_client, category, media_root):mock_create_thumbnails = Mock(return_value=None)monkeypatch.setattr(('saleor.dashboard.category.forms.'diff --git a/tests/dashboard/test_collection.py b/tests/dashboard/test_collection.pyindex f0204f2871..5f20283d44 100644--- a/tests/dashboard/test_collection.py+++ b/tests/dashboard/test_collection.py@@ -80,7 +80,7 @@ def test_collection_create_view(monkeypatch, admin_client):def test_collection_create_with_background_image(- monkeypatch, admin_client):+ monkeypatch, admin_client, media_root):mock_create_thumbnails = Mock(return_value=None)monkeypatch.setattr(('saleor.dashboard.collection.forms.'@@ -125,7 +125,7 @@ def test_collection_update_view(def test_collection_update_background_image(- monkeypatch, admin_client, collection, product):+ monkeypatch, admin_client, collection, product, media_root):mock_create_category_thumbnails = Mock(return_value=None)monkeypatch.setattr(('saleor.dashboard.collection.forms.'diff --git a/tests/settings.py b/tests/settings.pyindex e95956f7de..baf99922fc 100644--- a/tests/settings.py+++ b/tests/settings.py@@ -33,4 +33,4 @@ CHECKOUT_PAYMENT_GATEWAYS = {COUNTRIES_ONLY = None-MEDIA_ROOT = os.path.join(MEDIA_ROOT, 'test')+MEDIA_ROOT = Nonediff --git a/tests/test_core.py b/tests/test_core.pyindex 2b3ddf4c45..c9ff7c1ed6 100644--- a/tests/test_core.py+++ b/tests/test_core.py@@ -64,7 +64,7 @@ def test_get_currency_for_country(country, expected_currency, monkeypatch):assert currency == expected_currency-def test_create_superuser(db, client):+def test_create_superuser(db, client, media_root):credentials = {'email': '[email protected]', 'password': 'admin'}# Test admin creationassert User.objects.all().count() == 0diff --git a/tests/test_order.py b/tests/test_order.pyindex 6be379f769..8c3713140b 100644--- a/tests/test_order.py+++ b/tests/test_order.py@@ -585,7 +585,8 @@ def test_get_order_weight_non_existing_product(order_with_lines, product):@patch('saleor.order.utils.emails.send_fulfillment_confirmation')@patch('saleor.order.utils.get_default_digital_content_settings')def test_fulfill_digital_lines(- mock_digital_settings, mock_email_fulfillment, order_with_lines):+ mock_digital_settings, mock_email_fulfillment, order_with_lines,+ media_root):mock_digital_settings.return_value = {'automatic_fulfillment': True}line = order_with_lines.lines.all()[0]