<s> import uuid <EOL> from nose . tools import eq_ <EOL> from kazoo . testing import KazooTestCase <EOL> class KazooPartyTests ( KazooTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( KazooPartyTests , self ) . setUp ( ) <EOL> self . path = "<STR_LIT:/>" + uuid . uuid4 ( ) . hex <EOL> def test_party ( self ) : <EOL> parties = [ self . client . Party ( self . path , "<STR_LIT>" % i ) <EOL> for i in range ( <NUM_LIT:5> ) ] <EOL> one_party = parties [ <NUM_LIT:0> ] <EOL> eq_ ( list ( one_party ) , [ ] ) <EOL> eq_ ( len ( one_party ) , <NUM_LIT:0> ) <EOL> participants = set ( ) <EOL> for party in parties : <EOL> party . join ( ) <EOL> participants . add ( party . data . decode ( '<STR_LIT:utf-8>' ) ) <EOL> eq_ ( set ( party ) , participants ) <EOL> eq_ ( len ( party ) , len ( participants ) ) <EOL> for party in parties : <EOL> party . leave ( ) <EOL> participants . remove ( party . data . decode ( '<STR_LIT:utf-8>' ) ) <EOL> eq_ ( set ( party ) , participants ) <EOL> eq_ ( len ( party ) , len ( participants ) ) <EOL> def test_party_reuse_node ( self ) : <EOL> party = self . client . Party ( self . path , "<STR_LIT>" ) <EOL> self . client . ensure_path ( self . path ) <EOL> self . client . create ( party . create_path ) <EOL> party . join ( ) <EOL> self . assertTrue ( party . participating ) <EOL> party . leave ( ) <EOL> self . assertFalse ( party . participating ) <EOL> self . assertEqual ( len ( party ) , <NUM_LIT:0> ) <EOL> def test_party_vanishing_node ( self ) : <EOL> party = self . client . Party ( self . path , "<STR_LIT>" ) <EOL> party . join ( ) <EOL> self . assertTrue ( party . participating ) <EOL> self . client . delete ( party . create_path ) <EOL> party . leave ( ) <EOL> self . assertFalse ( party . participating ) <EOL> self . assertEqual ( len ( party ) , <NUM_LIT:0> ) <EOL> class KazooShallowPartyTests ( KazooTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( KazooShallowPartyTests , self ) . setUp ( ) <EOL> self . path = "<STR_LIT:/>" + uuid . uuid4 ( ) . hex <EOL> def test_party ( self ) : <EOL> parties = [ self . client . ShallowParty ( self . path , "<STR_LIT>" % i ) <EOL> for i in range ( <NUM_LIT:5> ) ] <EOL> one_party = parties [ <NUM_LIT:0> ] <EOL> eq_ ( list ( one_party ) , [ ] ) <EOL> eq_ ( len ( one_party ) , <NUM_LIT:0> ) <EOL> participants = set ( ) <EOL> for party in parties : <EOL> party . join ( ) <EOL> participants . add ( party . data . decode ( '<STR_LIT:utf-8>' ) ) <EOL> eq_ ( set ( party ) , participants ) <EOL> eq_ ( len ( party ) , len ( participants ) ) <EOL> for party in parties : <EOL> party . leave ( ) <EOL> participants . remove ( party . data . decode ( '<STR_LIT:utf-8>' ) ) <EOL> eq_ ( set ( party ) , participants ) <EOL> eq_ ( len ( party ) , len ( participants ) ) </s>
