def test_same_field_two_arguments(): expect_passes_rule(UniqueArgumentNames, ''' { one: field(arg: "value") two: field(arg: "value") } ''')
def test_unique_fields(): expect_passes_rule(OverlappingFieldsCanBeMerged, ''' fragment uniqueFields on Dog { name nickname } ''')
def test_boolean_boolean_in_fragment(): expect_passes_rule(VariablesInAllowedPosition, ''' fragment booleanArgFrag on ComplicatedArgs { booleanArgField(booleanArg: $booleanArg) } query Query($booleanArg: Boolean) { complicatedArgs { ...booleanArgFrag } } ''') expect_passes_rule(VariablesInAllowedPosition, ''' query Query($booleanArg: Boolean) { complicatedArgs { ...booleanArgFrag } } fragment booleanArgFrag on ComplicatedArgs { booleanArgField(booleanArg: $booleanArg) } ''')
def test_boolean_non_null_boolean_in_directive_with_default(): expect_passes_rule(VariablesInAllowedPosition, ''' query Query($boolVar: Boolean = false) { dog @include(if: $boolVar) } ''')
def test_identical_fields_with_identical_args(): expect_passes_rule(OverlappingFieldsCanBeMerged, ''' fragment mergeIdenticalFieldsWithIdenticalArgs on Dog { doesKnowCommand(dogCommand: SIT) doesKnowCommand(dogCommand: SIT) } ''')
def test_aliased_object_field_selection(): expect_passes_rule(FieldsOnCorrectType, ''' fragment aliasedObjectFieldSelection on Dog { tn : __typename otherName : name } ''')
def test_identical_fields_with_identical_directives(): expect_passes_rule(OverlappingFieldsCanBeMerged, ''' fragment mergeSameFieldsWithSameDirectives on Dog { name @include(if: true) name @include(if: true) } ''')
def test_identical_fields(): expect_passes_rule(OverlappingFieldsCanBeMerged, ''' fragment mergeIdenticalFields on Dog { name name } ''')
def test_ignores_unknown_arguments(): expect_passes_rule(ProvidedNonNullArguments, ''' { dog { isHousetrained(unknownArgument: true) } }''')
def test_different_directives_with_different_aliases(): expect_passes_rule(OverlappingFieldsCanBeMerged, ''' fragment differentDirectivesWithDifferentAliases on Dog { nameIfTrue: name @include(if: true) nameIfFalse: name @include(if: false) } ''')
def test_no_arg_on_optional_arg(): expect_passes_rule(ProvidedNonNullArguments, ''' { dog { isHousetrained } }''')
def test_arg_on_optional_arg(): expect_passes_rule(ProvidedNonNullArguments, ''' { dog { isHousetrained(atOtherHomes: true) } }''')
def test_object_field_selection(): expect_passes_rule(FieldsOnCorrectType, ''' fragment objectFieldSelection on Dog { __typename name } ''')
def test_different_args_with_different_aliases(): expect_passes_rule(OverlappingFieldsCanBeMerged, ''' fragment differentArgsWithDifferentAliases on Dog { knowsSit: doesKnowCommand(dogCommand: SIT) knowsDown: doesKnowCommand(dogCommand: DOWN) } ''')
def test_interface_field_selection(): expect_passes_rule(FieldsOnCorrectType, ''' fragment interfaceFieldSelection on Pet { __typename name } ''')
def test_arg_on_optional_arg(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { dog { isHousetrained(atOtherHomes: true) } } ''')
def test_good_float_value(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { floatArgField(floatArg: 1.1) } } ''')
def test_aliased_object_field_selection(): expect_passes_rule( FieldsOnCorrectType, ''' fragment aliasedObjectFieldSelection on Dog { tn : __typename otherName : name } ''')
def test_good_string_value(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { stringArgField(stringArg: "foo") } } ''')
def test_good_boolean_value(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { booleanArgField(booleanArg: true) } } ''')
def test_good_int_value(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { intArgField(intArg: 2) } } ''')
def test_interface_field_selection(): expect_passes_rule( FieldsOnCorrectType, ''' fragment interfaceFieldSelection on Pet { __typename name } ''')
def test_valid_field_in_inline_fragment(): expect_passes_rule(FieldsOnCorrectType, ''' fragment objectFieldSelection on Pet { ... on Dog { name } } ''')
def test_same_field_two_arguments(): expect_passes_rule( UniqueArgumentNames, ''' { one: field(arg: "value") two: field(arg: "value") } ''')
def test_object_field_selection(): expect_passes_rule( FieldsOnCorrectType, ''' fragment objectFieldSelection on Dog { __typename name } ''')
def test_single_value_into_list(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { stringListArgField(stringListArg: "one") } } ''')
def test_boolean_non_null_boolean_in_directive_with_default(): expect_passes_rule( VariablesInAllowedPosition, ''' query Query($boolVar: Boolean = false) { dog @include(if: $boolVar) } ''')
def test_good_list_value(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { stringListArgField(stringListArg: ["one", "two"]) } } ''')
def test_no_arg_on_optional_arg(): expect_passes_rule( ProvidedNonNullArguments, ''' { dog { isHousetrained } }''')
def test_arg_on_optional_arg(): expect_passes_rule( ProvidedNonNullArguments, ''' { dog { isHousetrained(atOtherHomes: true) } }''')
def test_empty_list_value(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { stringListArgField(stringListArg: []) } } ''')
def test_ignores_unknown_arguments(): expect_passes_rule( ProvidedNonNullArguments, ''' { dog { isHousetrained(unknownArgument: true) } }''')
def test_partial_object_including_required(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { complexArgField(complexArg: { requiredField: false, intField: 4 }) } } ''')
def test_second_arg_on_multiple_optional(): expect_passes_rule(ProvidedNonNullArguments, ''' { complicatedArgs { multipleOpts(opt2: 1) } } ''')
def test_multiple_reqs_on_mixed_list(): expect_passes_rule(ProvidedNonNullArguments, ''' { complicatedArgs { multipleOptAndReq(req1: 3, req2: 4) } } ''')
def test_multiple_args_reverse_order(): expect_passes_rule(ProvidedNonNullArguments, ''' { complicatedArgs { multipleReqs(req2: 2, req1: 1) } } ''')
def test_no_args_on_multiple_optional(): expect_passes_rule(ProvidedNonNullArguments, ''' { complicatedArgs { multipleOpts } } ''')
def test_int_into_id(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { idArgField(idArg: 1) } } ''')
def test_all_reqs_and_opts_on_mixed_list(): expect_passes_rule(ProvidedNonNullArguments, ''' { complicatedArgs { multipleOptAndReq(req1: 3, req2: 4, opt1: 5, opt2: 6) } } ''')
def test_object_is_valid_inline_fragment_type(): expect_passes_rule(FragmentsOnCompositeTypes, ''' fragment validFragment on Pet { ... on Dog { barks } } ''')
def test_inline_fragment_without_type_is_valid(): expect_passes_rule(FragmentsOnCompositeTypes, ''' fragment validFragment on Pet { ... { name } } ''')
def test_string_into_id(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { idArgField(idArg: "someIdString") } } ''')
def test_good_enum_value(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { dog { doesKnowCommand(dogCommand: SIT) } } ''')
def test_partial_object_only_required(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { complexArgField(complexArg: { requiredField: true }) } } ''')
def test_partial_object_required_field_can_be_falsey(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { complexArgField(complexArg: { requiredField: false }) } } ''')
def test_optional_arg_despite_required_field_in_type(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { complexArgField } } ''')
def test_all_reqs_and_opts_on_mixed_list(self): expect_passes_rule(ArgumentsOfCorrectType, ''' { complicatedArgs { multipleOpts(req1: 3, req2: 4, opt1: 5, opt2: 6) } } ''')
def test_partial_object_including_required(self): expect_passes_rule( ArgumentsOfCorrectType, ''' { complicatedArgs { complexArgField(complexArg: { requiredField: false, intField: 4 }) } } ''')
def test_int_into_id(self): expect_passes_rule( ArgumentsOfCorrectType, ''' { complicatedArgs { idArgField(idArg: 1) } } ''')
def test_all_reqs_and_opts_on_mixed_list(): expect_passes_rule( ProvidedNonNullArguments, ''' { complicatedArgs { multipleOptAndReq(req1: 3, req2: 4, opt1: 5, opt2: 6) } } ''')
def test_partial_object_required_field_can_be_falsey(self): expect_passes_rule( ArgumentsOfCorrectType, ''' { complicatedArgs { complexArgField(complexArg: { requiredField: false }) } } ''')
def test_second_arg_on_multiple_optional(): expect_passes_rule( ProvidedNonNullArguments, ''' { complicatedArgs { multipleOpts(opt2: 1) } } ''')
def test_no_args_on_multiple_optional(): expect_passes_rule( ProvidedNonNullArguments, ''' { complicatedArgs { multipleOpts } } ''')
def test_multiple_args_reverse_order(): expect_passes_rule( ProvidedNonNullArguments, ''' { complicatedArgs { multipleReqs(req2: 2, req1: 1) } } ''')
def test_string_into_id(self): expect_passes_rule( ArgumentsOfCorrectType, ''' { complicatedArgs { idArgField(idArg: "someIdString") } } ''')
def test_multiple_reqs_on_mixed_list(): expect_passes_rule( ProvidedNonNullArguments, ''' { complicatedArgs { multipleOptAndReq(req1: 3, req2: 4) } } ''')
def test_object_is_valid_inline_fragment_type(): expect_passes_rule( FragmentsOnCompositeTypes, ''' fragment validFragment on Pet { ... on Dog { barks } } ''')
def test_good_enum_value(self): expect_passes_rule( ArgumentsOfCorrectType, ''' { dog { doesKnowCommand(dogCommand: SIT) } } ''')
def test_anon_operation_with_fragment(): expect_passes_rule(LoneAnonymousOperation, ''' { ...Foo } fragment Foo on Type { field } ''')
def test_with_well_placed_directives(): expect_passes_rule(KnownDirectives, ''' query Foo { name @include(if: true) ...Frag @include(if: true) skippedField @skip(if: true) ...SkippedFrag @skip(if: true) } ''')