#NEWLINE# def test_graph_cycle_direct( session , graph , users , groups ) : #NEWLINE# #INDENT# ' Test adding members where all descendants already exist.' #NEWLINE# add_member ( groups [ 'team-sre' ] , users [ 'gary@a.co' ] ) #NEWLINE# add_member ( groups [ 'tech-ops' ] , users [ 'zay@a.co' ] ) #NEWLINE# add_member ( groups [ 'team-sre' ] , groups [ 'tech-ops' ] ) #NEWLINE# add_member ( groups [ 'tech-ops' ] , groups [ 'team-sre' ] ) #NEWLINE# session . commit ( ) #NEWLINE# graph . update_from_db ( session ) #NEWLINE# assert ( get_users ( graph , 'team-sre' ) == set ( [ 'gary@a.co' , 'zay@a.co' ] ) ) #NEWLINE# assert ( get_users ( graph , 'team-sre' , cutoff = 1 ) == set ( [ 'gary@a.co' ] ) ) #NEWLINE# assert ( get_users ( graph , 'tech-ops' ) == set ( [ 'gary@a.co' , 'zay@a.co' ] ) ) #NEWLINE# assert ( get_users ( graph , 'tech-ops' , cutoff = 1 ) == set ( [ 'zay@a.co' ] ) ) #NEWLINE# assert ( get_groups ( graph , 'gary@a.co' ) == set ( [ 'team-sre' , 'tech-ops' ] ) ) #NEWLINE# assert ( get_groups ( graph , 'gary@a.co' , cutoff = 1 ) == set ( [ 'team-sre' ] ) ) #NEWLINE# assert ( get_groups ( graph , 'zay@a.co' ) == set ( [ 'team-sre' , 'tech-ops' ] ) ) #NEWLINE# assert ( get_groups ( graph , 'zay@a.co' , cutoff = 1 ) == set ( [ 'tech-ops' ] ) )