#NEWLINE# def test_device_attributes( site ) : #NEWLINE# #INDENT# models . Attribute . objects . create ( site = device , resource_name = 'Device' , name = 'owner' ) #NEWLINE# device = models . Device . objects . create ( site = site , hostname = 'foobarhost' , attributes = { #NEWLINE# #INDENT# 'owner' : 'gary' , #NEWLINE# #UNINDENT# } ) #NEWLINE# assert ( device . get_attributes ( ) == { #NEWLINE# #INDENT# 'owner' : 'gary' , #NEWLINE# #UNINDENT# } ) #NEWLINE# device . set_attributes ( { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# assert ( device . get_attributes ( ) == { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# with pytest . raises ( exc . ValidationError ) : #NEWLINE# #INDENT# device . set_attributes ( None ) #NEWLINE# #UNINDENT# with pytest . raises ( exc . ValidationError ) : #NEWLINE# #INDENT# device . set_attributes ( { #NEWLINE# #INDENT# 0 : 'value' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# with pytest . raises ( exc . ValidationError ) : #NEWLINE# #INDENT# device . set_attributes ( { #NEWLINE# #INDENT# 'key' : 0 , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# with pytest . raises ( exc . ValidationError ) : #NEWLINE# #INDENT# device . set_attributes ( { #NEWLINE# #INDENT# 'made_up' : 'value' , #NEWLINE# #UNINDENT# } )