mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 04:07:16 +03:00
automatically generated linting fixes
This commit is contained in:
parent
fc3dbf0963
commit
c076412ba5
|
@ -11,12 +11,13 @@ class Decimal(Scalar):
|
|||
"""
|
||||
The `Decimal` scalar type represents a python Decimal.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def serialize(dec):
|
||||
if isinstance(dec, str):
|
||||
dec = _Decimal(dec)
|
||||
assert isinstance(dec, _Decimal), (
|
||||
'Received not compatible Decimal "{}"'.format(repr(dec))
|
||||
assert isinstance(dec, _Decimal), 'Received not compatible Decimal "{}"'.format(
|
||||
repr(dec)
|
||||
)
|
||||
return str(dec)
|
||||
|
||||
|
|
|
@ -11,36 +11,33 @@ class Query(ObjectType):
|
|||
def resolve_decimal(self, info, input):
|
||||
return input
|
||||
|
||||
|
||||
schema = Schema(query=Query)
|
||||
|
||||
|
||||
def test_decimal_string_query():
|
||||
decimal_value = decimal.Decimal('1969.1974')
|
||||
result = schema.execute('''{ decimal(input: "%s") }''' % decimal_value)
|
||||
decimal_value = decimal.Decimal("1969.1974")
|
||||
result = schema.execute("""{ decimal(input: "%s") }""" % decimal_value)
|
||||
assert not result.errors
|
||||
assert result.data == {
|
||||
'decimal': str(decimal_value)
|
||||
}
|
||||
assert decimal.Decimal(result.data['decimal']) == decimal_value
|
||||
assert result.data == {"decimal": str(decimal_value)}
|
||||
assert decimal.Decimal(result.data["decimal"]) == decimal_value
|
||||
|
||||
|
||||
def test_decimal_string_query_variable():
|
||||
decimal_value = decimal.Decimal('1969.1974')
|
||||
decimal_value = decimal.Decimal("1969.1974")
|
||||
|
||||
result = schema.execute(
|
||||
'''query Test($decimal: Decimal){ decimal(input: $decimal) }''',
|
||||
variable_values={'decimal': decimal_value}
|
||||
"""query Test($decimal: Decimal){ decimal(input: $decimal) }""",
|
||||
variable_values={"decimal": decimal_value},
|
||||
)
|
||||
assert not result.errors
|
||||
assert result.data == {
|
||||
'decimal': str(decimal_value)
|
||||
}
|
||||
assert decimal.Decimal(result.data['decimal']) == decimal_value
|
||||
assert result.data == {"decimal": str(decimal_value)}
|
||||
assert decimal.Decimal(result.data["decimal"]) == decimal_value
|
||||
|
||||
|
||||
def test_bad_decimal_query():
|
||||
not_a_decimal = "Nobody expects the Spanish Inquisition!"
|
||||
|
||||
result = schema.execute('''{ decimal(input: "%s") }''' % not_a_decimal)
|
||||
|
||||
result = schema.execute("""{ decimal(input: "%s") }""" % not_a_decimal)
|
||||
assert len(result.errors) == 1
|
||||
assert result.data == None
|
||||
|
|
Loading…
Reference in New Issue
Block a user