# Path: kiel/zookeeper/party.py
# class Party(object):
#     def __init__(self, client, member_name, path, on_change):
#     def start(self):
#         def member_change(members):
#     def join(self):
#     def leave(self):


import unittest
from mock import Mock
from kazoo.exceptions import NoNodeError
from kiel.zookeeper import party
        client.exists.return_value = Mock(owner_session_id=1234)
        client.client_id = (4321, 0)

        p = party.Party(client, "host.local", "/my/party", Mock())

        p.join()

        client.transaction.assert_called_once_with()
        transaction = client.transaction.return_value
        transaction.delete.assert_called_once_with("/my/party/host.local")
        transaction.create.assert_called_once_with(
            "/my/party/host.local", ephemeral=True
        )
        transaction.commit.assert_called_once_with()

    def test_join_when_znode_belongs_to_us(self):
        client = Mock()
        client.exists.return_value = Mock(owner_session_id=1234)
        client.client_id = (1234, 0)

        p = party.Party(client, "host.local", "/my/party", Mock())

        p.join()

        assert client.create.called is False
        assert client.transaction.called is False

    def test_leave(self):
        client = Mock()


# Path: kiel/zookeeper/party.py
# class Party(object):
#     def __init__(self, client, member_name, path, on_change):
#     def start(self):
#         def member_change(members):
#     def join(self):
#     def leave(self):


# Path: tests/zookeeper/test_party.py
import unittest
from mock import Mock
from kazoo.exceptions import NoNodeError
from kiel.zookeeper import party

        client.exists.return_value = Mock(owner_session_id=1234)
        client.client_id = (4321, 0)

        p = party.Party(client, "host.local", "/my/party", Mock())

        p.join()

        client.transaction.assert_called_once_with()
        transaction = client.transaction.return_value
        transaction.delete.assert_called_once_with("/my/party/host.local")
        transaction.create.assert_called_once_with(
            "/my/party/host.local", ephemeral=True
        )
        transaction.commit.assert_called_once_with()

    def test_join_when_znode_belongs_to_us(self):
        client = Mock()
        client.exists.return_value = Mock(owner_session_id=1234)
        client.client_id = (1234, 0)

        p = party.Party(client, "host.local", "/my/party", Mock())

        p.join()

        assert client.create.called is False
        assert client.transaction.called is False

    def test_leave(self):
        client = Mock()


        p = party.Party(client, "host.local", "/my/party", Mock())