@@ -113,12 +113,16 @@ def __init__(self):
113113 self .ssl_options = None
114114
115115 def add_host (self , endpoint , datacenter , rack , signal = False , refresh_nodes = True , host_id = None ,
116- is_zero_token = False ):
116+ is_zero_token = None ):
117117 host = Host (endpoint , SimpleConvictionPolicy , datacenter , rack , host_id = host_id )
118- host .is_zero_token = is_zero_token
119- host , _ = self .metadata .add_or_return_host (host )
120- self .added_hosts .append (host )
121- return host , True
118+ if is_zero_token is not None :
119+ host .is_zero_token = is_zero_token
120+ host , new = self .metadata .add_or_return_host (host )
121+ if is_zero_token is not None :
122+ host .is_zero_token = is_zero_token
123+ if new :
124+ self .added_hosts .append (host )
125+ return host , new
122126
123127 def remove_host (self , host ):
124128 pass
@@ -218,6 +222,22 @@ def _assert_zero_token_host_without_token_map_entry(self, endpoint, host_id):
218222 assert zero_token_host not in self .cluster .metadata .token_map
219223 return zero_token_host
220224
225+ def test_mock_add_host_updates_zero_token_status_for_existing_host (self ):
226+ endpoint = DefaultEndPoint ("192.168.1.0" )
227+
228+ host , new = self .cluster .add_host (endpoint , "dc1" , "rack1" , signal = False ,
229+ host_id = "uuid1" , is_zero_token = True )
230+
231+ assert new is False
232+ assert host .is_zero_token is True
233+
234+ same_host , new = self .cluster .add_host (endpoint , "dc1" , "rack1" , signal = False ,
235+ host_id = "uuid1" , is_zero_token = False )
236+
237+ assert new is False
238+ assert same_host is host
239+ assert same_host .is_zero_token is False
240+
221241 def test_wait_for_schema_agreement (self ):
222242 """
223243 Basic test with all schema versions agreeing
0 commit comments