<s> import sys <EOL> import time <EOL> import unittest <EOL> import base64 <EOL> from threading import Thread <EOL> from test import test_support <EOL> import appscale_datastore <EOL> import helper_functions as hf <EOL> from dbconstants import * <EOL> USERS_VALUES = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:1>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:yes>" ] <EOL> APPS_VALUES = [ "<STR_LIT:name>" , "<STR_LIT>" , "<STR_LIT:version>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:host>" , <EOL> "<STR_LIT:port>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:yes>" , "<STR_LIT:class>" , "<STR_LIT:index>" ] <EOL> ERROR_CODE = "<STR_LIT>" <EOL> datastore_name = None <EOL> def createRandomList ( number_of_columns , column_name_len ) : <EOL> columns = [ ] <EOL> for ii in range ( <NUM_LIT:0> , number_of_columns ) : <EOL> columns += [ hf . randomString ( column_name_len ) ] <EOL> return columns <EOL> class TestDatastoreFunctions ( unittest . TestCase ) : <EOL> def test_getput ( self ) : <EOL> ret = self . db . put_entity ( USERS_TABLE , "<STR_LIT:1>" , USERS_SCHEMA , USERS_VALUES ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . put_entity ( APPS_TABLE , "<STR_LIT:1>" , APPS_SCHEMA , APPS_VALUES ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( USERS_TABLE , "<STR_LIT:1>" , USERS_SCHEMA ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( USERS_VALUES [ <NUM_LIT:0> ] , ret [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( USERS_VALUES [ <NUM_LIT:1> ] , ret [ <NUM_LIT:2> ] ) <EOL> ret = self . db . get_entity ( APPS_TABLE , "<STR_LIT:1>" , APPS_SCHEMA ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( APPS_VALUES [ <NUM_LIT:0> ] , ret [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( APPS_VALUES [ <NUM_LIT:1> ] , ret [ <NUM_LIT:2> ] ) <EOL> ret = self . db . delete_row ( USERS_TABLE , "<STR_LIT:1>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_row ( APPS_TABLE , "<STR_LIT:1>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_getput_longkey ( self ) : <EOL> longKey = "<STR_LIT>" <EOL> ret = self . db . put_entity ( USERS_TABLE , longKey , USERS_SCHEMA , USERS_VALUES ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( USERS_TABLE , longKey , USERS_SCHEMA ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( USERS_VALUES [ <NUM_LIT:0> ] , ret [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( USERS_VALUES [ <NUM_LIT:1> ] , ret [ <NUM_LIT:2> ] ) <EOL> ret = self . db . delete_row ( USERS_TABLE , longKey ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_getput_longkey2 ( self ) : <EOL> longKey = "<STR_LIT>" <EOL> ret = self . db . put_entity ( USERS_TABLE , longKey , USERS_SCHEMA , USERS_VALUES ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( USERS_TABLE , longKey , USERS_SCHEMA ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( USERS_VALUES [ <NUM_LIT:0> ] , ret [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( USERS_VALUES [ <NUM_LIT:1> ] , ret [ <NUM_LIT:2> ] ) <EOL> ret = self . db . delete_row ( USERS_TABLE , longKey ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_get_each_column ( self ) : <EOL> table = "<STR_LIT>" <EOL> key = "<STR_LIT>" <EOL> columns = [ "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:3>" , "<STR_LIT:4>" , "<STR_LIT:5>" ] <EOL> values = [ "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:3>" , "<STR_LIT:4>" , "<STR_LIT:5>" ] <EOL> ret = self . db . put_entity ( table , key , columns , values ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( table , key , columns ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT:1>" , ret [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( "<STR_LIT:5>" , ret [ <NUM_LIT:5> ] ) <EOL> ret = self . db . get_entity ( table , key , [ "<STR_LIT:3>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT:3>" , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . get_entity ( table , key , [ "<STR_LIT:5>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT:5>" , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . get_entity ( table , key , [ "<STR_LIT:1>" , "<STR_LIT:2>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT:1>" , ret [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( "<STR_LIT:2>" , ret [ <NUM_LIT:2> ] ) <EOL> ret = self . db . get_entity ( table , key , [ "<STR_LIT:4>" , "<STR_LIT:5>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT:4>" , ret [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( "<STR_LIT:5>" , ret [ <NUM_LIT:2> ] ) <EOL> ret = self . db . delete_row ( table , key ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_table ( table ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def notest_get_nonexisting_key ( self ) : <EOL> ret = self . db . get_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> self . assertNotEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def notest_delete_nonexisting_key ( self ) : <EOL> ret = self . db . delete_row ( APPS_TABLE , "<STR_LIT>" ) <EOL> self . assertNotEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def notest_delete_row_nonexisting_table ( self ) : <EOL> ret = self . db . delete_row ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertNotEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def notest_delete_table_nonexisting_table ( self ) : <EOL> ret = self . db . delete_table ( "<STR_LIT>" ) <EOL> self . assertNotEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def notest_delete_row_twice ( self ) : <EOL> table = "<STR_LIT>" <EOL> key = "<STR_LIT>" <EOL> ret = self . db . put_entity ( table , key , [ "<STR_LIT:value>" ] , [ "<STR_LIT:value>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_row ( table , key ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_row ( table , key ) <EOL> self . assertNotEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_table ( table ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_update_column ( self ) : <EOL> table = "<STR_LIT>" <EOL> key = "<STR_LIT>" <EOL> columns = [ "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:3>" , "<STR_LIT:4>" , "<STR_LIT:5>" ] <EOL> values = [ "<STR_LIT:1>" , "<STR_LIT:2>" , "<STR_LIT:3>" , "<STR_LIT:4>" , "<STR_LIT:5>" ] <EOL> ret = self . db . put_entity ( table , key , columns , values ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( table , key , columns ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT:1>" , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . put_entity ( table , key , [ "<STR_LIT:1>" ] , [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( table , key , columns ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT>" , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . delete_row ( table , key ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_table ( table ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_enabled ( self ) : <EOL> ret = self . db . put_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] , [ "<STR_LIT:true>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT:true>" , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . put_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] , [ "<STR_LIT:false>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT:false>" , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . delete_row ( APPS_TABLE , "<STR_LIT>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_language ( self ) : <EOL> ret = self . db . put_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] , [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT>" , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . delete_row ( APPS_TABLE , "<STR_LIT>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_genid ( self ) : <EOL> ret = self . db . put_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] , [ "<STR_LIT:1>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> err , value = ret <EOL> value = int ( value ) <EOL> self . assertEqual ( <NUM_LIT:1> , value ) <EOL> ret = self . db . put_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] , [ str ( value + <NUM_LIT:1> ) ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT:2>" , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . delete_row ( APPS_TABLE , "<STR_LIT>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_getschema ( self ) : <EOL> user_schema = self . db . get_schema ( USERS_TABLE ) <EOL> self . assertEqual ( self . error_code , user_schema [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , user_schema . count ( "<STR_LIT:email>" ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , user_schema . count ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , user_schema . count ( "<STR_LIT>" ) ) <EOL> app_schema = self . db . get_schema ( APPS_TABLE ) <EOL> self . assertEqual ( self . error_code , app_schema [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( <NUM_LIT:1> , app_schema . count ( "<STR_LIT:name>" ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , app_schema . count ( "<STR_LIT:version>" ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , app_schema . count ( "<STR_LIT>" ) ) <EOL> def test_getschema_nonexisting_table ( self ) : <EOL> ret = self . db . get_schema ( "<STR_LIT>" ) <EOL> self . assertNotEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_getput_tar ( self ) : <EOL> f = open ( '<STR_LIT>' % APPSCALE_HOME , '<STR_LIT:r>' ) <EOL> data = f . read ( ) <EOL> encdata = base64 . b64encode ( data ) <EOL> ret = self . db . put_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] , [ encdata ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( APPS_TABLE , "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( encdata , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . delete_row ( APPS_TABLE , "<STR_LIT>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_getput_binary ( self ) : <EOL> f = open ( '<STR_LIT>' % APPSCALE_HOME , '<STR_LIT:r>' ) <EOL> data = f . read ( ) <EOL> ret = self . db . put_entity ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] , [ data ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( data , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . delete_row ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_table ( "<STR_LIT>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_getput_bigbinary ( self ) : <EOL> f = open ( '<STR_LIT>' % APPSCALE_HOME , '<STR_LIT:r>' ) <EOL> data = f . read ( ) <EOL> ret = self . db . put_entity ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] , [ data ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( data , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . delete_row ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_table ( "<STR_LIT>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_gettable ( self ) : <EOL> table = "<STR_LIT>" <EOL> schema = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> ret = self . db . put_entity ( table , "<STR_LIT:1>" , schema , [ "<STR_LIT:1>" , "<STR_LIT:2>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . put_entity ( table , "<STR_LIT:2>" , schema , [ "<STR_LIT:3>" , "<STR_LIT:4>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_table ( table , schema ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT:1>" , ret [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( "<STR_LIT:2>" , ret [ <NUM_LIT:2> ] ) <EOL> self . assertEqual ( "<STR_LIT:3>" , ret [ <NUM_LIT:3> ] ) <EOL> self . assertEqual ( "<STR_LIT:4>" , ret [ <NUM_LIT:4> ] ) <EOL> ret = self . db . delete_table ( table ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_delete_table ( self ) : <EOL> key = "<STR_LIT>" <EOL> ret = self . db . put_entity ( "<STR_LIT>" , key , [ "<STR_LIT:value>" ] , [ "<STR_LIT:value>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( "<STR_LIT>" , key , [ "<STR_LIT:value>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( "<STR_LIT:value>" , ret [ <NUM_LIT:1> ] ) <EOL> ret = self . db . delete_table ( "<STR_LIT>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . get_entity ( "<STR_LIT>" , key , [ "<STR_LIT:value>" ] ) <EOL> self . assertNotEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def notest_delete_table_twice ( self ) : <EOL> key = "<STR_LIT>" <EOL> ret = self . db . put_entity ( "<STR_LIT>" , key , [ "<STR_LIT:value>" ] , [ "<STR_LIT:value>" ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_table ( "<STR_LIT>" ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_table ( "<STR_LIT>" ) <EOL> self . assertNotEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_200requests ( self ) : <EOL> table = "<STR_LIT>" <EOL> prekey = "<STR_LIT:value>" <EOL> valuename = "<STR_LIT:value>" <EOL> value = "<STR_LIT>" <EOL> for i in range ( <NUM_LIT:200> ) : <EOL> key = prekey + str ( i ) <EOL> ret = self . db . put_entity ( table , key , [ valuename ] , [ value ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> for i in range ( <NUM_LIT:200> ) : <EOL> key = prekey + str ( i ) <EOL> ret = self . db . get_entity ( table , key , [ valuename ] ) <EOL> if len ( ret ) < <NUM_LIT:2> : <EOL> ret [ <NUM_LIT:1> ] = "<STR_LIT>" <EOL> self . assertEqual ( value , ret [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_row ( table , key ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> ret = self . db . delete_table ( table ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_10multi_requests ( self ) : <EOL> table = "<STR_LIT>" <EOL> valuename = "<STR_LIT:value>" <EOL> value = "<STR_LIT>" <EOL> ret = self . db . put_entity ( table , "<STR_LIT>" , [ valuename ] , [ value ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> tlist = [ ] <EOL> for tnum in range ( <NUM_LIT:10> ) : <EOL> key = "<STR_LIT:key>" + str ( tnum ) + "<STR_LIT>" <EOL> thread = Thread ( target = self . _multi50requests , args = [ key ] ) <EOL> thread . start ( ) <EOL> tlist . append ( thread ) <EOL> for t in tlist : <EOL> t . join ( ) <EOL> ret = self . db . delete_table ( table ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def test_20multi_requests ( self ) : <EOL> table = "<STR_LIT>" <EOL> valuename = "<STR_LIT:value>" <EOL> value = "<STR_LIT>" <EOL> ret = self . db . put_entity ( table , "<STR_LIT>" , [ valuename ] , [ value ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> tlist = [ ] <EOL> for tnum in range ( <NUM_LIT:20> ) : <EOL> key = "<STR_LIT:key>" + str ( tnum ) + "<STR_LIT>" <EOL> thread = Thread ( target = self . _multi50requests , args = [ key ] ) <EOL> thread . start ( ) <EOL> tlist . append ( thread ) <EOL> for t in tlist : <EOL> t . join ( ) <EOL> ret = self . db . delete_table ( table ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def _multi50requests ( self , prekey ) : <EOL> table = "<STR_LIT>" <EOL> valuename = "<STR_LIT:value>" <EOL> value = "<STR_LIT>" <EOL> for i in range ( <NUM_LIT:50> ) : <EOL> key = prekey + str ( i ) <EOL> ret = self . db . put_entity ( table , key , [ valuename ] , [ value ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> for i in range ( <NUM_LIT:50> ) : <EOL> key = prekey + str ( i ) <EOL> ret = self . db . get_entity ( table , key , [ valuename ] ) <EOL> if len ( ret ) < <NUM_LIT:2> : <EOL> ret [ <NUM_LIT:1> ] = "<STR_LIT>" <EOL> self . assertEqual ( value , ret [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> for i in range ( <NUM_LIT:50> ) : <EOL> key = prekey + str ( i ) <EOL> ret = self . db . delete_row ( table , key ) <EOL> self . assertEqual ( self . error_code , ret [ <NUM_LIT:0> ] ) <EOL> def setUp ( self ) : <EOL> global datastore_name <EOL> self . db = appscale_datastore . DatastoreFactory . getDatastore ( datastore_name ) <EOL> self . error_code = ERROR_CODE <EOL> def test_main ( ) : <EOL> filename = "<STR_LIT>" % APPSCALE_HOME <EOL> os . system ( "<STR_LIT>" % filename ) <EOL> global datastore_name <EOL> datastore_name = sys . argv [ <NUM_LIT:1> ] <EOL> test_support . run_unittest ( TestDatastoreFunctions ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
