<s> import unittest <EOL> import utils <EOL> import sdk <EOL> change_file_permissions = [ '<STR_LIT>' ] <EOL> change_folder_permissions = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> list_permissions = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> readonly_permissions = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> class Permissions ( unittest . TestCase ) : <EOL> new_roles = { } <EOL> @ utils . allow ( services = list_permissions ) <EOL> def setUp ( self ) : <EOL> acc = self . account <EOL> if acc . service in list_permissions : <EOL> self . test_folder = utils . create_or_get_test_folder ( acc ) <EOL> self . test_file = utils . create_test_file ( acc ) <EOL> new_roles = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> if acc . service in change_folder_permissions : <EOL> self . new_roles = new_roles <EOL> self . test_folder . permissions . create ( data = self . new_roles ) <EOL> if acc . service in change_file_permissions : <EOL> self . new_roles = new_roles <EOL> self . test_file . permissions . create ( data = self . new_roles ) <EOL> def list_helper ( self , data ) : <EOL> result = data . permissions . all ( ) <EOL> self . assertIsInstance ( result , sdk . resources . AnnotatedList ) <EOL> owner_exists = False <EOL> for perm in result : <EOL> self . assertIsInstance ( perm , sdk . resources . Permission ) <EOL> if self . account . service not in readonly_permissions : <EOL> if perm . role == "<STR_LIT>" : <EOL> owner_exists = True <EOL> else : <EOL> self . assertIn ( perm . email , self . new_roles ) <EOL> self . assertEqual ( perm . role , self . new_roles . get ( perm . email ) ) <EOL> self . assertTrue ( owner_exists ) <EOL> def test_folder_permissions_list ( self ) : <EOL> if self . account . service in list_permissions : <EOL> self . list_helper ( self . test_folder ) <EOL> def test_folder_permissions_set ( self ) : <EOL> if self . account . service in change_folder_permissions : <EOL> self . new_roles = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> result = self . test_folder . permissions . create ( data = self . new_roles ) <EOL> self . assertIsInstance ( result . permissions , list ) <EOL> self . list_helper ( self . test_folder ) <EOL> def test_folder_permissions_update ( self ) : <EOL> if self . account . service in change_folder_permissions : <EOL> self . new_roles . update ( { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } ) <EOL> result = self . test_folder . permissions . update ( data = self . new_roles ) <EOL> self . assertIsInstance ( result . permissions , list ) <EOL> self . list_helper ( self . test_folder ) <EOL> def test_file_permissions_list ( self ) : <EOL> if self . account . service in list_permissions : <EOL> self . list_helper ( self . test_file ) <EOL> def test_file_permissions_set ( self ) : <EOL> if self . account . service in change_file_permissions : <EOL> self . new_roles = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> result = self . test_file . permissions . create ( data = self . new_roles ) <EOL> self . assertIsInstance ( result . permissions , list ) <EOL> self . list_helper ( self . test_file ) <EOL> def test_file_permissions_update ( self ) : <EOL> if self . account . service in change_file_permissions : <EOL> self . new_roles . update ( { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } ) <EOL> result = self . test_file . permissions . update ( data = self . new_roles ) <EOL> self . assertIsInstance ( result . permissions , list ) <EOL> self . list_helper ( self . test_file ) <EOL> def test_cases ( ) : <EOL> return [ utils . create_test_case ( acc , Permissions ) for acc in utils . accounts ] <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> suite = utils . create_suite ( test_cases ( ) ) <EOL> unittest . TextTestRunner ( verbosity = <NUM_LIT:2> ) . run ( suite ) </s>
