Skip to content

Commit

Permalink
Switch schema parser tests to use dedent
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Oct 22, 2018
1 parent d24f556 commit 967a02d
Showing 1 changed file with 72 additions and 17 deletions.
89 changes: 72 additions & 17 deletions tests/language/test_schema_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,14 @@ def directive_node(name, arguments, loc):

def describe_schema_parser():
def simple_type():
body = "\ntype Hello {\n world: String\n}"
definition = assert_definitions(body, (0, 31))
body = dedent(
"""
type Hello {
world: String
}
"""
)
definition = assert_definitions(body, (0, 32))
assert isinstance(definition, ObjectTypeDefinitionNode)
assert definition.name == name_node("Hello", (6, 11))
assert definition.description is None
Expand All @@ -125,8 +131,15 @@ def simple_type():
assert definition.loc == (1, 31)

def parses_type_with_description_string():
body = '\n"Description"\ntype Hello {\n world: String\n}'
definition = assert_definitions(body, (0, 45))
body = dedent(
"""
"Description"
type Hello {
world: String
}
"""
)
definition = assert_definitions(body, (0, 46))
assert isinstance(definition, ObjectTypeDefinitionNode)
assert definition.name == name_node("Hello", (20, 25))
description = definition.description
Expand Down Expand Up @@ -156,7 +169,13 @@ def parses_type_with_description_multi_line_string():
assert description.loc == (1, 20)

def simple_extension():
body = "\nextend type Hello {\n world: String\n}\n"
body = dedent(
"""
extend type Hello {
world: String
}
"""
)
extension = assert_definitions(body, (0, 39))
assert isinstance(extension, ObjectTypeExtensionNode)
assert extension.name == name_node("Hello", (13, 18))
Expand Down Expand Up @@ -261,8 +280,14 @@ def schema_extension_without_anything_throws():
assert_syntax_error("extend schema", "Unexpected <EOF>", (1, 14))

def simple_non_null_type():
body = "\ntype Hello {\n world: String!\n}"
definition = assert_definitions(body, (0, 32))
body = dedent(
"""
type Hello {
world: String!
}
"""
)
definition = assert_definitions(body, (0, 33))
assert isinstance(definition, ObjectTypeDefinitionNode)
assert definition.name == name_node("Hello", (6, 11))
assert definition.description is None
Expand Down Expand Up @@ -352,8 +377,14 @@ def double_value_enum():
assert definition.loc == (0, 22)

def simple_interface():
body = "\ninterface Hello {\n world: String\n}"
definition = assert_definitions(body, (0, 36))
body = dedent(
"""
interface Hello {
world: String
}
"""
)
definition = assert_definitions(body, (0, 37))
assert isinstance(definition, InterfaceTypeDefinitionNode)
assert definition.name == name_node("Hello", (11, 16))
assert definition.description is None
Expand All @@ -366,8 +397,14 @@ def simple_interface():
assert definition.loc == (1, 36)

def simple_field_with_arg():
body = "\ntype Hello {\n world(flag: Boolean): String\n}"
definition = assert_definitions(body, (0, 46))
body = dedent(
"""
type Hello {
world(flag: Boolean): String
}
"""
)
definition = assert_definitions(body, (0, 47))
assert isinstance(definition, ObjectTypeDefinitionNode)
assert definition.name == name_node("Hello", (6, 11))
assert definition.description is None
Expand All @@ -391,8 +428,14 @@ def simple_field_with_arg():
assert definition.loc == (1, 46)

def simple_field_with_arg_with_default_value():
body = "\ntype Hello {\n world(flag: Boolean = true): String\n}"
definition = assert_definitions(body, (0, 53))
body = dedent(
"""
type Hello {
world(flag: Boolean = true): String
}
"""
)
definition = assert_definitions(body, (0, 54))
assert isinstance(definition, ObjectTypeDefinitionNode)
assert definition.name == name_node("Hello", (6, 11))
assert definition.description is None
Expand All @@ -416,8 +459,14 @@ def simple_field_with_arg_with_default_value():
assert definition.loc == (1, 53)

def simple_field_with_list_arg():
body = "\ntype Hello {\n world(things: [String]): String\n}"
definition = assert_definitions(body, (0, 49))
body = dedent(
"""
type Hello {
world(things: [String]): String
}
"""
)
definition = assert_definitions(body, (0, 50))
assert isinstance(definition, ObjectTypeDefinitionNode)
assert definition.name == name_node("Hello", (6, 11))
assert definition.description is None
Expand All @@ -441,8 +490,14 @@ def simple_field_with_list_arg():
assert definition.loc == (1, 49)

def simple_field_with_two_args():
body = "\ntype Hello {\n world(argOne: Boolean, argTwo: Int): String\n}"
definition = assert_definitions(body, (0, 61))
body = dedent(
"""
type Hello {
world(argOne: Boolean, argTwo: Int): String
}
"""
)
definition = assert_definitions(body, (0, 62))
assert isinstance(definition, ObjectTypeDefinitionNode)
assert definition.name == name_node("Hello", (6, 11))
assert definition.description is None
Expand Down

0 comments on commit 967a02d

Please sign in to comment.