Skip to content

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

Removed unused fields in gql queries and move const queries around tests

NyanKiyoshi5d1a5d930250
diff --git a/tests/api/test_category.py b/tests/api/test_category.py
index 3d9800ce27..d80ab43e38 100644
--- a/tests/api/test_category.py
+++ b/tests/api/test_category.py
@@ -9,33 +9,6 @@ from tests.utils import create_image
from tests.api.utils import get_graphql_content, get_multipart_request_body
-FETCH_CATEGORY_QUERY = """
-query fetchCategory($id: ID!){
- category(id: $id) {
- name
- backgroundImage {
- url(size: 120)
- }
- }
-}
-"""
-
-LEVELED_CATEGORIES_QUERY = """
-query leveled_categories($level: Int) {
- categories(level: $level) {
- edges {
- node {
- name
- parent {
- name
- }
- }
- }
- }
-}
-"""
-
-
def test_category_query(user_api_client, product):
category = Category.objects.first()
query = """
@@ -156,16 +129,6 @@ def test_category_create_mutation_without_background_image(
},
parent: $parentId
) {
- category {
- id
- name
- slug
- description
- parent {
- name
- id
- }
- }
errors {
field
message
@@ -274,14 +237,6 @@ def test_category_update_mutation_without_background_image(
slug: $slug
}
) {
- category {
- id
- name
- description
- parent {
- id
- }
- }
errors {
field
message
@@ -345,6 +300,22 @@ def test_category_delete_mutation(
category.refresh_from_db()
+LEVELED_CATEGORIES_QUERY = """
+query leveled_categories($level: Int) {
+ categories(level: $level) {
+ edges {
+ node {
+ name
+ parent {
+ name
+ }
+ }
+ }
+ }
+}
+"""
+
+
def test_category_level(user_api_client, category):
query = LEVELED_CATEGORIES_QUERY
child = Category.objects.create(
@@ -364,6 +335,18 @@ def test_category_level(user_api_client, category):
assert category_data['parent']['name'] == category.name
+FETCH_CATEGORY_QUERY = """
+query fetchCategory($id: ID!){
+ category(id: $id) {
+ name
+ backgroundImage {
+ url(size: 120)
+ }
+ }
+}
+"""
+
+
def test_category_image_query(user_api_client, non_default_category):
category = non_default_category
image_file, image_name = create_image()
diff --git a/tests/api/test_collection.py b/tests/api/test_collection.py
index ec2fe65c6a..4e424ba1c5 100644
--- a/tests/api/test_collection.py
+++ b/tests/api/test_collection.py
@@ -309,6 +309,18 @@ def test_remove_products_from_collection(
'products']['totalCount'] == no_products_before - len(product_ids)
+FETCH_COLLECTION_QUERY = """
+ query fetchCollection($id: ID!){
+ collection(id: $id) {
+ name
+ backgroundImage {
+ url
+ }
+ }
+ }
+"""
+
+
def test_collection_image_query(user_api_client, collection):
query = """
query fetchCollection($id: ID!){