#NEWLINE# def test_partial_update( site , client ) : #NEWLINE# #INDENT# 'Test PATCH operations to partially update an Interface.' #NEWLINE# ifc_uri = site . list_uri ( 'interface' ) #NEWLINE# dev_uri = site . list_uri ( 'device' ) #NEWLINE# net_uri = site . list_uri ( 'network' ) #NEWLINE# attr_uri = site . list_uri ( 'attribute' ) #NEWLINE# dev_resp = client . create ( dev_uri , hostname = 'foo-bar1' ) #NEWLINE# dev = get_result ( dev_resp ) #NEWLINE# net_resp = client . create ( net_uri , cidr = '10.1.1.0/24' ) #NEWLINE# net = get_result ( net_resp ) #NEWLINE# client . create ( attr_uri , name = 'attr1' , resource_name = 'Interface' ) #NEWLINE# addresses = [ '10.1.1.1/32' ] #NEWLINE# ifc_resp = client . create ( ifc_uri , device = dev [ 'id' ] , name = 'eth0' , addresses = addresses , attributes = { #NEWLINE# #INDENT# 'attr1' : 'value' , #NEWLINE# #UNINDENT# } ) #NEWLINE# ifc = get_result ( ifc_resp ) #NEWLINE# ifc_pk_uri = site . detail_uri ( 'interface' , id = ifc [ 'id' ] ) #NEWLINE# params = { #NEWLINE# #INDENT# 'name' : 'ge-0/0/1' , #NEWLINE# #UNINDENT# } #NEWLINE# assert_error ( client . update ( ifc_pk_uri , ** params ) , status . HTTP_400_BAD_REQUEST ) #NEWLINE# payload = copy . deepcopy ( ifc ) #NEWLINE# params = { #NEWLINE# #INDENT# 'name' : 'ge-0/0/1' , #NEWLINE# #UNINDENT# } #NEWLINE# payload . update ( params ) #NEWLINE# assert_success ( client . partial_update ( ifc_pk_uri , ** params ) , client ) #NEWLINE# params = { #NEWLINE# #INDENT# 'attributes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# payload . update ( params ) #NEWLINE# assert_success ( client . partial_update ( ifc_pk_uri , ** params ) , payload ) #NEWLINE# params = { #NEWLINE# #INDENT# 'addresses' : [ '10.1.1.2/32' ] , #NEWLINE# #UNINDENT# } #NEWLINE# payload . update ( params ) #NEWLINE# assert_success ( client . partial_update ( ifc_pk_uri , ** params ) , payload ) #NEWLINE# params = { #NEWLINE# #INDENT# 'addresses' : [ ] , #NEWLINE# #UNINDENT# } #NEWLINE# payload . update ( params ) #NEWLINE# payload [ 'networks' ] = [ ] #NEWLINE# assert_success ( client . partial_update ( ifc_pk_uri , ** params ) , payload )