<s> import sys <EOL> import unittest <EOL> try : <EOL> import simplejson as json <EOL> except ImportError : <EOL> import json <EOL> from libcloud . utils . py3 import httplib <EOL> from libcloud . compute . drivers . vultr import VultrNodeDriver <EOL> from libcloud . test import LibcloudTestCase , MockHttpTestCase <EOL> from libcloud . test . file_fixtures import ComputeFileFixtures <EOL> from libcloud . test . secrets import VULTR_PARAMS <EOL> class VultrTests ( LibcloudTestCase ) : <EOL> def setUp ( self ) : <EOL> VultrNodeDriver . connectionCls . conn_classes = ( VultrMockHttp , VultrMockHttp ) <EOL> VultrMockHttp . type = None <EOL> self . driver = VultrNodeDriver ( * VULTR_PARAMS ) <EOL> def test_list_images_success ( self ) : <EOL> images = self . driver . list_images ( ) <EOL> self . assertTrue ( len ( images ) >= <NUM_LIT:1> ) <EOL> image = images [ <NUM_LIT:0> ] <EOL> self . assertTrue ( image . id is not None ) <EOL> self . assertTrue ( image . name is not None ) <EOL> def test_list_sizes_success ( self ) : <EOL> sizes = self . driver . list_sizes ( ) <EOL> self . assertTrue ( len ( sizes ) == <NUM_LIT> ) <EOL> size = sizes [ <NUM_LIT:0> ] <EOL> self . assertTrue ( size . id is not None ) <EOL> self . assertEqual ( size . name , '<STR_LIT>' ) <EOL> self . assertEqual ( size . ram , <NUM_LIT> ) <EOL> size = sizes [ <NUM_LIT> ] <EOL> self . assertTrue ( size . id is not None ) <EOL> self . assertEqual ( size . name , '<STR_LIT>' ) <EOL> self . assertEqual ( size . ram , <NUM_LIT> ) <EOL> def test_list_locations_success ( self ) : <EOL> locations = self . driver . list_locations ( ) <EOL> self . assertTrue ( len ( locations ) >= <NUM_LIT:1> ) <EOL> location = locations [ <NUM_LIT:0> ] <EOL> self . assertEqual ( location . id , '<STR_LIT:1>' ) <EOL> self . assertEqual ( location . name , '<STR_LIT>' ) <EOL> def test_list_nodes_success ( self ) : <EOL> nodes = self . driver . list_nodes ( ) <EOL> self . assertEqual ( len ( nodes ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( nodes [ <NUM_LIT:0> ] . id , '<STR_LIT:1>' ) <EOL> self . assertEqual ( nodes [ <NUM_LIT:0> ] . public_ips , [ '<STR_LIT>' ] ) <EOL> def test_reboot_node_success ( self ) : <EOL> node = self . driver . list_nodes ( ) [ <NUM_LIT:0> ] <EOL> result = self . driver . reboot_node ( node ) <EOL> self . assertTrue ( result ) <EOL> def test_destroy_node_success ( self ) : <EOL> node = self . driver . list_nodes ( ) [ <NUM_LIT:0> ] <EOL> result = self . driver . destroy_node ( node ) <EOL> self . assertTrue ( result ) <EOL> class VultrMockHttp ( MockHttpTestCase ) : <EOL> fixtures = ComputeFileFixtures ( '<STR_LIT>' ) <EOL> def _v1_regions_list ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _v1_os_list ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _v1_plans_list ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _v1_server_list ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , { } , httplib . responses [ httplib . OK ] ) <EOL> def _v1_server_destroy ( self , method , url , body , headers ) : <EOL> return ( httplib . OK , "<STR_LIT>" , { } , httplib . responses [ httplib . OK ] ) <EOL> def _v1_server_reboot ( self , method , url , body , headers ) : <EOL> return ( httplib . OK , "<STR_LIT>" , { } , httplib . responses [ httplib . OK ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( unittest . main ( ) ) </s>
