<s> from graphql . core . language . location import SourceLocation as L <EOL> from graphql . core . validation . rules import NoFragmentCycles <EOL> from . utils import expect_fails_rule , expect_passes_rule <EOL> def cycle_error_message ( fragment_name , spread_names , * locations ) : <EOL> return { <EOL> '<STR_LIT:message>' : NoFragmentCycles . cycle_error_message ( fragment_name , spread_names ) , <EOL> '<STR_LIT>' : list ( locations ) <EOL> } <EOL> def test_single_reference_is_valid ( ) : <EOL> expect_passes_rule ( NoFragmentCycles , '''<STR_LIT>''' ) <EOL> def test_spreading_twice_is_not_circular ( ) : <EOL> expect_passes_rule ( NoFragmentCycles , '''<STR_LIT>''' ) <EOL> def test_spreading_twice_indirectly_is_not_circular ( ) : <EOL> expect_passes_rule ( NoFragmentCycles , '''<STR_LIT>''' ) <EOL> def test_double_spread_within_abstract_types ( ) : <EOL> expect_passes_rule ( NoFragmentCycles , '''<STR_LIT>''' ) <EOL> def test_does_not_raise_false_positive_on_unknown_fragment ( ) : <EOL> expect_passes_rule ( NoFragmentCycles , '''<STR_LIT>''' ) <EOL> def test_spreading_recursively_within_field_fails ( ) : <EOL> expect_fails_rule ( NoFragmentCycles , '''<STR_LIT>''' , [ <EOL> cycle_error_message ( '<STR_LIT>' , [ ] , L ( <NUM_LIT:2> , <NUM_LIT> ) ) <EOL> ] ) <EOL> def test_no_spreading_itself_directly ( ) : <EOL> expect_fails_rule ( NoFragmentCycles , '''<STR_LIT>''' , [ <EOL> cycle_error_message ( '<STR_LIT>' , [ ] , L ( <NUM_LIT:2> , <NUM_LIT> ) ) <EOL> ] ) <EOL> def test_no_spreading_itself_directly_within_inline_fragment ( ) : <EOL> expect_fails_rule ( NoFragmentCycles , '''<STR_LIT>''' , [ <EOL> cycle_error_message ( '<STR_LIT>' , [ ] , L ( <NUM_LIT:4> , <NUM_LIT> ) ) <EOL> ] ) <EOL> def test_no_spreading_itself_indirectly ( ) : <EOL> expect_fails_rule ( NoFragmentCycles , '''<STR_LIT>''' , [ <EOL> cycle_error_message ( '<STR_LIT>' , [ '<STR_LIT>' ] , L ( <NUM_LIT:2> , <NUM_LIT> ) , L ( <NUM_LIT:3> , <NUM_LIT> ) ) <EOL> ] ) <EOL> def test_no_spreading_itself_indirectly_reports_opposite_order ( ) : <EOL> expect_fails_rule ( NoFragmentCycles , '''<STR_LIT>''' , [ <EOL> cycle_error_message ( '<STR_LIT>' , [ '<STR_LIT>' ] , L ( <NUM_LIT:2> , <NUM_LIT> ) , L ( <NUM_LIT:3> , <NUM_LIT> ) ) <EOL> ] ) <EOL> def test_no_spreading_itself_indirectly_within_inline_fragment ( ) : <EOL> expect_fails_rule ( NoFragmentCycles , '''<STR_LIT>''' , [ <EOL> cycle_error_message ( '<STR_LIT>' , [ '<STR_LIT>' ] , L ( <NUM_LIT:4> , <NUM_LIT> ) , L ( <NUM_LIT:9> , <NUM_LIT> ) ) <EOL> ] ) <EOL> def test_no_spreading_itself_deeply ( ) : <EOL> expect_fails_rule ( <EOL> NoFragmentCycles , '''<STR_LIT>''' , [ <EOL> cycle_error_message ( <EOL> '<STR_LIT>' , [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , L ( <EOL> <NUM_LIT:2> , <NUM_LIT> ) , L ( <EOL> <NUM_LIT:3> , <NUM_LIT> ) , L ( <EOL> <NUM_LIT:4> , <NUM_LIT> ) , L ( <EOL> <NUM_LIT:8> , <NUM_LIT> ) , L ( <EOL> <NUM_LIT:9> , <NUM_LIT> ) ) , cycle_error_message ( <EOL> '<STR_LIT>' , [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , L ( <EOL> <NUM_LIT:8> , <NUM_LIT> ) , L ( <EOL> <NUM_LIT:9> , <NUM_LIT> ) , L ( <EOL> <NUM_LIT:5> , <NUM_LIT> ) , L ( <EOL> <NUM_LIT:6> , <NUM_LIT> ) , L ( <EOL> <NUM_LIT:7> , <NUM_LIT> ) ) ] ) <EOL> def test_no_spreading_itself_deeply_two_paths ( ) : <EOL> expect_fails_rule ( NoFragmentCycles , '''<STR_LIT>''' , [ <EOL> cycle_error_message ( '<STR_LIT>' , [ '<STR_LIT>' ] , L ( <NUM_LIT:2> , <NUM_LIT> ) , L ( <NUM_LIT:3> , <NUM_LIT> ) ) , <EOL> cycle_error_message ( '<STR_LIT>' , [ '<STR_LIT>' ] , L ( <NUM_LIT:2> , <NUM_LIT> ) , L ( <NUM_LIT:4> , <NUM_LIT> ) ) <EOL> ] ) <EOL> def test_no_spreading_itself_deeply_two_paths_alt_reverse_order ( ) : <EOL> expect_fails_rule ( NoFragmentCycles , '''<STR_LIT>''' , [ <EOL> cycle_error_message ( '<STR_LIT>' , [ '<STR_LIT>' ] , L ( <NUM_LIT:2> , <NUM_LIT> ) , L ( <NUM_LIT:4> , <NUM_LIT> ) ) , <EOL> cycle_error_message ( '<STR_LIT>' , [ '<STR_LIT>' ] , L ( <NUM_LIT:4> , <NUM_LIT> ) , L ( <NUM_LIT:3> , <NUM_LIT> ) ) <EOL> ] ) <EOL> def test_no_spreading_itself_deeply_and_immediately ( ) : <EOL> expect_fails_rule ( NoFragmentCycles , '''<STR_LIT>''' , [ <EOL> cycle_error_message ( '<STR_LIT>' , [ ] , L ( <NUM_LIT:3> , <NUM_LIT> ) ) , <EOL> cycle_error_message ( '<STR_LIT>' , [ '<STR_LIT>' , '<STR_LIT>' ] , L ( <NUM_LIT:2> , <NUM_LIT> ) , L ( <NUM_LIT:3> , <NUM_LIT> ) , L ( <NUM_LIT:4> , <NUM_LIT> ) ) , <EOL> cycle_error_message ( '<STR_LIT>' , [ '<STR_LIT>' ] , L ( <NUM_LIT:3> , <NUM_LIT> ) , L ( <NUM_LIT:4> , <NUM_LIT> ) ) <EOL> ] ) </s>
