Skip to content

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

Fixed failing tests, pep8 formatting

k-brke3198402d3db
diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.py
index 2c758563d5..4e2c43284c 100644
--- a/saleor/graphql/product/mutations/products.py
+++ b/saleor/graphql/product/mutations/products.py
@@ -110,7 +110,8 @@ class CollectionInput(graphene.InputObjectType):
description = graphene.String(description='Description of the collection.')
background_image = Upload(description='Background image file.')
seo = SeoInput(description='Search engine optimization fields.')
- published_at = graphene.types.datetime.Date(description='Publication date. ISO 8601 standard.')
+ published_at = graphene.String(
+ description='Publication date. ISO 8601 standard.')
class CollectionCreateInput(CollectionInput):
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 8aab8fc4d7..7a69f4a852 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -439,6 +439,7 @@ input CollectionCreateInput {
description: String
backgroundImage: Upload
seo: SeoInput
+ publishedAt: String
products: [ID]
}
@@ -454,6 +455,7 @@ input CollectionInput {
description: String
backgroundImage: Upload
seo: SeoInput
+ publishedAt: String
}
type CollectionRemoveProducts {
@@ -669,6 +671,7 @@ input FulfillmentUpdateTrackingInput {
enum GatewaysEnum {
DUMMY
BRAINTREE
+ RAZORPAY
}
scalar GenericScalar
diff --git a/saleor/product/models.py b/saleor/product/models.py
index 34858eb88c..86b0e0b2c4 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -457,7 +457,7 @@ class Collection(SeoModel):
upload_to='collection-backgrounds', blank=True, null=True)
is_published = models.BooleanField(default=False)
description = models.TextField(blank=True)
- published_at = models.DateField(blank=True, null=True);
+ published_at = models.DateField(blank=True, null=True)
objects = CollectionQuerySet.as_manager()
translated = TranslationProxy()
@@ -475,8 +475,8 @@ class Collection(SeoModel):
@property
def is_available(self):
today = datetime.date.today()
- return self.is_published and (self.published_at is None or self.published_at <= today)
-
+ return self.is_published and \
+ (self.published_at is None or self.published_at <= today)
class CollectionTranslation(SeoModelTranslation):
diff --git a/saleor/static/dashboard-next/collections/components/CollectionCreatePage/CollectionCreatePage.tsx b/saleor/static/dashboard-next/collections/components/CollectionCreatePage/CollectionCreatePage.tsx
index e24c834523..765888ecb4 100644
--- a/saleor/static/dashboard-next/collections/components/CollectionCreatePage/CollectionCreatePage.tsx
+++ b/saleor/static/dashboard-next/collections/components/CollectionCreatePage/CollectionCreatePage.tsx
@@ -26,7 +26,6 @@ export interface CollectionCreatePageFormData {
isPublished: boolean;
seoDescription: string;
seoTitle: string;
- publishedAt: string;
}
export interface CollectionCreatePageProps {
@@ -44,7 +43,6 @@ const initialForm: CollectionCreatePageFormData = {
},
isPublished: false,
name: "",
- publishedAt: "",
seoDescription: "",
seoTitle: ""
};
diff --git a/tests/api/test_collection.py b/tests/api/test_collection.py
index d1b2e7a5ce..3856658ada 100644
--- a/tests/api/test_collection.py
+++ b/tests/api/test_collection.py
@@ -1,6 +1,6 @@
import graphene
import pytest
-from datetime import datetime
+from datetime import date
from django.utils.text import slugify
from graphql_relay import to_global_id
from unittest.mock import Mock
@@ -55,7 +55,7 @@ def test_create_collection(
monkeypatch, staff_api_client, product_list, permission_manage_products):
query = """
mutation createCollection(
- $name: String!, $slug: String!, $description: String, $products: [ID], $backgroundImage: Upload!, $isPublished: Boolean!, $publishedAt: Date) {
+ $name: String!, $slug: String!, $description: String, $products: [ID], $backgroundImage: Upload!, $isPublished: Boolean!, $publishedAt: String) {
collectionCreate(
input: {name: $name, slug: $slug, description: $description, products: $products, backgroundImage: $backgroundImage, isPublished: $isPublished, publishedAt: $publishedAt}) {
collection {
@@ -65,6 +65,11 @@ def test_create_collection(
products {
totalCount
}
+ publishedAt
+ }
+ errors {
+ field
+ message
}
}
}
@@ -82,8 +87,7 @@ def test_create_collection(
name = 'test-name'
slug = 'test-slug'
description = 'test-description'
- published_at = datetime.today()
-
+ published_at = date.today().isoformat()
variables = {
'name': name, 'slug': slug, 'description': description,
'products': product_ids, 'backgroundImage': image_name,
@@ -136,13 +140,14 @@ def test_update_collection(
monkeypatch, staff_api_client, collection, permission_manage_products):
query = """
mutation updateCollection(
- $name: String!, $slug: String!, $description: String, $id: ID!, $isPublished: Boolean!) {
+ $name: String!, $slug: String!, $description: String, $id: ID!, $isPublished: Boolean!, $publishedAt: String) {
collectionUpdate(
- id: $id, input: {name: $name, slug: $slug, description: $description, isPublished: $isPublished}) {
+ id: $id, input: {name: $name, slug: $slug, description: $description, isPublished: $isPublished, publishedAt: $publishedAt}) {
collection {
name
slug
description
+ publishedAt
}
}
}
@@ -157,15 +162,17 @@ def test_update_collection(
name = 'new-name'
slug = 'new-slug'
description = 'new-description'
+ published_at = date.today().isoformat()
variables = {
'name': name, 'slug': slug, 'description': description,
- 'id': to_global_id('Collection', collection.id), 'isPublished': True}
+ 'id': to_global_id('Collection', collection.id), 'isPublished': True, 'publishedAt': published_at}
response = staff_api_client.post_graphql(
query, variables, permissions=[permission_manage_products])
content = get_graphql_content(response)
data = content['data']['collectionUpdate']['collection']
assert data['name'] == name
assert data['slug'] == slug
+ assert data['publishedAt'] == published_at
assert mock_create_thumbnails.call_count == 0