#NEWLINE# def test_crud_version_two( self ) : #NEWLINE# #INDENT# if ( not conf . settings . RUN_LIVE_TESTS ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# conf . configure_cache ( self . client , 'test_crud_version_two' ) #NEWLINE# self . client . api_version = '2' #NEWLINE# entry = create_element ( 'entry' ) #NEWLINE# entry . _other_elements . append ( create_element ( 'title' , ATOM , 'Jeff' , { #NEWLINE# #INDENT# 'type' : 'text' , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# entry . _other_elements . append ( create_element ( 'email' , GD , attributes = { #NEWLINE# #INDENT# 'address' : 'j.s@google.com' , #NEWLINE# 'rel' : WORK_REL , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# http_request = atom . http_core . HttpRequest ( ) #NEWLINE# http_request . add_body_part ( entry . to_string ( ) , 'application/atom+xml' ) #NEWLINE# posted = self . client . request ( 'POST' , 'http://www.google.com/m8/feeds/contacts/default/full' , converter = element_from_string , http_request = http_request ) #NEWLINE# self_link = None #NEWLINE# edit_link = None #NEWLINE# for link in posted . get_elements ( 'link' , ATOM ) : #NEWLINE# #INDENT# if ( link . get_attributes ( 'rel' ) [ 0 ] . value == 'self' ) : #NEWLINE# #INDENT# self_link = link . get_attributes ( 'href' ) [ 0 ] . value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( link . get_attributes ( 'rel' ) [ 0 ] . value == 'edit' ) : #NEWLINE# #INDENT# edit_link = link . get_attributes ( 'href' ) [ 0 ] . value #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . assertTrue ( ( self_link is not None ) ) #NEWLINE# self . assertTrue ( ( edit_link is not None ) ) #NEWLINE# etag = posted . get_attributes ( 'etag' ) [ 0 ] . value #NEWLINE# self . assertTrue ( ( etag is not None ) ) #NEWLINE# self . assertTrue ( ( len ( etag ) > 0 ) ) #NEWLINE# http_request = atom . http_core . HttpRequest ( ) #NEWLINE# http_request . headers [ 'If-Match' ] = link #NEWLINE# self . client . request ( 'DELETE' , edit_link , http_request = http_request )