<s> import sys <EOL> import unittest <EOL> from libcloud . common . types import InvalidCredsError <EOL> from libcloud . common . digitalocean import DigitalOceanBaseDriver <EOL> from libcloud . test import LibcloudTestCase , MockHttpTestCase <EOL> from libcloud . test . file_fixtures import FileFixtures <EOL> from libcloud . test . secrets import DIGITALOCEAN_v2_PARAMS <EOL> from libcloud . utils . py3 import httplib <EOL> class DigitalOceanTests ( LibcloudTestCase ) : <EOL> def setUp ( self ) : <EOL> DigitalOceanBaseDriver . connectionCls . conn_classes = ( None , DigitalOceanMockHttp ) <EOL> DigitalOceanMockHttp . type = None <EOL> self . driver = DigitalOceanBaseDriver ( * DIGITALOCEAN_v2_PARAMS ) <EOL> def test_authentication ( self ) : <EOL> DigitalOceanMockHttp . type = '<STR_LIT>' <EOL> self . assertRaises ( InvalidCredsError , self . driver . ex_account_info ) <EOL> def test_ex_account_info ( self ) : <EOL> account_info = self . driver . ex_account_info ( ) <EOL> self . assertEqual ( account_info [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' ) <EOL> self . assertTrue ( account_info [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( account_info [ '<STR_LIT:email>' ] , '<STR_LIT>' ) <EOL> self . assertEqual ( account_info [ '<STR_LIT>' ] , <NUM_LIT:10> ) <EOL> def test_ex_list_events ( self ) : <EOL> events = self . driver . ex_list_events ( ) <EOL> self . assertEqual ( events , [ ] ) <EOL> def test_ex_get_event ( self ) : <EOL> action = self . driver . ex_get_event ( '<STR_LIT>' ) <EOL> self . assertEqual ( action [ "<STR_LIT:id>" ] , <NUM_LIT> ) <EOL> self . assertEqual ( action [ "<STR_LIT:status>" ] , "<STR_LIT>" ) <EOL> self . assertEqual ( action [ "<STR_LIT:type>" ] , "<STR_LIT>" ) <EOL> def test__paginated_request ( self ) : <EOL> DigitalOceanMockHttp . type = '<STR_LIT>' <EOL> actions = self . driver . _paginated_request ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( actions [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( actions [ <NUM_LIT:0> ] [ '<STR_LIT:status>' ] , '<STR_LIT>' ) <EOL> class DigitalOceanMockHttp ( MockHttpTestCase ) : <EOL> fixtures = FileFixtures ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> response = { <EOL> None : httplib . OK , <EOL> '<STR_LIT>' : httplib . CREATED , <EOL> '<STR_LIT>' : httplib . NO_CONTENT , <EOL> '<STR_LIT>' : httplib . OK , <EOL> '<STR_LIT>' : httplib . NOT_FOUND , <EOL> '<STR_LIT>' : httplib . UNAUTHORIZED , <EOL> '<STR_LIT>' : httplib . OK <EOL> } <EOL> def _v2_account ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( self . response [ self . type ] , body , { } , <EOL> httplib . responses [ self . response [ self . type ] ] ) <EOL> def _v2_account_UNAUTHORIZED ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( <EOL> '<STR_LIT>' ) <EOL> return ( self . response [ self . type ] , body , { } , <EOL> httplib . responses [ self . response [ self . type ] ] ) <EOL> def _v2_actions ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( self . response [ self . type ] , body , { } , <EOL> httplib . responses [ self . response [ self . type ] ] ) <EOL> def _v2_actions_12345670 ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( self . response [ self . type ] , body , { } , <EOL> httplib . responses [ self . response [ self . type ] ] ) <EOL> def _v2_actions_page_1 ( self , method , url , body , headers ) : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( self . response [ None ] , body , { } , <EOL> httplib . responses [ self . response [ None ] ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( unittest . main ( ) ) </s>
