Skip to content

Commit

Permalink
Merge pull request #4653 from NyanKiyoshi/fix/upgrade/graphene
Browse files Browse the repository at this point in the history
Upgraded graphene to 2.1.8 to fix time rounding issues in aniso8601
  • Loading branch information
maarcingebala committed Aug 21, 2019
2 parents 3c6c3a0 + 391822c commit 77421db
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 147 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ django-bootstrap4 = ">=0.0.4"
django-cache-url = ">=1.0.0"
django-countries = ">=5.2"
django-filter = ">=2.0"
django-graphql-jwt = ">=0.1.13"
django-graphql-jwt = ">=0.1.13,<=0.2.1"
django-impersonate = ">=1.3"
django-measurement = "==3.0.0"
django-mptt = ">=0.7.1"
Expand Down
204 changes: 110 additions & 94 deletions Pipfile.lock

Large diffs are not rendered by default.

36 changes: 19 additions & 17 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-i https://pypi.python.org/simple
amqp==2.5.0
aniso8601==6.0.0
amqp==2.5.1
aniso8601==7.0.0
autopep8==1.4.4
babel==2.7.0
beautifulsoup4==4.7.1
billiard==3.6.0.0
billiard==3.6.1.0
bleach==2.1.4
boto3==1.9.202
botocore==1.12.202
boto3==1.9.210
botocore==1.12.210
braintree==3.49.0
cachetools==3.1.1
cairocffi==1.0.2
Expand All @@ -25,7 +25,7 @@ django-appconf==1.0.3
django-babel==0.6.2
django-bootstrap4==0.0.8
django-cache-url==3.0.0
django-countries==5.3.3
django-countries==5.4
django-elasticsearch-dsl==0.5.1
django-filter==2.2.0
django-graphql-jwt==0.2.1
Expand All @@ -46,7 +46,7 @@ django-templated-email==2.3.0
django-versatileimagefield==1.10
django-webpack-loader==0.6.0
django==2.2.4
docutils==0.14
docutils==0.15.2
draftjs-sanitizer==1.0.0
elasticsearch-dsl==6.0.1
elasticsearch==6.3.1
Expand All @@ -55,34 +55,35 @@ freezegun==0.3.12
google-api-core==1.14.2
google-auth==1.6.3
google-cloud-core==1.0.3
google-cloud-storage==1.17.0
google-cloud-storage==1.18.0
google-i18n-address==2.3.5
google-measurement-protocol==1.0.0
google-resumable-media==0.3.2
googleapis-common-protos==1.6.0
gprof2dot==2016.10.13
graphene-django-optimizer==0.6.0
graphene-django==2.4.0
graphene==2.1.7
graphene-django==2.5.0
graphene==2.1.8
graphql-core==2.2.1
graphql-relay==2.0.0
html-to-draftjs==1.0.1
html5lib==1.0.1
idna==2.8
importlib-metadata==0.19
ipaddress==1.0.22
jinja2==2.10.1
jmespath==0.9.4
jsonfield==2.0.2
kombu==4.6.3
lxml==4.4.0
kombu==4.6.4
lxml==4.4.1
markdown==3.1.1
markupsafe==1.1.1
maxminddb-geolite2==2018.703
maxminddb==1.4.1
measurement==3.0.0
mpmath==1.1.0
oauthlib==3.1.0
phonenumberslite==8.10.16
phonenumberslite==8.10.17
pillow==5.4.1
prices==1.0.0
promise==2.2.1
Expand All @@ -100,20 +101,20 @@ python-dateutil==2.8.0 ; python_version >= '2.7'
python3-openid==3.1.0 ; python_version >= '3.0'
pytz==2019.2
razorpay==1.2.0
redis==3.3.6
redis==3.3.7
requests-oauthlib==1.2.0
requests==2.22.0
rsa==4.0
rx==1.6.1
s3transfer==0.2.1
sentry-sdk==0.10.2
sentry-sdk==0.11.0
singledispatch==3.4.0.3
six==1.12.0
social-auth-app-django==3.1.0
social-auth-core==3.2.0
soupsieve==1.9.2
soupsieve==1.9.3
sqlparse==0.3.0
stripe==2.33.2
stripe==2.35.0
sympy==1.4
text-unidecode==1.2
tinycss2==1.0.2
Expand All @@ -123,3 +124,4 @@ uwsgi==2.0.18 ; platform_system != 'Windows'
vine==1.3.0
weasyprint==48
webencodings==0.5.1
zipp==0.5.2
16 changes: 8 additions & 8 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ django-debug-toolbar==1.11
django-extensions==2.2.1
django==2.2.4
entrypoints==0.3
execnet==1.6.1
execnet==1.7.0
filelock==3.0.12
flake8==3.7.8
identify==1.4.5
identify==1.4.6
idna==2.8
importlib-metadata==0.19
isort==4.3.21
Expand All @@ -35,10 +35,10 @@ multidict==4.5.2
nodeenv==1.3.3
packaging==19.1
pluggy==0.12.0
pre-commit==1.18.0
pre-commit==1.18.2
py==1.8.0
pycodestyle==2.5.0
pydocstyle==4.0.0
pydocstyle==4.0.1
pyflakes==2.1.1
pylint-celery==0.3
pylint-django==2.0.11
Expand All @@ -52,7 +52,7 @@ pytest-forked==1.0.2
pytest-mock==1.10.4
pytest-vcr==1.0.2
pytest-xdist==1.29.0
pytest==5.0.1
pytest==5.1.0
python-slugify==1.2.6
pytz==2019.2
pyyaml==5.1.2
Expand All @@ -66,10 +66,10 @@ transifex-client==0.13.6
typed-ast==1.4.0 ; implementation_name == 'cpython'
unidecode==1.1.1
urllib3==1.25.3
vcrpy==2.0.1
virtualenv==16.7.2
vcrpy==2.1.0
virtualenv==16.7.3
wcwidth==0.1.7
wrapt==1.11.2
yapf==0.28.0
yarl==1.3.0 ; python_version >= '3.4'
yarl==1.3.0 ; python_version >= '3.5'
zipp==0.5.2
6 changes: 3 additions & 3 deletions saleor/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ type AssignNavigation {

type Attribute implements Node {
id: ID!
productTypes(before: String, after: String, first: Int, last: Int): ProductTypeCountableConnection
productVariantTypes(before: String, after: String, first: Int, last: Int): ProductTypeCountableConnection
productTypes(before: String, after: String, first: Int, last: Int): ProductTypeCountableConnection!
productVariantTypes(before: String, after: String, first: Int, last: Int): ProductTypeCountableConnection!
privateMeta: [MetaStore]!
meta: [MetaStore]!
inputType: AttributeInputTypeEnum
Expand Down Expand Up @@ -970,7 +970,6 @@ enum CountryCode {
LT
LU
MO
MK
MG
MW
MY
Expand Down Expand Up @@ -1004,6 +1003,7 @@ enum CountryCode {
NU
NF
KP
MK
MP
NO
OM
Expand Down
7 changes: 3 additions & 4 deletions tests/api/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,11 @@ def _run_test():
_run_test()
return

with pytest.raises(
ImproperlyConfigured,
message="Permissions should be a tuple or a string in Meta",
):
with pytest.raises(ImproperlyConfigured) as exc:
_run_test()

assert exc.value.args[0] == "Permissions should be a tuple or a string in Meta"


MUTATION_TOKEN_VERIFY = """
mutation tokenVerify($token: String!){
Expand Down
9 changes: 0 additions & 9 deletions tests/api/test_discount.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pytest
from django.utils import timezone
from django_countries import countries
from freezegun import freeze_time

from saleor.discount import DiscountValueType, VoucherType
from saleor.discount.models import Sale, Voucher
Expand Down Expand Up @@ -177,7 +176,6 @@ def test_sale_query(staff_api_client, sale, permission_manage_discounts):
"""


@freeze_time("2010-05-31 12:00:01")
def test_create_voucher(staff_api_client, permission_manage_discounts):
start_date = timezone.now() - timedelta(days=365)
end_date = timezone.now() + timedelta(days=365)
Expand Down Expand Up @@ -213,7 +211,6 @@ def test_create_voucher(staff_api_client, permission_manage_discounts):
assert voucher.usage_limit == 3


@freeze_time("2010-05-31 12:00:01")
def test_create_voucher_with_empty_code(staff_api_client, permission_manage_discounts):
start_date = timezone.now() - timedelta(days=365)
end_date = timezone.now() + timedelta(days=365)
Expand All @@ -238,7 +235,6 @@ def test_create_voucher_with_empty_code(staff_api_client, permission_manage_disc
assert data["code"] != ""


@freeze_time("2010-05-31 12:00:01")
def test_create_voucher_with_deprecated_type(
staff_api_client, permission_manage_discounts
):
Expand Down Expand Up @@ -266,7 +262,6 @@ def test_create_voucher_with_deprecated_type(
assert data["type"] == VoucherTypeEnum.ENTIRE_ORDER.name


@freeze_time("2010-05-31 12:00:01")
def test_create_voucher_with_existing_gift_card_code(
staff_api_client, gift_card, permission_manage_discounts
):
Expand Down Expand Up @@ -294,7 +289,6 @@ def test_create_voucher_with_existing_gift_card_code(
assert errors[0]["field"] == "promoCode"


@freeze_time("2010-05-31 12:00:01")
def test_create_voucher_with_existing_voucher_code(
staff_api_client, voucher_shipping_type, permission_manage_discounts
):
Expand Down Expand Up @@ -552,7 +546,6 @@ def test_voucher_remove_no_catalogues(
assert voucher.collections.exists()


@freeze_time("2010-05-31 12:00:01")
def test_create_sale(staff_api_client, permission_manage_discounts):
query = """
mutation saleCreate(
Expand Down Expand Up @@ -793,7 +786,6 @@ def test_sale_remove_no_catalogues(
assert sale.collections.exists()


@freeze_time("2019-05-31 12:00:01")
@pytest.mark.parametrize(
"voucher_filter, start_date, end_date, count",
[
Expand Down Expand Up @@ -991,7 +983,6 @@ def test_query_vouchers_with_filter_search(
assert len(data) == count


@freeze_time("2019-05-31 12:00:01")
@pytest.mark.parametrize(
"sale_filter, start_date, end_date, count",
[
Expand Down
24 changes: 14 additions & 10 deletions tests/api/test_graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,33 +216,37 @@ def test_get_nodes(product_list):
msg = "There is no node of type {} with pk {}".format(
nonexistent_item.type, nonexistent_item.pk
)
with pytest.raises(AssertionError, message=msg):
with pytest.raises(AssertionError) as exc:
get_nodes(global_ids, Product)

assert exc.value.args == (msg,)
global_ids.pop()

# Raise an error if one of the node is of wrong type
invalid_item = Mock(type="test", pk=123)
invalid_item_global_id = to_global_id(invalid_item.type, invalid_item.pk)
global_ids.append(invalid_item_global_id)
with pytest.raises(AssertionError, message="Must receive an Product id."):
with pytest.raises(AssertionError) as exc:
get_nodes(global_ids, Product)

assert exc.value.args == ("Must receive an Product id.",)

# Raise an error if no nodes were found
global_ids = []
msg = "Could not resolve to a node with the global id list of {}.".format(
global_ids
)
with pytest.raises(Exception, message=msg):
msg = f"Could not resolve to a node with the global id list of '{global_ids}'."
with pytest.raises(Exception) as exc:
get_nodes(global_ids, Product)

assert exc.value.args == (msg,)

# Raise an error if pass wrong ids
global_ids = ["a", "bb"]
msg = "Could not resolve to a node with the global id list of {}.".format(
global_ids
)
with pytest.raises(Exception, message=msg):
msg = f"Could not resolve to a node with the global id list of '{global_ids}'."
with pytest.raises(Exception) as exc:
get_nodes(global_ids, Product)

assert exc.value.args == (msg,)


@patch("saleor.product.models.Product.objects")
def test_filter_by_query_param(qs):
Expand Down
4 changes: 3 additions & 1 deletion tests/api/test_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -1604,11 +1604,13 @@ def test_try_payment_action_generates_event(order, staff_user, payment_dummy):
def _test_operation():
raise PaymentError(message)

with pytest.raises(ValidationError, message={"payment": message}):
with pytest.raises(ValidationError) as exc:
try_payment_action(
order=order, user=staff_user, payment=payment_dummy, func=_test_operation
)

assert exc.value.args[0] == {"payment": message}

error_event = OrderEvent.objects.get() # type: OrderEvent
assert error_event.type == order_events.OrderEvents.PAYMENT_FAILED
assert error_event.user == staff_user
Expand Down

0 comments on commit 77421db

Please sign in to comment.