<s> """<STR_LIT>""" <EOL> try : <EOL> import json <EOL> except ImportError : <EOL> import simplejson as json <EOL> from mock import Mock <EOL> from nose . tools import eq_ <EOL> from tests . utils import check_client_method , get_client_and_http , URL_BASE <EOL> def test_find ( ) : <EOL> item_id = <NUM_LIT> <EOL> client , check_assertions = check_client_method ( ) <EOL> result = client . Item . find ( item_id ) <EOL> check_assertions ( result , '<STR_LIT:GET>' , '<STR_LIT>' % item_id ) <EOL> client , check_assertions = check_client_method ( ) <EOL> result = client . Item . find ( item_id , basic = True ) <EOL> check_assertions ( result , '<STR_LIT:GET>' , '<STR_LIT>' % item_id ) <EOL> def test_filters ( ) : <EOL> app_id = <NUM_LIT> <EOL> attributes = { '<STR_LIT:a>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT> } <EOL> client , check_assertions = check_client_method ( ) <EOL> result = client . Item . filter ( app_id , attributes ) <EOL> check_assertions ( result , <EOL> '<STR_LIT:POST>' , <EOL> '<STR_LIT>' % app_id , <EOL> expected_body = json . dumps ( attributes ) , <EOL> expected_headers = { '<STR_LIT>' : '<STR_LIT:application/json>' } ) <EOL> def test_find_by_external_id ( ) : <EOL> app_id = <NUM_LIT> <EOL> external_id = <NUM_LIT> <EOL> client , check_assertions = check_client_method ( ) <EOL> result = client . Item . find_all_by_external_id ( app_id , external_id ) <EOL> check_assertions ( result , <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' % ( app_id , external_id ) ) <EOL> def test_revisions ( ) : <EOL> item_id = <NUM_LIT:255> <EOL> client , check_assertions = check_client_method ( ) <EOL> result = client . Item . revisions ( item_id ) <EOL> check_assertions ( result , <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' % ( item_id ) ) <EOL> def test_revision_difference ( ) : <EOL> item_id = <NUM_LIT:2> <EOL> from_id = <NUM_LIT:4> <EOL> to_id = <NUM_LIT:8> <EOL> client , check_assertions = check_client_method ( ) <EOL> result = client . Item . revision_difference ( item_id , from_id , to_id ) <EOL> check_assertions ( result , <EOL> '<STR_LIT:GET>' , <EOL> '<STR_LIT>' % ( item_id , from_id , to_id ) ) <EOL> def test_values ( ) : <EOL> item_id = <NUM_LIT> <EOL> client , check_assertions = check_client_method ( ) <EOL> result = client . Item . values ( item_id ) <EOL> check_assertions ( result , '<STR_LIT:GET>' , '<STR_LIT>' % item_id ) <EOL> def test_values_v2 ( ) : <EOL> item_id = <NUM_LIT> <EOL> client , check_assertions = check_client_method ( ) <EOL> result = client . Item . values_v2 ( item_id ) <EOL> check_assertions ( result , '<STR_LIT:GET>' , '<STR_LIT>' % item_id ) <EOL> def test_create ( ) : <EOL> app_id = <NUM_LIT:1> <EOL> attributes = { '<STR_LIT:1>' : <NUM_LIT:1> , '<STR_LIT:2>' : <NUM_LIT:3> , '<STR_LIT:5>' : '<STR_LIT>' } <EOL> client , check_assertions = check_client_method ( ) <EOL> result = client . Item . create ( app_id , attributes ) <EOL> check_assertions ( result , <EOL> '<STR_LIT:POST>' , <EOL> '<STR_LIT>' % app_id , <EOL> json . dumps ( attributes ) , <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } ) <EOL> def test_update ( ) : <EOL> app_id = <NUM_LIT:1> <EOL> attributes = { '<STR_LIT:1>' : <NUM_LIT:1> , '<STR_LIT:2>' : <NUM_LIT:3> , '<STR_LIT:5>' : '<STR_LIT>' } <EOL> client , check_assertions = check_client_method ( ) <EOL> result = client . Item . update ( app_id , attributes ) <EOL> check_assertions ( result , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' % app_id , <EOL> json . dumps ( attributes ) , <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } ) <EOL> client , check_assertions = check_client_method ( ) <EOL> result = client . Item . update ( app_id , attributes , silent = True ) <EOL> check_assertions ( result , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' % app_id , <EOL> json . dumps ( attributes ) , <EOL> { '<STR_LIT>' : '<STR_LIT:application/json>' } ) <EOL> def test_delete ( ) : <EOL> item_id = <NUM_LIT:1> <EOL> client , http = get_client_and_http ( ) <EOL> http . request = Mock ( return_value = ( None , None ) ) <EOL> result = client . Item . delete ( item_id ) <EOL> eq_ ( None , result ) <EOL> http . request . assert_called_once_with ( "<STR_LIT>" % ( URL_BASE , item_id ) , <EOL> '<STR_LIT>' , <EOL> body = None , <EOL> headers = { } ) </s>
