<s> from google . appengine . api import memcache <EOL> from mock import patch <EOL> import snippets <EOL> SNIPPET_VALUES = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:3> , <EOL> } <EOL> @ patch ( '<STR_LIT>' , return_value = '<STR_LIT:data>' ) <EOL> def test_get_data_not_present ( query_fn , testbed ) : <EOL> data = snippets . get_data ( ) <EOL> query_fn . assert_called_once_with ( ) <EOL> assert data == '<STR_LIT:data>' <EOL> memcache . delete ( '<STR_LIT:key>' ) <EOL> @ patch ( '<STR_LIT>' , return_value = '<STR_LIT:data>' ) <EOL> def test_get_data_present ( query_fn , testbed ) : <EOL> memcache . add ( '<STR_LIT:key>' , '<STR_LIT:data>' , <NUM_LIT> ) <EOL> data = snippets . get_data ( ) <EOL> query_fn . assert_not_called ( ) <EOL> assert data == '<STR_LIT:data>' <EOL> memcache . delete ( '<STR_LIT:key>' ) <EOL> def test_add_values ( testbed ) : <EOL> snippets . add_values ( ) <EOL> for key , value in SNIPPET_VALUES . iteritems ( ) : <EOL> assert memcache . get ( key ) == value </s>
