#NEWLINE# def test_retrieve_device( site ) : #NEWLINE# #INDENT# models . Attribute . objects . create ( site = site , resource_name = 'Device' , name = 'test' ) #NEWLINE# device1 = models . Device . objects . create ( site = site , hostname = 'device1' , attributes = { #NEWLINE# #INDENT# 'test' : 'foo' , #NEWLINE# #UNINDENT# } ) #NEWLINE# device2 = models . Device . objects . create ( site = site , hostname = 'device2' , attributes = { #NEWLINE# #INDENT# 'test' : 'bar' , #NEWLINE# #UNINDENT# } ) #NEWLINE# device3 = models . Device . objects . create ( site = site , hostname = 'device3' ) #NEWLINE# assert ( list ( site . devices . all ( ) ) == [ device1 , device2 , device3 ] ) #NEWLINE# assert ( list ( site . devices . by_attribute ( None , 'foo' ) ) == [ ] ) #NEWLINE# assert ( list ( site . devices . by_attribute ( 'test' , 'foo' ) ) == [ device1 ] )