<s> import runabove <EOL> import unittest <EOL> import mock <EOL> import json <EOL> class TestSshKey ( unittest . TestCase ) : <EOL> answer_list = '''<STR_LIT>''' <EOL> answer_one = '''<STR_LIT>''' <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def setUp ( self , mock_wrapper , mock_client ) : <EOL> self . mock_wrapper = mock_wrapper <EOL> self . mock_client = mock_client <EOL> self . mock_client . regions = runabove . region . RegionManager ( mock_wrapper , <EOL> mock_client ) <EOL> self . ssh_keys = runabove . ssh_key . SSHKeyManager ( mock_wrapper , <EOL> mock_client ) <EOL> def test_base_path ( self ) : <EOL> self . assertEqual ( self . ssh_keys . basepath , '<STR_LIT>' ) <EOL> def test_list ( self ) : <EOL> self . mock_wrapper . get . return_value = json . loads ( self . answer_list ) <EOL> ssh_key_list = self . ssh_keys . list ( ) <EOL> self . mock_wrapper . get . assert_called_once_with ( <EOL> self . ssh_keys . basepath <EOL> ) <EOL> self . assertIsInstance ( ssh_key_list , list ) <EOL> self . assertTrue ( len ( ssh_key_list ) > <NUM_LIT:0> ) <EOL> def test_list_by_region ( self ) : <EOL> region_name = '<STR_LIT>' <EOL> self . mock_wrapper . get . return_value = json . loads ( self . answer_list ) <EOL> ssh_key_list = self . ssh_keys . list_by_region ( region_name ) <EOL> self . mock_wrapper . get . assert_called_once_with ( <EOL> self . ssh_keys . basepath , <EOL> { '<STR_LIT>' : region_name } <EOL> ) <EOL> self . assertIsInstance ( ssh_key_list , list ) <EOL> self . assertTrue ( len ( ssh_key_list ) > <NUM_LIT:0> ) <EOL> for ssh_key in ssh_key_list : <EOL> self . assertIsInstance ( ssh_key , runabove . ssh_key . SSHKey ) <EOL> self . assertEqual ( ssh_key . region . name , region_name ) <EOL> def test_get_by_name ( self ) : <EOL> region_name = '<STR_LIT>' <EOL> name = "<STR_LIT>" <EOL> self . mock_wrapper . encode_for_api . return_value = name <EOL> self . mock_wrapper . get . return_value = json . loads ( self . answer_one ) <EOL> ssh_key = self . ssh_keys . get_by_name ( region_name , name ) <EOL> self . mock_wrapper . get . assert_called_once_with ( <EOL> self . ssh_keys . basepath + '<STR_LIT:/>' + name , <EOL> { '<STR_LIT>' : region_name } <EOL> ) <EOL> self . assertEqual ( ssh_key . name , name ) <EOL> def test_create_ssh_key ( self ) : <EOL> region_name = '<STR_LIT>' <EOL> name = "<STR_LIT>" <EOL> public_key = "<STR_LIT>" <EOL> content = { <EOL> "<STR_LIT:name>" : name , <EOL> "<STR_LIT>" : public_key , <EOL> "<STR_LIT>" : region_name <EOL> } <EOL> self . mock_wrapper . get . return_value = json . loads ( self . answer_one ) <EOL> self . ssh_keys . create ( region_name , name , public_key ) <EOL> self . mock_wrapper . post . assert_called_once_with ( <EOL> self . ssh_keys . basepath , content <EOL> ) <EOL> def test_delete ( self ) : <EOL> region_name = '<STR_LIT>' <EOL> name = "<STR_LIT>" <EOL> self . mock_wrapper . encode_for_api . return_value = name <EOL> self . ssh_keys . delete ( region_name , name ) <EOL> self . mock_wrapper . delete . assert_called_once_with ( <EOL> self . ssh_keys . basepath + '<STR_LIT:/>' + name , <EOL> { '<STR_LIT>' : region_name } <EOL> ) <EOL> class TestSSHKeyObject ( unittest . TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def setUp ( self , mock_ssh_keys ) : <EOL> self . mock_ssh_keys = mock_ssh_keys <EOL> self . ssh_key = runabove . ssh_key . SSHKey ( <EOL> self . mock_ssh_keys , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ) <EOL> def test_delete_object ( self ) : <EOL> self . ssh_key . delete ( ) <EOL> self . mock_ssh_keys . delete . assert_called_once_with ( <EOL> self . ssh_key . region , <EOL> self . ssh_key <EOL> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
