<s> from __future__ import absolute_import <EOL> import mock <EOL> from httplib import HTTPException <EOL> from nydus . db . backends . riak import Riak <EOL> from nydus . testutils import BaseTest <EOL> from riak import RiakClient , RiakError <EOL> from socket import error as SocketError <EOL> class RiakTest ( BaseTest ) : <EOL> def setUp ( self ) : <EOL> self . expected_defaults = { <EOL> '<STR_LIT:host>' : '<STR_LIT:127.0.0.1>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> self . modified_props = { <EOL> '<STR_LIT:host>' : '<STR_LIT>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : mock . Mock , <EOL> '<STR_LIT>' : mock . Mock , <EOL> } <EOL> self . conn = Riak ( <NUM_LIT:0> ) <EOL> self . modified_conn = Riak ( <NUM_LIT:1> , ** self . modified_props ) <EOL> def test_init_defaults ( self ) : <EOL> self . assertDictContainsSubset ( self . expected_defaults , self . conn . __dict__ ) <EOL> def test_init_properties ( self ) : <EOL> self . assertDictContainsSubset ( self . modified_props , self . modified_conn . __dict__ ) <EOL> def test_identifier ( self ) : <EOL> expected_identifier = '<STR_LIT>' % self . conn . __dict__ <EOL> self . assertEquals ( expected_identifier , self . conn . identifier ) <EOL> def test_identifier_properties ( self ) : <EOL> expected_identifier = '<STR_LIT>' % self . modified_props <EOL> self . assertEquals ( expected_identifier , self . modified_conn . identifier ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_connect_riakclient_options ( self , _RiakClient ) : <EOL> self . conn . connect ( ) <EOL> _RiakClient . assert_called_with ( host = self . conn . host , port = self . conn . port , prefix = self . conn . prefix , mapred_prefix = self . conn . mapred_prefix , client_id = self . conn . client_id , transport_options = self . conn . transport_options , transport_class = self . conn . transport_class , solr_transport_class = self . conn . solr_transport_class ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_connect_riakclient_modified_options ( self , _RiakClient ) : <EOL> self . modified_conn . connect ( ) <EOL> _RiakClient . assert_called_with ( host = self . modified_conn . host , port = self . modified_conn . port , prefix = self . modified_conn . prefix , mapred_prefix = self . modified_conn . mapred_prefix , client_id = self . modified_conn . client_id , transport_options = self . modified_conn . transport_options , transport_class = self . modified_conn . transport_class , solr_transport_class = self . modified_conn . solr_transport_class ) <EOL> def test_connect_returns_riakclient ( self ) : <EOL> client = self . conn . connect ( ) <EOL> self . assertIsInstance ( client , RiakClient ) <EOL> def test_provides_retryable_exceptions ( self ) : <EOL> self . assertItemsEqual ( [ RiakError , HTTPException , SocketError ] , self . conn . retryable_exceptions ) </s>
