<s> import sys <EOL> import unittest <EOL> import httplib <EOL> from libcloud . compute . base import Node <EOL> from libcloud . compute . drivers . cloudsigma import CloudSigmaBaseNodeDriver <EOL> from libcloud . compute . drivers . cloudsigma import str2dicts , str2list , dict2str <EOL> from test import MockHttp <EOL> from test . compute import TestCaseMixin <EOL> from test . file_fixtures import ComputeFileFixtures <EOL> class CloudSigmaTestCase ( unittest . TestCase , TestCaseMixin ) : <EOL> def setUp ( self ) : <EOL> CloudSigmaBaseNodeDriver . connectionCls . conn_classes = ( None , <EOL> CloudSigmaHttp ) <EOL> self . driver = CloudSigmaBaseNodeDriver ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) <EOL> def test_list_nodes ( self ) : <EOL> nodes = self . driver . list_nodes ( ) <EOL> self . assertTrue ( isinstance ( nodes , list ) ) <EOL> self . assertEqual ( len ( nodes ) , <NUM_LIT:1> ) <EOL> node = nodes [ <NUM_LIT:0> ] <EOL> self . assertEqual ( node . public_ip [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> self . assertEqual ( node . extra [ '<STR_LIT>' ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( node . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( node . extra [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> def test_list_sizes ( self ) : <EOL> images = self . driver . list_sizes ( ) <EOL> self . assertEqual ( len ( images ) , <NUM_LIT:9> ) <EOL> def test_list_images ( self ) : <EOL> sizes = self . driver . list_images ( ) <EOL> self . assertEqual ( len ( sizes ) , <NUM_LIT:10> ) <EOL> def test_list_locations_response ( self ) : <EOL> pass <EOL> def test_start_node ( self ) : <EOL> nodes = self . driver . list_nodes ( ) <EOL> node = nodes [ <NUM_LIT:0> ] <EOL> self . assertTrue ( self . driver . ex_start_node ( node ) ) <EOL> def test_shutdown_node ( self ) : <EOL> nodes = self . driver . list_nodes ( ) <EOL> node = nodes [ <NUM_LIT:0> ] <EOL> self . assertTrue ( self . driver . ex_stop_node ( node ) ) <EOL> self . assertTrue ( self . driver . ex_shutdown_node ( node ) ) <EOL> def test_reboot_node ( self ) : <EOL> node = self . driver . list_nodes ( ) [ <NUM_LIT:0> ] <EOL> self . assertTrue ( self . driver . reboot_node ( node ) ) <EOL> def test_destroy_node ( self ) : <EOL> node = self . driver . list_nodes ( ) [ <NUM_LIT:0> ] <EOL> self . assertTrue ( self . driver . destroy_node ( node ) ) <EOL> nodes = self . driver . list_nodes ( ) <EOL> def test_create_node ( self ) : <EOL> size = self . driver . list_sizes ( ) [ <NUM_LIT:0> ] <EOL> image = self . driver . list_images ( ) [ <NUM_LIT:0> ] <EOL> node = self . driver . create_node ( name = "<STR_LIT>" , image = image , size = size ) <EOL> self . assertTrue ( isinstance ( node , Node ) ) <EOL> def test_ex_static_ip_list ( self ) : <EOL> ips = self . driver . ex_static_ip_list ( ) <EOL> self . assertEqual ( len ( ips ) , <NUM_LIT:3> ) <EOL> def test_ex_static_ip_create ( self ) : <EOL> result = self . driver . ex_static_ip_create ( ) <EOL> self . assertEqual ( len ( result ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( len ( result [ <NUM_LIT:0> ] . keys ( ) ) , <NUM_LIT:6> ) <EOL> self . assertEqual ( len ( result [ <NUM_LIT:1> ] . keys ( ) ) , <NUM_LIT:6> ) <EOL> def test_ex_static_ip_destroy ( self ) : <EOL> result = self . driver . ex_static_ip_destroy ( '<STR_LIT>' ) <EOL> self . assertTrue ( result ) <EOL> def test_ex_drives_list ( self ) : <EOL> result = self . driver . ex_drives_list ( ) <EOL> self . assertEqual ( len ( result ) , <NUM_LIT:2> ) <EOL> def test_ex_drive_destroy ( self ) : <EOL> result = self . driver . ex_drive_destroy ( '<STR_LIT>' ) <EOL> self . assertTrue ( result ) <EOL> def test_ex_set_node_configuration ( self ) : <EOL> node = self . driver . list_nodes ( ) [ <NUM_LIT:0> ] <EOL> result = self . driver . ex_set_node_configuration ( node , ** { '<STR_LIT>' : <NUM_LIT:2> } ) <EOL> self . assertTrue ( result ) <EOL> def test_str2dicts ( self ) : <EOL> string = '<STR_LIT>' <EOL> result = str2dicts ( string ) <EOL> self . assertEqual ( len ( result ) , <NUM_LIT:2> ) <EOL> def test_str2list ( self ) : <EOL> string = '<STR_LIT>' <EOL> result = str2list ( string ) <EOL> self . assertEqual ( len ( result ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( result [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( result [ <NUM_LIT:1> ] , '<STR_LIT>' ) <EOL> self . assertEqual ( result [ <NUM_LIT:2> ] , '<STR_LIT>' ) <EOL> def test_dict2str ( self ) : <EOL> d = { '<STR_LIT>' : <NUM_LIT:5> , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : <NUM_LIT> } <EOL> result = dict2str ( d ) <EOL> self . assertTrue ( len ( result ) > <NUM_LIT:0> ) <EOL> self . assertTrue ( result . find ( '<STR_LIT>' ) >= <NUM_LIT:0> ) <EOL> self . assertTrue ( result . find ( '<STR_LIT>' ) >= <NUM_LIT:0> ) <EOL> self . assertTrue ( result . find ( '<STR_LIT>' ) >= <NUM_LIT:0> ) <EOL> class CloudSigmaHttp ( MockHttp ) : <EOL> fixtures = ComputeFileFixtures ( '<STR_LIT>' ) <EOL> def _drives_standard_info ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _servers_62fe7cde_4fb9_4c63_bd8c_e757930066a0_start ( self , method , url , body , headers ) : <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _servers_62fe7cde_4fb9_4c63_bd8c_e757930066a0_stop ( self , method , url , body , headers ) : <EOL> return ( httplib . NO_CONTENT , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _servers_62fe7cde_4fb9_4c63_bd8c_e757930066a0_destroy ( self , method , url , body , headers ) : <EOL> return ( httplib . NO_CONTENT , body , { } , httplib . responses [ httplib . NO_CONTENT ] ) <EOL> def _drives_d18119ce_7afa_474a_9242_e0384b160220_clone ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _drives_a814def5_1789_49a0_bf88_7abe7bb1682a_info ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _drives_info ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _servers_create ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _servers_info ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _resources_ip_list ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _resources_ip_create ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _resources_ip_1_2_3_4_destroy ( self , method , url , body , headers ) : <EOL> return ( httplib . NO_CONTENT , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _drives_d18119ce_7afa_474a_9242_e0384b160220_destroy ( self , method , url , body , headers ) : <EOL> return ( httplib . NO_CONTENT , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _servers_62fe7cde_4fb9_4c63_bd8c_e757930066a0_set ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( unittest . main ( ) ) </s>
